OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ComponentHost.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Holds a single text file component from a group */
19 
20 #ifndef INC_C4ComponentHost
21 #define INC_C4ComponentHost
22 
24 {
25 public:
26  C4ComponentHost() = default;
27  virtual ~C4ComponentHost() { Clear(); }
28  const char *GetFilePath() const { return FilePath.getData(); }
29  void Clear() { Data.Clear(); OnLoad(); }
30  const char *GetData() const { return Data.getData(); }
31  const StdStrBuf & GetDataBuf() const { return Data; }
32  size_t GetDataSize() const { return Data.getLength(); }
33  bool Load(C4Group &hGroup, const char *szFilename, const char *szLanguage=nullptr);
34  bool Load(C4GroupSet &hGroupSet, const char *szFilename, const char *szLanguage=nullptr);
35  bool GetLanguageString(const char *szLanguage, StdStrBuf &rTarget);
36 protected:
37  // The component host's Data has changed. This callback can be used by
38  // derived classes to reload internal structures.
39  virtual void OnLoad() {}
40 
44  void CopyFilePathFromGroup(const C4Group &hGroup);
45  void FinishLoad(const StdStrBuf &, C4Group &hGroup);
46 };
47 
48 #endif
const char * getData() const
Definition: StdBuf.h:442
void FinishLoad(const StdStrBuf &, C4Group &hGroup)
bool Load(C4Group &hGroup, const char *szFilename, const char *szLanguage=nullptr)
void Clear()
Definition: StdBuf.h:466
const char * GetData() const
StdCopyStrBuf FilePath
const StdStrBuf & GetDataBuf() const
void CopyFilePathFromGroup(const C4Group &hGroup)
size_t GetDataSize() const
bool GetLanguageString(const char *szLanguage, StdStrBuf &rTarget)
virtual ~C4ComponentHost()
StdCopyStrBuf Data
virtual void OnLoad()
C4ComponentHost()=default
size_t getLength() const
Definition: StdBuf.h:445
StdCopyStrBuf Filename
const char * GetFilePath() const