OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Folder.cpp
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 
17 /* Core component of a folder */
18 
19 #include "C4Include.h"
20 #include "gui/C4Folder.h"
21 
22 #include "c4group/C4Group.h"
23 #include "c4group/C4Components.h"
24 
25 
26 //================= C4FolderHead ====================
27 
29 {
30  Index = 0;
31 }
32 
34 {
35  pComp->Value(mkNamingAdapt(Index, "Index", 0));
36 }
37 
38 //=================== C4Folder ======================
39 
41 {
42  Default();
43 }
44 
46 {
47  Head.Default();
48 }
49 
50 bool C4Folder::Load(C4Group &hGroup)
51 {
52  char *pSource;
53  // Load
54  if (!hGroup.LoadEntry(C4CFN_FolderCore, &pSource, nullptr, 1)) return false;
55  // Compile
56  if (!Compile(pSource)) { delete [] pSource; return false; }
57  delete [] pSource;
58  // Success
59  return true;
60 }
61 
63 {
64  pComp->Value(mkNamingAdapt(Head, "Head"));
65 }
66 
67 bool C4Folder::Compile(const char *szSource)
68 {
69  Default();
70  return CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, StdStrBuf(szSource), C4CFN_FolderCore);
71 }
72 
C4FolderHead Head
Definition: C4Folder.h:36
void Default()
Definition: C4Folder.cpp:45
void Default()
Definition: C4Folder.cpp:28
bool LoadEntry(const char *szEntryName, char **lpbpBuf, size_t *ipSize=nullptr, int iAppendZeros=0)
Definition: C4Group.cpp:1893
C4Folder()
Definition: C4Folder.cpp:40
#define C4CFN_FolderCore
Definition: C4Components.h:44
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
bool Load(C4Group &hGroup)
Definition: C4Folder.cpp:50
bool Compile(const char *szSource)
Definition: C4Folder.cpp:67
void CompileFunc(StdCompiler *pComp)
Definition: C4Folder.cpp:62
void Value(const T &rStruct)
Definition: StdCompiler.h:161
void CompileFunc(StdCompiler *pComp)
Definition: C4Folder.cpp:33
int32_t Index
Definition: C4Folder.h:25