OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
StdCompilerINIRead Class Reference

#include <StdCompiler.h>

Inheritance diagram for StdCompilerINIRead:
[legend]
Collaboration diagram for StdCompilerINIRead:
[legend]

Classes

struct  NameNode
 

Public Types

typedef StdStrBuf InT
 
enum  Sep {
  SEP_NONE =0, SEP_SEP, SEP_SEP2, SEP_SET,
  SEP_PART, SEP_PART2, SEP_PLUS, SEP_START,
  SEP_END, SEP_START2, SEP_END2, SEP_VLINE,
  SEP_DOLLAR
}
 
enum  RawCompileType {
  RCT_Escaped =0, RCT_All, RCT_Idtf, RCT_IdtfAllowEmpty,
  RCT_ID
}
 
typedef void(* WarnCBT )(void *, const char *, const char *)
 

Public Member Functions

 StdCompilerINIRead ()
 
 ~StdCompilerINIRead () override
 
void setInput (const InT &In)
 
bool isDeserializer () override
 
bool hasNaming () override
 
bool Name (const char *szName) override
 
void NameEnd (bool fBreak=false) override
 
bool FollowName (const char *szName) override
 
const char * GetNameByIndex (size_t idx) const override
 
bool Separator (Sep eSep) override
 
void NoSeparator () override
 
int NameCount (const char *szName=nullptr) override
 
void DWord (int32_t &rInt) override
 
void DWord (uint32_t &rInt) override
 
void Word (int16_t &rShort) override
 
void Word (uint16_t &rShort) override
 
void Byte (int8_t &rByte) override
 
void Byte (uint8_t &rByte) override
 
void Boolean (bool &rBool) override
 
void Character (char &rChar) override
 
void String (char *szString, size_t iMaxLength, RawCompileType eType=RCT_Escaped) override
 
void String (char **pszString, RawCompileType eType=RCT_Escaped) override
 
void String (std::string &str, RawCompileType eType=RCT_Escaped) override
 
void Raw (void *pData, size_t iSize, RawCompileType eType=RCT_Escaped) override
 
StdStrBuf getPosition () const override
 
void Begin () override
 
void End () override
 
virtual bool isDoublePass ()
 
bool isSerializer ()
 
virtual bool isVerbose ()
 
virtual bool isRegistry ()
 
virtual void setRuntimeWritesAllowed (int32_t iChange)
 
virtual bool Default (const char *szName)
 
virtual void BeginSecond ()
 
template<class T >
void Value (const T &rStruct)
 
template<class T >
void Value (T &rStruct)
 
void Value (int32_t &rInt)
 
void Value (uint32_t &rInt)
 
void Value (int16_t &rInt)
 
void Value (uint16_t &rInt)
 
void Value (int8_t &rInt)
 
void Value (uint8_t &rInt)
 
void Value (bool &rBool)
 
template<class T >
void Compile (T &&rStruct)
 
template<class T >
void Decompile (const T &rStruct)
 
void excNotFound (const char *szMessage,...)
 
void excEOF (const char *szMessage="EOF",...)
 
void excCorrupt (const char *szMessage,...)
 
void setWarnCallback (WarnCBT pnWarnCB, void *pData)
 
void Warn (const char *szWarning,...)
 

Protected Member Functions

void CreateNameTree ()
 
void FreeNameTree ()
 
void FreeNameNode (NameNode *pNode)
 
void SkipWhitespace ()
 
void SkipNum ()
 
long ReadNum ()
 
size_t GetStringLength (RawCompileType eTyped)
 
StdBuf ReadString (size_t iLength, RawCompileType eTyped, bool fAppendNull=true)
 
bool TestStringEnd (RawCompileType eType)
 
char ReadEscapedChar ()
 
unsigned long ReadUNum ()
 
void notFound (const char *szWhat)
 
template<class T >
void DoCompilation (T &rStruct)
 

Static Protected Member Functions

static char SeparatorToChar (Sep eSep)
 
static bool IsStringEnd (char c, RawCompileType eType)
 

Protected Attributes

NameNodepNameRoot {nullptr}
 
NameNodepName
 
int iDepth {0}
 
int iRealDepth {0}
 
StdStrBuf Buf
 
const char * pPos
 
const char * pReenter
 
StdCopyStrBuf NotFoundName
 

Detailed Description

Definition at line 621 of file StdCompiler.h.

Member Typedef Documentation

Definition at line 629 of file StdCompiler.h.

typedef void(* StdCompiler::WarnCBT)(void *, const char *, const char *)
inherited

Definition at line 281 of file StdCompiler.h.

Member Enumeration Documentation

Enumerator
RCT_Escaped 
RCT_All 
RCT_Idtf 
RCT_IdtfAllowEmpty 
RCT_ID 

Definition at line 135 of file StdCompiler.h.

136  {
137  RCT_Escaped=0,// Any data allowed, no separator needed (default)
138  RCT_All, // Printable characters only, must be last element in naming.
139  RCT_Idtf, // Alphanumerical characters or '_', separator needed.
140  RCT_IdtfAllowEmpty, // Like RCT_Idtf, but empty strings are also allowed
141  RCT_ID // Like RCT_Idtf (only used for special compilers that treat IDs differently)
142  };
enum StdCompiler::Sep
inherited
Enumerator
SEP_NONE 
SEP_SEP 
SEP_SEP2 
SEP_SET 
SEP_PART 
SEP_PART2 
SEP_PLUS 
SEP_START 
SEP_END 
SEP_START2 
SEP_END2 
SEP_VLINE 
SEP_DOLLAR 

Definition at line 103 of file StdCompiler.h.

104  {
105  SEP_NONE=0, // No separator ("")
106  SEP_SEP, // Array separation (",")
107  SEP_SEP2, // Array separation 2 (";")
108  SEP_SET, // Map pair separation ("=")
109  SEP_PART, // Value part separation (".")
110  SEP_PART2, // Value part separation 2 (":")
111  SEP_PLUS, // Value separation with a '+' char ("+")
112  SEP_START, // Start some sort of list ('(')
113  SEP_END, // End some sort of list ('(')
114  SEP_START2, // Start some sort of list ('[')
115  SEP_END2, // End some sort of list (']')
116  SEP_VLINE, // Vertical line separator ('|')
117  SEP_DOLLAR // Dollar sign ('$')
118  };

Constructor & Destructor Documentation

StdCompilerINIRead::StdCompilerINIRead ( )
default
StdCompilerINIRead::~StdCompilerINIRead ( )
override

Definition at line 450 of file StdCompiler.cpp.

References FreeNameTree().

451 {
452  FreeNameTree();
453 }

Here is the call graph for this function:

Member Function Documentation

void StdCompilerINIRead::Begin ( )
overridevirtual

Reimplemented from StdCompiler.

Definition at line 740 of file StdCompiler.cpp.

References CreateNameTree(), iDepth, iRealDepth, pNameRoot, pPos, and pReenter.

Referenced by C4Network2RefClient::GetReferences().

741 {
742  // Already running? This may happen if someone confuses Compile with Value.
743  assert(!iDepth && !iRealDepth && !pNameRoot);
744  // Create tree
745  CreateNameTree();
746  // Start must be inside a section
747  iDepth = iRealDepth = 0;
748  pPos = nullptr; pReenter = nullptr;
749 }
const char * pPos
Definition: StdCompiler.h:702
NameNode * pNameRoot
Definition: StdCompiler.h:693
const char * pReenter
Definition: StdCompiler.h:705

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void StdCompiler::BeginSecond ( )
inlinevirtualinherited

Reimplemented in StdCompilerBinWrite.

Definition at line 155 of file StdCompiler.h.

Referenced by StdCompiler::DoCompilation().

155 { }

Here is the caller graph for this function:

void StdCompilerINIRead::Boolean ( bool &  rBool)
overridevirtual

Implements StdCompiler.

Definition at line 641 of file StdCompiler.cpp.

References notFound(), pPos, and SEqual2().

642 {
643  if (!pPos) { notFound("Boolean"); return; }
644  if (*pPos == '1' && !isdigit((unsigned char)*(pPos+1)))
645  { rBool = true; pPos ++; }
646  else if (*pPos == '0' && !isdigit((unsigned char)*(pPos+1)))
647  { rBool = false; pPos ++; }
648  else if (SEqual2(pPos, "true"))
649  { rBool = true; pPos += 4; }
650  else if (SEqual2(pPos, "false"))
651  { rBool = false; pPos += 5; }
652  else
653  { notFound("Boolean"); return; }
654 }
const char * pPos
Definition: StdCompiler.h:702
void notFound(const char *szWhat)
bool SEqual2(const char *szStr1, const char *szStr2)
Definition: Standard.cpp:198

Here is the call graph for this function:

void StdCompilerINIRead::Byte ( int8_t &  rByte)
overridevirtual

Implements StdCompiler.

Definition at line 625 of file StdCompiler.cpp.

References Clamp(), ReadNum(), and StdCompiler::Warn().

626 {
627  const int MIN = -(1 << 7), MAX = (1 << 7) - 1;
628  int iNum = ReadNum();
629  if (iNum < MIN || iNum > MAX)
630  Warn("number out of range (%d to %d): %d ", MIN, MAX, iNum);
631  rByte = Clamp(iNum, MIN, MAX);
632 }
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:44
void Warn(const char *szWarning,...)
Definition: StdCompiler.cpp:21

Here is the call graph for this function:

void StdCompilerINIRead::Byte ( uint8_t &  rByte)
overridevirtual

Implements StdCompiler.

Definition at line 633 of file StdCompiler.cpp.

References Clamp(), ReadUNum(), and StdCompiler::Warn().

634 {
635  const unsigned int MIN = 0, MAX = (1 << 8) - 1;
636  unsigned int iNum = ReadUNum();
637  if (iNum > MAX)
638  Warn("number out of range (%u to %u): %u ", MIN, MAX, iNum);
639  rByte = Clamp(iNum, MIN, MAX);
640 }
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:44
unsigned long ReadUNum()
void Warn(const char *szWarning,...)
Definition: StdCompiler.cpp:21

Here is the call graph for this function:

void StdCompilerINIRead::Character ( char &  rChar)
overridevirtual

Implements StdCompiler.

Definition at line 655 of file StdCompiler.cpp.

References notFound(), and pPos.

656 {
657  if (!pPos || !isalpha((unsigned char)*pPos))
658  { notFound("Character"); return; }
659  rChar = *pPos++;
660 }
const char * pPos
Definition: StdCompiler.h:702
void notFound(const char *szWhat)

Here is the call graph for this function:

template<class T >
void StdCompiler::Compile ( T &&  rStruct)
inlineinherited

Definition at line 173 of file StdCompiler.h.

References StdCompiler::DoCompilation(), and StdCompiler::isDeserializer().

Referenced by C4Config::Default(), C4GameParameters::Load(), C4Config::Load(), C4ConfigGamepad::Reset(), and C4ConfigGamepad::ResetButtons().

174  {
175  assert(isDeserializer());
176  DoCompilation(rStruct);
177  }
void DoCompilation(T &rStruct)
Definition: StdCompiler.h:188
virtual bool isDeserializer()
Definition: StdCompiler.h:53

Here is the call graph for this function:

Here is the caller graph for this function:

void StdCompilerINIRead::CreateNameTree ( )
protected

Definition at line 756 of file StdCompiler.cpp.

References StdStrBuf::AppendChar(), Buf, StdCompilerINIRead::NameNode::FirstChild, FreeNameTree(), StdStrBuf::getPtr(), StdCompilerINIRead::NameNode::Indent, StdCompilerINIRead::NameNode::LastChild, Name(), StdCompilerINIRead::NameNode::Name, StdCompilerINIRead::NameNode::NextChild, StdCompilerINIRead::NameNode::Parent, pName, pNameRoot, StdCompilerINIRead::NameNode::Pos, pPos, StdCompilerINIRead::NameNode::PrevChild, StdCompilerINIRead::NameNode::Section, StdStrBuf::Take(), and StdCompiler::Warn().

Referenced by Begin().

757 {
758  FreeNameTree();
759  // Create root node
760  pName = pNameRoot = new NameNode();
761  // No input? Stop
762  if (!Buf) return;
763  // Start scanning
764  pPos = Buf.getPtr(0);
765  while (*pPos)
766  {
767  // Go over whitespace
768  int iIndent = 0;
769  while (*pPos == ' ' || *pPos == '\t')
770  { pPos++; iIndent++; }
771  // Name/Section?
772  bool fSection = *pPos == '[' && isalpha((unsigned char)*(pPos+1));
773  if (fSection || isalpha((unsigned char)*pPos))
774  {
775  // Treat values as if they had more indention
776  // (so they become children of sections on the same level)
777  if (!fSection) iIndent++; else pPos++;
778  // Go up in tree structure if there is less indention
779  while (pName->Parent && pName->Indent >= iIndent)
780  pName = pName->Parent;
781  // Copy name
782  StdStrBuf Name;
783  while (isalnum((unsigned char)*pPos) || *pPos == ' ' || *pPos == '_')
784  Name.AppendChar(*pPos++);
785  while (*pPos == ' ' || *pPos == '\t') pPos++;
786  if ( *pPos != (fSection ? ']' : '=') )
787  // Warn, ignore
788  Warn(isprint((unsigned char)*pPos) ? "Unexpected character ('%c'): %s ignored" : "Unexpected character ('0x%02x'): %s ignored", unsigned(*pPos), fSection ? "section" : "value");
789  else
790  {
791  pPos++;
792  // Create new node
793  NameNode *pPrev = pName->LastChild;
794  pName =
795  pName->LastChild =
797  new NameNode(pName);
798  pName->PrevChild = pPrev;
799  pName->Name.Take(std::move(Name));
800  pName->Pos = pPos;
801  pName->Indent = iIndent;
802  pName->Section = fSection;
803  // Values don't have children (even if the indention looks like it)
804  if (!fSection)
805  pName = pName->Parent;
806  }
807  }
808  // Skip line
809  while (*pPos && (*pPos != '\n' && *pPos != '\r'))
810  pPos++;
811  while (*pPos == '\n' || *pPos == '\r')
812  pPos++;
813  }
814  // Set pointer back
815  pName = pNameRoot;
816 }
const char * pPos
Definition: StdCompiler.h:702
void AppendChar(char cChar)
Definition: StdBuf.h:588
NameNode * pNameRoot
Definition: StdCompiler.h:693
bool Name(const char *szName) override
void Take(char *pnData)
Definition: StdBuf.h:457
void Warn(const char *szWarning,...)
Definition: StdCompiler.cpp:21
const char * getPtr(size_t i) const
Definition: StdBuf.h:448
NameNode * pName
Definition: StdCompiler.h:693

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
void StdCompiler::Decompile ( const T &  rStruct)
inlineinherited

Definition at line 178 of file StdCompiler.h.

References StdCompiler::DoCompilation(), and StdCompiler::isDeserializer().

Referenced by GetValByStdCompiler(), and C4Config::Save().

179  {
180  assert(!isDeserializer());
181  DoCompilation(const_cast<T &>(rStruct));
182  }
void DoCompilation(T &rStruct)
Definition: StdCompiler.h:188
virtual bool isDeserializer()
Definition: StdCompiler.h:53

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool StdCompiler::Default ( const char *  szName)
inlinevirtualinherited

Reimplemented in C4ValueCompiler.

Definition at line 88 of file StdCompiler.h.

Referenced by StdNamingDefaultAdapt< T, D >::CompileFunc(), C4ConfigControls::CompileFunc(), and C4PlayerControlAssignmentSets::CompileFunc().

88 { return true; }

Here is the caller graph for this function:

template<class T >
void StdCompiler::DoCompilation ( T &  rStruct)
inlineprotectedinherited

Definition at line 188 of file StdCompiler.h.

References StdCompiler::Begin(), StdCompiler::BeginSecond(), StdCompiler::End(), StdCompiler::isDoublePass(), and StdCompiler::Value().

Referenced by StdCompiler::Compile(), and StdCompiler::Decompile().

189  {
190  // Start compilation, do first pass
191  Begin();
192  Value(rStruct);
193  // Second pass needed?
194  if (isDoublePass())
195  {
196  BeginSecond();
197  Value(rStruct);
198  }
199  // Finish
200  End();
201  }
virtual void End()
Definition: StdCompiler.h:156
virtual bool isDoublePass()
Definition: StdCompiler.h:50
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual void Begin()
Definition: StdCompiler.h:154
virtual void BeginSecond()
Definition: StdCompiler.h:155

Here is the call graph for this function:

Here is the caller graph for this function:

void StdCompilerINIRead::DWord ( int32_t &  rInt)
overridevirtual

Implements StdCompiler.

Definition at line 601 of file StdCompiler.cpp.

References ReadNum().

602 {
603  rInt = ReadNum();
604 }

Here is the call graph for this function:

void StdCompilerINIRead::DWord ( uint32_t &  rInt)
overridevirtual

Implements StdCompiler.

Definition at line 605 of file StdCompiler.cpp.

References ReadUNum().

606 {
607  rInt = ReadUNum();
608 }
unsigned long ReadUNum()

Here is the call graph for this function:

void StdCompilerINIRead::End ( )
overridevirtual

Reimplemented from StdCompiler.

Definition at line 750 of file StdCompiler.cpp.

References FreeNameTree(), iDepth, and iRealDepth.

Referenced by C4Network2RefClient::GetReferences().

751 {
752  assert(!iDepth && !iRealDepth);
753  FreeNameTree();
754 }

Here is the call graph for this function:

Here is the caller graph for this function:

void StdCompiler::excCorrupt ( const char *  szMessage,
  ... 
)
inlineinherited

Definition at line 249 of file StdCompiler.h.

References FormatStringV(), and StdCompiler::getPosition().

Referenced by C4MeshDenumerator::CompileFunc(), C4Network2ResCore::CompileFunc(), C4RoundResultsPlayers::CompileFunc(), C4DefGraphicsAdapt::CompileFunc(), C4Network2ResChunkData::CompileFunc(), C4Value::CompileFunc(), C4PropListNumbered::CompileFunc(), C4KeyCodeEx::CompileFunc(), StdSubMeshInstance::CompileFunc(), C4IDPacket::CompileFunc(), C4ClientPlayerInfos::CompileFunc(), StdMeshInstanceAnimationNode::CompileFunc(), C4PlayerInfoList::CompileFunc(), StdMeshInstance::CompileFunc(), C4ValueNumbers::CompileValue(), C4PropListStatic::RefCompileFunc(), and StdCompilerBinRead::String().

250  {
251  // Throw the appropriate exception
252  va_list args; va_start(args, szMessage);
253  throw new CorruptException(getPosition(), FormatStringV(szMessage, args));
254  }
virtual StdStrBuf getPosition() const
Definition: StdCompiler.h:151
StdStrBuf FormatStringV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:276

Here is the call graph for this function:

Here is the caller graph for this function:

void StdCompiler::excEOF ( const char *  szMessage = "EOF",
  ... 
)
inlineinherited

Definition at line 243 of file StdCompiler.h.

References FormatStringV(), and StdCompiler::getPosition().

Referenced by StdCompilerBinRead::Raw(), StdCompilerBinRead::ReadValue(), and StdCompilerBinRead::String().

244  {
245  // Throw the appropriate exception
246  va_list args; va_start(args, szMessage);
247  throw new EOFException(getPosition(), FormatStringV(szMessage, args));
248  }
virtual StdStrBuf getPosition() const
Definition: StdCompiler.h:151
StdStrBuf FormatStringV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:276

Here is the call graph for this function:

Here is the caller graph for this function:

void StdCompiler::excNotFound ( const char *  szMessage,
  ... 
)
inlineinherited

Definition at line 233 of file StdCompiler.h.

References FormatStringV(), and StdCompiler::getPosition().

Referenced by C4ScenarioParameterDef::Option::CompileFunc(), C4PlayerControlDef::CompileFunc(), C4ScenarioParameterDef::CompileFunc(), C4PlayerControlAssignment::CompileFunc(), C4Object::CompileFunc(), C4PlayerControlAssignmentSet::CompileFunc(), StdHexAdapt::CompileFunc(), and notFound().

234  {
235 #ifdef STDCOMPILER_EXCEPTION_WORKAROUND
236  // Exception workaround: Just set a flag in failesafe mode.
237  if (fFailSafe) { fFail = true; return; }
238 #endif
239  // Throw the appropriate exception
240  va_list args; va_start(args, szMessage);
241  throw new NotFoundException(getPosition(), FormatStringV(szMessage, args));
242  }
virtual StdStrBuf getPosition() const
Definition: StdCompiler.h:151
StdStrBuf FormatStringV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:276

Here is the call graph for this function:

Here is the caller graph for this function:

bool StdCompilerINIRead::FollowName ( const char *  szName)
overridevirtual

Reimplemented from StdCompiler.

Definition at line 518 of file StdCompiler.cpp.

References iDepth, iRealDepth, Name(), StdCompilerINIRead::NameNode::Name, NameEnd(), StdCompilerINIRead::NameNode::NextChild, and pName.

519 {
520  // Current naming virtual?
521  if (iDepth > iRealDepth)
522  return false;
523  // Next section must be the one
524  if (!pName->NextChild || pName->NextChild->Name != szName)
525  {
526  // End current naming
527  NameEnd();
528  // Go into virtual naming
529  iDepth++;
530  return false;
531  }
532  // End current naming
533  NameEnd();
534  // Start new one
535  Name(szName);
536  // Done
537  return true;
538 }
void NameEnd(bool fBreak=false) override
bool Name(const char *szName) override
NameNode * pName
Definition: StdCompiler.h:693

Here is the call graph for this function:

void StdCompilerINIRead::FreeNameNode ( NameNode pNode)
protected

Definition at line 825 of file StdCompiler.cpp.

References StdCompilerINIRead::NameNode::FirstChild, StdCompilerINIRead::NameNode::NextChild, and StdCompilerINIRead::NameNode::Parent.

Referenced by FreeNameTree().

826 {
827  NameNode *pNode = pDelNode;
828  while (pNode)
829  {
830  if (pNode->FirstChild)
831  pNode = pNode->FirstChild;
832  else
833  {
834  NameNode *pDelete = pNode;
835  if (pDelete == pDelNode) { delete pDelete; break; }
836  if (pNode->NextChild)
837  pNode = pNode->NextChild;
838  else
839  {
840  pNode = pNode->Parent;
841  if (pNode) pNode->FirstChild = nullptr;
842  }
843  delete pDelete;
844  }
845  }
846 }

Here is the caller graph for this function:

void StdCompilerINIRead::FreeNameTree ( )
protected

Definition at line 818 of file StdCompiler.cpp.

References FreeNameNode(), pName, and pNameRoot.

Referenced by CreateNameTree(), End(), and ~StdCompilerINIRead().

819 {
820  // free all nodes
822  pName = pNameRoot = nullptr;
823 }
NameNode * pNameRoot
Definition: StdCompiler.h:693
void FreeNameNode(NameNode *pNode)
NameNode * pName
Definition: StdCompiler.h:693

Here is the call graph for this function:

Here is the caller graph for this function:

const char * StdCompilerINIRead::GetNameByIndex ( size_t  idx) const
overridevirtual

Reimplemented from StdCompiler.

Definition at line 585 of file StdCompiler.cpp.

References StdCompilerINIRead::NameNode::FirstChild, StdStrBuf::getData(), iDepth, iRealDepth, StdCompilerINIRead::NameNode::Name, StdCompilerINIRead::NameNode::NextChild, pName, and StdCompilerINIRead::NameNode::Pos.

586 {
587  // not in virtual naming
588  if (iDepth > iRealDepth || !pName) return nullptr;
589  // count within current name
590  NameNode *pNode;
591  for (pNode = pName->FirstChild; pNode; pNode = pNode->NextChild)
592  // all valid subsections are counted
593  if (pNode->Pos)
594  if (!idx--)
595  return pNode->Name.getData();
596  // index out of range
597  return nullptr;
598 }
NameNode * pName
Definition: StdCompiler.h:693

Here is the call graph for this function:

StdStrBuf StdCompilerINIRead::getPosition ( ) const
overridevirtual

Reimplemented from StdCompiler.

Definition at line 728 of file StdCompiler.cpp.

References FormatString(), StdStrBuf::getData(), iDepth, iRealDepth, StdCompilerINIRead::NameNode::Name, NotFoundName, pName, StdCompilerINIRead::NameNode::Pos, pPos, and StdCompilerINIRead::NameNode::Section.

729 {
730  if (pPos)
731  return FormatString("line %d", getLineNumberOfPos(pPos));
732  else if (iDepth == iRealDepth)
733  return FormatString(pName->Section ? R"(section "%s", after line %d)" : R"(value "%s", line %d)", pName->Name.getData(), getLineNumberOfPos(pName->Pos));
734  else if (iRealDepth)
735  return FormatString(R"(missing value/section "%s" inside section "%s" (line %d))", NotFoundName.getData(), pName->Name.getData(), getLineNumberOfPos(pName->Pos));
736  else
737  return FormatString(R"(missing value/section "%s")", NotFoundName.getData());
738 }
const char * getData() const
Definition: StdBuf.h:442
const char * pPos
Definition: StdCompiler.h:702
StdCopyStrBuf NotFoundName
Definition: StdCompiler.h:708
NameNode * pName
Definition: StdCompiler.h:693
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

size_t StdCompilerINIRead::GetStringLength ( RawCompileType  eTyped)
protected

Definition at line 894 of file StdCompiler.cpp.

References notFound(), pPos, StdCompiler::RCT_Escaped, ReadEscapedChar(), SkipWhitespace(), and TestStringEnd().

Referenced by String().

895 {
896  // Excpect valid position
897  if (!pPos)
898  { notFound("String"); return 0; }
899  // Skip whitespace
900  SkipWhitespace();
901  // Save position
902  const char *pStart = pPos;
903  // Escaped? Go over '"'
904  if (eRawType == RCT_Escaped && *pPos++ != '"')
905  { notFound("Escaped string"); return 0; }
906  // Search end of string
907  size_t iLength = 0;
908  while (!TestStringEnd(eRawType))
909  {
910  // Read a character (we're just counting atm)
911  if (eRawType == RCT_Escaped)
912  ReadEscapedChar();
913  else
914  pPos++;
915  // Count it
916  iLength++;
917  }
918  // Reset position, return the length
919  pPos = pStart;
920  return iLength;
921 }
const char * pPos
Definition: StdCompiler.h:702
void notFound(const char *szWhat)
bool TestStringEnd(RawCompileType eType)
Definition: StdCompiler.h:723

Here is the call graph for this function:

Here is the caller graph for this function:

bool StdCompilerINIRead::hasNaming ( )
inlineoverridevirtual

Reimplemented from StdCompiler.

Definition at line 634 of file StdCompiler.h.

634 { return true; }
bool StdCompilerINIRead::isDeserializer ( )
inlineoverridevirtual

Reimplemented from StdCompiler.

Definition at line 633 of file StdCompiler.h.

633 { return true; }
virtual bool StdCompiler::isDoublePass ( )
inlinevirtualinherited

Reimplemented in StdCompilerBinWrite.

Definition at line 50 of file StdCompiler.h.

Referenced by StdCompiler::DoCompilation().

50 { return false; }

Here is the caller graph for this function:

virtual bool StdCompiler::isRegistry ( )
inlinevirtualinherited

Definition at line 65 of file StdCompiler.h.

Referenced by C4PlayerControlAssignmentSets::CompileFunc().

65 { return false; }

Here is the caller graph for this function:

bool StdCompiler::isSerializer ( )
inlineinherited

Definition at line 54 of file StdCompiler.h.

References StdCompiler::isDeserializer().

Referenced by C4NetFilenameAdapt::CompileFunc(), C4ID::CompileFunc(), C4Command::CompileFunc(), StdNamingDefaultAdapt< T, D >::CompileFunc(), C4ObjectList::CompileFunc(), C4FoWLightSection::CompileFunc(), C4Effect::CompileFunc(), StdDecompileAdapt< T >::CompileFunc(), C4PlayerInfo::CompileFunc(), C4ConfigControls::CompileFunc(), C4Game::CompileFunc(), and C4PlayerControlAssignmentSets::CompileFunc().

54 { return !isDeserializer(); }
virtual bool isDeserializer()
Definition: StdCompiler.h:53

Here is the call graph for this function:

Here is the caller graph for this function:

bool StdCompiler::IsStringEnd ( char  c,
RawCompileType  eType 
)
staticprotectedinherited

Definition at line 53 of file StdCompiler.cpp.

References StdCompiler::RCT_All, StdCompiler::RCT_Escaped, StdCompiler::RCT_ID, StdCompiler::RCT_Idtf, and StdCompiler::RCT_IdtfAllowEmpty.

Referenced by TestStringEnd().

54 {
55  switch (eType)
56  {
57  case RCT_Escaped: return c == '"' || !c || c == '\n' || c == '\r';
58  case RCT_All: return !c || c == '\n' || c == '\r';
59  // '-' is needed for Layers in Scenario.txt (C4NameList) and other Material-Texture combinations
60  case RCT_Idtf: case RCT_IdtfAllowEmpty: case RCT_ID: return !isalnum((unsigned char)c) && c != '_' && c != '-';
61  }
62  // unreachable
63  return true;
64 }

Here is the caller graph for this function:

virtual bool StdCompiler::isVerbose ( )
inlinevirtualinherited

Reimplemented in C4ValueCompiler.

Definition at line 62 of file StdCompiler.h.

References StdCompiler::hasNaming().

Referenced by StdEnumAdapt< T, int_t >::CompileFunc(), StdBitfieldAdapt< T >::CompileFunc(), and StdHexAdapt::CompileFunc().

62 { return hasNaming(); }
virtual bool hasNaming()
Definition: StdCompiler.h:58

Here is the call graph for this function:

Here is the caller graph for this function:

bool StdCompilerINIRead::Name ( const char *  szName)
overridevirtual

Reimplemented from StdCompiler.

Definition at line 456 of file StdCompiler.cpp.

References StdCompilerINIRead::NameNode::FirstChild, iDepth, iRealDepth, StdCompilerINIRead::NameNode::Name, StdCompilerINIRead::NameNode::NextChild, NotFoundName, pName, StdCompilerINIRead::NameNode::Pos, pPos, and pReenter.

Referenced by CreateNameTree(), FollowName(), and Separator().

457 {
458  // Increase depth
459  iDepth++;
460  // Parent category virtual?
461  if (iDepth - 1 > iRealDepth)
462  return false;
463  // Name must be alphanumerical and non-empty (force it)
464  if (!isalpha((unsigned char)*szName))
465  { assert(false); return false; }
466  for (const char *p = szName + 1; *p; p++)
467  // C4Update needs Name**...
468  if (!isalnum((unsigned char)*p) && *p != ' ' && *p != '_' && *p != '*')
469  { assert(false); return false; }
470  // Search name
471  NameNode *pNode;
472  for (pNode = pName->FirstChild; pNode; pNode = pNode->NextChild)
473  if (pNode->Pos && pNode->Name == szName)
474  break;
475  // Not found?
476  if (!pNode)
477  {
478  NotFoundName = szName;
479  return false;
480  }
481  // Save tree position, indicate success
482  pName = pNode;
483  pPos = pName->Pos;
484  pReenter = nullptr;
485  iRealDepth++;
486  return true;
487 }
const char * pPos
Definition: StdCompiler.h:702
StdCopyStrBuf NotFoundName
Definition: StdCompiler.h:708
NameNode * pName
Definition: StdCompiler.h:693
const char * pReenter
Definition: StdCompiler.h:705

Here is the caller graph for this function:

int StdCompilerINIRead::NameCount ( const char *  szName = nullptr)
overridevirtual

Reimplemented from StdCompiler.

Definition at line 571 of file StdCompiler.cpp.

References StdCompilerINIRead::NameNode::FirstChild, iDepth, iRealDepth, StdCompilerINIRead::NameNode::Name, StdCompilerINIRead::NameNode::NextChild, pName, and StdCompilerINIRead::NameNode::Pos.

572 {
573  // not in virtual naming
574  if (iDepth > iRealDepth || !pName) return 0;
575  // count within current name
576  int iCount = 0;
577  NameNode *pNode;
578  for (pNode = pName->FirstChild; pNode; pNode = pNode->NextChild)
579  // if no name is given, all valid subsections are counted
580  if (pNode->Pos && (!szName || pNode->Name == szName))
581  ++iCount;
582  return iCount;
583 }
NameNode * pName
Definition: StdCompiler.h:693
void StdCompilerINIRead::NameEnd ( bool  fBreak = false)
overridevirtual

Reimplemented from StdCompiler.

Definition at line 488 of file StdCompiler.cpp.

References StdCompilerINIRead::NameNode::FirstChild, iDepth, iRealDepth, StdCompilerINIRead::NameNode::LastChild, StdCompilerINIRead::NameNode::NextChild, StdCompilerINIRead::NameNode::Parent, pName, pPos, pReenter, StdCompilerINIRead::NameNode::PrevChild, and StdCompiler::Warn().

Referenced by FollowName(), and Separator().

489 {
490  assert(iDepth > 0);
491  if (iRealDepth == iDepth)
492  {
493  // Remove childs
494  for (NameNode *pNode = pName->FirstChild, *pNext; pNode; pNode = pNext)
495  {
496  // Report unused entries
497  if (pNode->Pos && !fBreak)
498  Warn(R"(Unexpected %s "%s"!)", pNode->Section ? "section" : "value", pNode->Name.getData());
499  // delete node
500  pNext = pNode->NextChild;
501  delete pNode;
502  }
503  // Remove name so it won't be found again
504  NameNode *pParent = pName->Parent;
507  delete pName;
508  // Go up
509  pName = pParent;
510  iRealDepth--;
511  }
512  // Decrease depth
513  iDepth--;
514  // This is the middle of nowhere
515  pPos = nullptr; pReenter = nullptr;
516 }
const char * pPos
Definition: StdCompiler.h:702
void Warn(const char *szWarning,...)
Definition: StdCompiler.cpp:21
NameNode * pName
Definition: StdCompiler.h:693
const char * pReenter
Definition: StdCompiler.h:705

Here is the call graph for this function:

Here is the caller graph for this function:

void StdCompilerINIRead::NoSeparator ( )
overridevirtual

Reimplemented from StdCompiler.

Definition at line 565 of file StdCompiler.cpp.

References pPos, and pReenter.

566 {
567  // Position saved back from separator mismatch?
568  if (pReenter) { pPos = pReenter; pReenter = nullptr; }
569 }
const char * pPos
Definition: StdCompiler.h:702
const char * pReenter
Definition: StdCompiler.h:705
void StdCompilerINIRead::notFound ( const char *  szWhat)
protected

Definition at line 1031 of file StdCompiler.cpp.

References StdCompiler::excNotFound().

Referenced by Boolean(), Character(), GetStringLength(), ReadNum(), ReadString(), and ReadUNum().

1032 {
1033  excNotFound("%s expected", szWhat);
1034 }
void excNotFound(const char *szMessage,...)
Definition: StdCompiler.h:233

Here is the call graph for this function:

Here is the caller graph for this function:

void StdCompilerINIRead::Raw ( void *  pData,
size_t  iSize,
RawCompileType  eType = RCT_Escaped 
)
overridevirtual

Implements StdCompiler.

Definition at line 685 of file StdCompiler.cpp.

References Buf, StdBuf::getData(), StdBuf::getSize(), iSize, MemCopy(), ReadString(), and StdCompiler::Warn().

686 {
687  // Read data
688  StdBuf Buf = ReadString(iSize, eType, false);
689  // Correct size?
690  if (Buf.getSize() != iSize)
691  Warn("got %u bytes raw data, but %u bytes expected!", Buf.getSize(), iSize);
692  // Copy
693  MemCopy(Buf.getData(), pData, iSize);
694 }
const void * getData() const
Definition: StdBuf.h:99
Definition: StdBuf.h:29
StdBuf ReadString(size_t iLength, RawCompileType eTyped, bool fAppendNull=true)
size_t getSize() const
Definition: StdBuf.h:101
void MemCopy(const void *lpMem1, void *lpMem2, size_t dwSize)
Definition: Standard.h:65
void Warn(const char *szWarning,...)
Definition: StdCompiler.cpp:21
int iSize
Definition: TstC4NetIO.cpp:32

Here is the call graph for this function:

char StdCompilerINIRead::ReadEscapedChar ( )
protected

Definition at line 974 of file StdCompiler.cpp.

References pPos, and StdCompiler::Warn().

Referenced by GetStringLength(), and ReadString().

975 {
976  // Catch some no-noes like \0, \n etc.
977  if (*pPos >= 0 && iscntrl((unsigned char)*pPos))
978  {
979  Warn("Nonprintable character found in string: %02x", static_cast<unsigned char>(*pPos));
980  return *pPos;
981  }
982  // Not escaped? Just return it
983  if (*pPos != '\\') return *pPos++;
984  // What type of escape?
985  switch (*++pPos)
986  {
987  case 'a': pPos++; return '\a';
988  case 'b': pPos++; return '\b';
989  case 'f': pPos++; return '\f';
990  case 'n': pPos++; return '\n';
991  case 'r': pPos++; return '\r';
992  case 't': pPos++; return '\t';
993  case 'v': pPos++; return '\v';
994  case '\'': pPos++; return '\'';
995  case '"': pPos++; return '"';
996  case '\\': pPos++; return '\\';
997  case '?': pPos++; return '?';
998  case 'x':
999  // Treat '\x' as 'x' - damn special cases
1000  if (!isxdigit((unsigned char)*++pPos))
1001  return 'x';
1002  else
1003  {
1004  // Read everything that looks like it might be hexadecimal - MSVC does it this way, so do not sue me.
1005  int iCode = 0;
1006  do
1007  { iCode = iCode * 16 + (isdigit((unsigned char)*pPos) ? *pPos - '0' : *pPos - 'a' + 10); pPos++; }
1008  while (isxdigit((unsigned char)*pPos));
1009  // Done. Don't bother to check the range (we aren't doing anything mission-critical here, are we?)
1010  return char(iCode);
1011  }
1012  default:
1013  // Not octal? Let it pass through.
1014  if (!isdigit((unsigned char)*pPos) || *pPos >= '8')
1015  return *pPos++;
1016  else
1017  {
1018  // Read it the octal way.
1019  int iCode = 0;
1020  do
1021  { iCode = iCode * 8 + (*pPos - '0'); pPos++;}
1022  while (isdigit((unsigned char)*pPos) && *pPos < '8');
1023  // Done. See above.
1024  return char(iCode);
1025  }
1026  }
1027  // unreachable
1028  assert (false);
1029 }
const char * pPos
Definition: StdCompiler.h:702
void Warn(const char *szWarning,...)
Definition: StdCompiler.cpp:21

Here is the call graph for this function:

Here is the caller graph for this function:

long StdCompilerINIRead::ReadNum ( )
protected

Definition at line 860 of file StdCompiler.cpp.

References notFound(), pPos, and SkipWhitespace().

Referenced by Byte(), DWord(), and Word().

861 {
862  if (!pPos)
863  { notFound("Number"); return 0; }
864  // Skip whitespace
865  SkipWhitespace();
866  // Read number. If this breaks, Günther is to blame!
867  const char *pnPos = pPos;
868  long iNum = strtol(pPos, const_cast<char **>(&pnPos), 10);
869  // Could not read?
870  if (!iNum && pnPos == pPos)
871  { notFound("Number"); return 0; }
872  // Get over it
873  pPos = pnPos;
874  return iNum;
875 }
const char * pPos
Definition: StdCompiler.h:702
void notFound(const char *szWhat)

Here is the call graph for this function:

Here is the caller graph for this function:

StdBuf StdCompilerINIRead::ReadString ( size_t  iLength,
RawCompileType  eTyped,
bool  fAppendNull = true 
)
protected

Definition at line 923 of file StdCompiler.cpp.

References StdBuf::getData(), StdBuf::New(), notFound(), pPos, StdCompiler::RCT_Escaped, StdCompiler::RCT_ID, StdCompiler::RCT_Idtf, ReadEscapedChar(), StdBuf::Shrink(), SkipWhitespace(), TestStringEnd(), and StdCompiler::Warn().

Referenced by Raw(), and String().

924 {
925  // Excpect valid position
926  if (!pPos)
927  { notFound("String"); return StdBuf(); }
928  // Skip whitespace
929  SkipWhitespace();
930  // Escaped? Go over '"'
931  if (eRawType == RCT_Escaped && *pPos++ != '"')
932  { notFound("Escaped string"); return StdBuf(); }
933  // Create buffer
934  StdBuf OutBuf; OutBuf.New(iLength + (fAppendNull ? sizeof('\0') : 0));
935  // Read
936  char *pOut = getMBufPtr<char>(OutBuf);
937  while (iLength && !TestStringEnd(eRawType))
938  {
939  // Read a character
940  if (eRawType == RCT_Escaped)
941  *pOut++ = ReadEscapedChar();
942  else
943  *pOut++ = *pPos++;
944  // Count it
945  iLength--;
946  }
947  // Escaped: Go over '"'
948  if (eRawType == RCT_Escaped)
949  {
950  while (*pPos != '"')
951  {
952  if (!*pPos || *pPos == '\n' || *pPos == '\r')
953  {
954  Warn("string not terminated!");
955  pPos--;
956  break;
957  }
958  pPos++;
959  }
960  pPos++;
961  }
962  // Nothing read? Identifiers need to be non-empty
963  if (pOut == OutBuf.getData() && (eRawType == RCT_Idtf || eRawType == RCT_ID))
964  { notFound("String"); return StdBuf(); }
965  // Append null
966  if (fAppendNull)
967  *pOut = '\0';
968  // Shrink, if less characters were read
969  OutBuf.Shrink(iLength);
970  // Done
971  return OutBuf;
972 }
const void * getData() const
Definition: StdBuf.h:99
Definition: StdBuf.h:29
const char * pPos
Definition: StdCompiler.h:702
void Shrink(size_t iShrink)
Definition: StdBuf.h:180
void New(size_t inSize)
Definition: StdBuf.h:146
void notFound(const char *szWhat)
void Warn(const char *szWarning,...)
Definition: StdCompiler.cpp:21
bool TestStringEnd(RawCompileType eType)
Definition: StdCompiler.h:723

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long StdCompilerINIRead::ReadUNum ( )
protected

Definition at line 877 of file StdCompiler.cpp.

References notFound(), pPos, and SkipWhitespace().

Referenced by Byte(), DWord(), and Word().

878 {
879  if (!pPos)
880  { notFound("Number"); return 0; }
881  // Skip whitespace
882  SkipWhitespace();
883  // Read number. If this breaks, Günther is to blame!
884  const char *pnPos = pPos;
885  unsigned long iNum = strtoul(pPos, const_cast<char **>(&pnPos), 10);
886  // Could not read?
887  if (!iNum && pnPos == pPos)
888  { notFound("Number"); return 0; }
889  // Get over it
890  pPos = pnPos;
891  return iNum;
892 }
const char * pPos
Definition: StdCompiler.h:702
void notFound(const char *szWhat)

Here is the call graph for this function:

Here is the caller graph for this function:

bool StdCompilerINIRead::Separator ( Sep  eSep)
overridevirtual

Reimplemented from StdCompiler.

Definition at line 541 of file StdCompiler.cpp.

References StdStrBuf::getData(), iDepth, iRealDepth, Name(), StdCompilerINIRead::NameNode::Name, NameEnd(), pName, pPos, pReenter, StdCompilerINIRead::NameNode::Section, StdCompiler::SeparatorToChar(), and SkipWhitespace().

542 {
543  if (iDepth > iRealDepth) return false;
544  // In section?
545  if (pName->Section)
546  {
547  // Store current name, search another section with the same name
548  StdStrBuf CurrName = pName->Name;
549  NameEnd();
550  return Name(CurrName.getData());
551  }
552  // Position saved back from separator mismatch?
553  if (pReenter) { pPos = pReenter; pReenter = nullptr; }
554  // Nothing to read?
555  if (!pPos) return false;
556  // Read (while skipping over whitespace)
557  SkipWhitespace();
558  // Separator mismatch? Let all read attempts fail until the correct separator is found or the naming ends.
559  if (*pPos != SeparatorToChar(eSep)) { pReenter = pPos; pPos = nullptr; return false; }
560  // Go over separator, success
561  pPos++;
562  return true;
563 }
const char * getData() const
Definition: StdBuf.h:442
const char * pPos
Definition: StdCompiler.h:702
void NameEnd(bool fBreak=false) override
bool Name(const char *szName) override
static char SeparatorToChar(Sep eSep)
Definition: StdCompiler.cpp:32
NameNode * pName
Definition: StdCompiler.h:693
const char * pReenter
Definition: StdCompiler.h:705

Here is the call graph for this function:

char StdCompiler::SeparatorToChar ( Sep  eSep)
staticprotectedinherited

Definition at line 32 of file StdCompiler.cpp.

References StdCompiler::SEP_DOLLAR, StdCompiler::SEP_END, StdCompiler::SEP_END2, StdCompiler::SEP_PART, StdCompiler::SEP_PART2, StdCompiler::SEP_PLUS, StdCompiler::SEP_SEP, StdCompiler::SEP_SEP2, StdCompiler::SEP_SET, StdCompiler::SEP_START, StdCompiler::SEP_START2, and StdCompiler::SEP_VLINE.

Referenced by StdCompilerINIWrite::Separator(), and Separator().

33 {
34  switch (eSep)
35  {
36  case SEP_SEP: return ',';
37  case SEP_SEP2: return ';';
38  case SEP_SET: return '=';
39  case SEP_PART: return '.';
40  case SEP_PART2: return ':';
41  case SEP_PLUS: return '+';
42  case SEP_START: return '(';
43  case SEP_END: return ')';
44  case SEP_START2: return '[';
45  case SEP_END2: return ']';
46  case SEP_VLINE: return '|';
47  case SEP_DOLLAR: return '$';
48  default: assert(!"Unhandled Separator value");
49  }
50  return ' ';
51 }

Here is the caller graph for this function:

void StdCompilerINIRead::setInput ( const InT In)
inline

Definition at line 630 of file StdCompiler.h.

References Buf, and StdStrBuf::Ref().

Referenced by C4Network2RefClient::GetReferences(), and C4Config::Load().

630 { Buf.Ref(In); lineBreaks.clear(); }
void Ref(const char *pnData)
Definition: StdBuf.h:455

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void StdCompiler::setRuntimeWritesAllowed ( int32_t  iChange)
inlinevirtualinherited

Definition at line 68 of file StdCompiler.h.

Referenced by StdRuntimeValueAdapt< T >::CompileFunc().

68 { }

Here is the caller graph for this function:

void StdCompiler::setWarnCallback ( WarnCBT  pnWarnCB,
void *  pData 
)
inlineinherited

Definition at line 282 of file StdCompiler.h.

282 { pWarnCB = pnWarnCB; pWarnData = pData; }
void StdCompilerINIRead::SkipNum ( )
protected

Definition at line 854 of file StdCompiler.cpp.

References pPos.

855 {
856  while (*pPos == '+' || *pPos == '-' || isdigit((unsigned char)*pPos))
857  pPos++;
858 }
const char * pPos
Definition: StdCompiler.h:702
void StdCompilerINIRead::SkipWhitespace ( )
protected

Definition at line 848 of file StdCompiler.cpp.

References pPos.

Referenced by GetStringLength(), ReadNum(), ReadString(), ReadUNum(), and Separator().

849 {
850  while (*pPos == ' ' || *pPos == '\t')
851  pPos++;
852 }
const char * pPos
Definition: StdCompiler.h:702

Here is the caller graph for this function:

void StdCompilerINIRead::String ( char *  szString,
size_t  iMaxLength,
RawCompileType  eType = RCT_Escaped 
)
overridevirtual

Implements StdCompiler.

Definition at line 661 of file StdCompiler.cpp.

References Buf, ReadString(), and SCopy().

662 {
663  // Read data
664  StdBuf Buf = ReadString(iMaxLength, eType, true);
665  // Copy
666  SCopy(getBufPtr<char>(Buf), szString, iMaxLength);
667 }
Definition: StdBuf.h:29
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
StdBuf ReadString(size_t iLength, RawCompileType eTyped, bool fAppendNull=true)

Here is the call graph for this function:

void StdCompilerINIRead::String ( char **  pszString,
RawCompileType  eType = RCT_Escaped 
)
overridevirtual

Implements StdCompiler.

Definition at line 668 of file StdCompiler.cpp.

References Buf, GetStringLength(), StdBuf::GrabPointer(), and ReadString().

669 {
670  // Get length
671  size_t iLength = GetStringLength(eType);
672  // Read data
673  StdBuf Buf = ReadString(iLength, eType, true);
674  // Set
675  *pszString = reinterpret_cast<char *>(Buf.GrabPointer());
676 }
Definition: StdBuf.h:29
StdBuf ReadString(size_t iLength, RawCompileType eTyped, bool fAppendNull=true)
void * GrabPointer()
Definition: StdBuf.h:133
size_t GetStringLength(RawCompileType eTyped)

Here is the call graph for this function:

void StdCompilerINIRead::String ( std::string &  str,
RawCompileType  eType = RCT_Escaped 
)
overridevirtual

Implements StdCompiler.

Definition at line 677 of file StdCompiler.cpp.

References Buf, GetStringLength(), and ReadString().

678 {
679  // Get length
680  size_t iLength = GetStringLength(type);
681  // Read data
682  StdBuf Buf = ReadString(iLength, type, true);
683  str = getBufPtr<char>(Buf);
684 }
Definition: StdBuf.h:29
StdBuf ReadString(size_t iLength, RawCompileType eTyped, bool fAppendNull=true)
size_t GetStringLength(RawCompileType eTyped)

Here is the call graph for this function:

bool StdCompilerINIRead::TestStringEnd ( RawCompileType  eType)
inlineprotected

Definition at line 723 of file StdCompiler.h.

References StdCompiler::IsStringEnd().

Referenced by GetStringLength(), and ReadString().

723 { return IsStringEnd(*pPos, eType); }
const char * pPos
Definition: StdCompiler.h:702
static bool IsStringEnd(char c, RawCompileType eType)
Definition: StdCompiler.cpp:53

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T >
void StdCompiler::Value ( const T &  rStruct)
inlineinherited

Definition at line 161 of file StdCompiler.h.

Referenced by C4FolderHead::CompileFunc(), C4MeshDenumerator::CompileFunc(), C4UpdatePackageCore::CompileFunc(), C4NetpuncherID::CompileFunc(), C4GameVersion::CompileFunc(), C4SVal::CompileFunc(), C4Folder::CompileFunc(), C4ScenarioParameterDef::Option::CompileFunc(), C4ObjectPtr::CompileFunc(), C4NameList::CompileFunc(), C4Sky::CompileFunc(), StdDefaultAdapt< T, D >::CompileFunc(), C4GameLobby::C4PacketCountdown::CompileFunc(), C4Weather::CompileFunc(), C4NetFilenameAdapt::CompileFunc(), C4LSector::CompileFunc(), C4Property::CompileFunc(), C4ObjectInfoCore::CompileFunc(), C4ControlPacket::CompileFunc(), C4StrValAdapt< T >::CompileFunc(), C4Network2Address::CompileFunc(), C4GameRes::CompileFunc(), C4GameLobby::C4PacketSetScenarioParameter::CompileFunc(), C4RoundResultsPlayer::CompileFunc(), C4MaterialReaction::CompileFunc(), C4PlayerControlDef::CompileFunc(), C4LeagueRequestHead::CompileFunc(), C4ValueProviderLinear::CompileFunc(), C4ConfigGeneral::CompileFunc(), C4ScenarioParameterDef::CompileFunc(), C4ValueArray::CompileFunc(), C4ValueMapData::CompileFunc(), C4Rect::CompileFunc(), StdNamingAdapt< T >::CompileFunc(), ValidatedStdCopyStrBufBase::CompileFunc(), C4RoundResult::CompileFunc(), C4Shape::CompileFunc(), C4ParticleDefCore::CompileFunc(), C4Team::CompileFunc(), C4LeagueReportDisconnectHead::CompileFunc(), C4ClientCore::CompileFunc(), C4SHead::CompileFunc(), C4ValueProviderX::CompileFunc(), C4ScenarioParameterDefs::CompileFunc(), C4Scoreboard::CompileFunc(), C4TargetRect::CompileFunc(), C4ConfigDeveloper::CompileFunc(), C4GameResList::CompileFunc(), C4Action::CompileFunc(), C4Network2Reference::CompileFunc(), C4Control::CompileFunc(), C4Network2Status::CompileFunc(), C4SDefinitions::CompileFunc(), C4LeagueRequestHeadEnd::CompileFunc(), C4Command::CompileFunc(), StdNamingDefaultAdapt< T, D >::CompileFunc(), C4ValueProviderY::CompileFunc(), C4Network2ResCore::CompileFunc(), C4DrawTransform::CompileFunc(), C4RoundResultsPlayers::CompileFunc(), C4ScenarioParameters::CompileFunc(), C4MusicSystem::CompileFunc(), C4PlayerInfoCore::CompileFunc(), C4PlayerControlDefs::CompileFunc(), C4RecordChunk::CompileFunc(), C4ConfigGraphics::CompileFunc(), C4ValueProviderR::CompileFunc(), C4LeagueResponseHead::CompileFunc(), C4ObjectList::CompileFunc(), C4SGame::CompileFunc(), C4ConfigSound::CompileFunc(), C4Client::CompileFunc(), C4FoWBeam::CompileFunc(), C4Effect::CompileFunc(), C4FoWLightSection::CompileFunc(), C4ValueProviderAbsX::CompileFunc(), StdDecompileAdapt< T >::CompileFunc(), C4PropList::CompileFunc(), C4MaterialCore::CompileFunc(), C4LeagueResponseHeadStart::CompileFunc(), EditorWindowState::CompileFunc(), C4PlayerInfo::CompileFunc(), C4Def::CompileFunc(), C4ValueProviderAbsY::CompileFunc(), C4SPlrStart::CompileFunc(), C4GameParameters::CompileFunc(), C4DefGraphicsAdapt::CompileFunc(), C4LeagueResponseHeadUpdate::CompileFunc(), C4RoundResults::CompileFunc(), StdRuntimeValueAdapt< T >::CompileFunc(), C4ConfigNetwork::CompileFunc(), C4ValueProviderDist::CompileFunc(), C4MessageBoardQuery::CompileFunc(), C4Landscape::CompileFunc(), C4Network2ResChunkData::CompileFunc(), C4LeagueResponseHeadAuthCheck::CompileFunc(), C4ClientList::CompileFunc(), C4TeamList::CompileFunc(), C4ValueProviderXDir::CompileFunc(), C4Player::CompileFunc(), C4ConfigStartup::CompileFunc(), C4SLandscape::CompileFunc(), C4Set< T >::CompileFunc(), C4PlayerControlAssignment::CompileFunc(), C4ConfigLobby::CompileFunc(), C4SWeather::CompileFunc(), C4GameControlPacket::CompileFunc(), C4NetIO::EndpointAddress::CompileFunc(), C4ValueProviderYDir::CompileFunc(), C4GraphicsOverlay::CompileFunc(), C4PacketAddr::CompileFunc(), C4ConfigIRC::CompileFunc(), C4Value::CompileFunc(), C4Object::CompileFunc(), C4SAnimals::CompileFunc(), C4ControlPlayerControl::ControlItem::CompileFunc(), StdIntAdapt< T, int_t >::CompileFunc(), C4PropListNumbered::CompileFunc(), C4ConfigGamepad::CompileFunc(), C4ValueProviderRDir::CompileFunc(), C4SEnvironment::CompileFunc(), C4PacketLeagueRoundResults::CompileFunc(), C4KeyCodeEx::CompileFunc(), C4PktBuf::CompileFunc(), C4ConfigControls::CompileFunc(), StdCastAdapt< T, to_t >::CompileFunc(), C4PktDebugRec::CompileFunc(), C4ValueProviderAbsRDir::CompileFunc(), C4ConfigSecurity::CompileFunc(), C4Scenario::CompileFunc(), C4PlayerControlAssignmentSet::CompileFunc(), C4KeyEventData::CompileFunc(), C4PacketControlReq::CompileFunc(), StdSubMeshInstance::CompileFunc(), C4ValueProviderCosR::CompileFunc(), DisconnectData::CompileFunc(), C4GraphicsOverlayListAdapt::CompileFunc(), C4IDPacket::CompileFunc(), C4ValueNumbers::CompileFunc(), C4ClientPlayerInfos::CompileFunc(), C4PacketControlPkt::CompileFunc(), C4Game::CompileFunc(), StdArrayAdapt< T, M >::CompileFunc(), C4ValueProviderSinR::CompileFunc(), C4Config::CompileFunc(), C4PacketExecSyncCtrl::CompileFunc(), C4PacketPlayerInfoUpdRequest::CompileFunc(), C4PlayerControlAssignmentSets::CompileFunc(), C4ValueProviderCosV::CompileFunc(), C4PacketList::CompileFunc(), C4PacketPlayerInfo::CompileFunc(), C4ValueProviderSinV::CompileFunc(), C4PlayerControlFile::CompileFunc(), C4Network2ResChunk::CompileFunc(), StdArrayDefaultAdapt< T, D, M >::CompileFunc(), C4ValueProviderAction::CompileFunc(), StdBuf::CompileFunc(), CompileFunc(), C4PacketPing::CompileFunc(), StdMeshInstanceAnimationNode::CompileFunc(), C4PlayerControl::CSync::ControlDownState::CompileFunc(), C4MapFolderData::CompileFunc(), C4PacketConn::CompileFunc(), StdArrayDefaultArrayAdapt< T, D, M >::CompileFunc(), C4PlayerControl::CSync::CompileFunc(), C4PacketConnRe::CompileFunc(), C4PacketFwd::CompileFunc(), C4PacketResStatus::CompileFunc(), C4PlayerInfoList::CompileFunc(), C4PlayerControl::CompileFunc(), StdInsertAdapt< T, I >::CompileFunc(), C4PacketResDiscover::CompileFunc(), C4PacketPostMortem::CompileFunc(), C4PacketResRequest::CompileFunc(), C4PacketJoinData::CompileFunc(), C4PacketActivateReq::CompileFunc(), C4CustomKey::CompileFunc(), StdMeshInstance::SerializableValueProvider::CompileFunc(), C4KeyboardInput::CompileFunc(), StdMeshInstance::AttachedMesh::CompileFunc(), StdMeshInstance::CompileFunc(), StdSTLContainerAdapt< C >::CompileFunc(), StdIntPackAdapt< T >::CompileFunc(), StdEnumAdapt< T, int_t >::CompileFunc(), C4ObjectListDumpHelper::CompileFunc(), StdBitfieldAdapt< T >::CompileFunc(), StdNamingCountAdapt< int_t >::CompileFunc(), CompileNewFunc(), CompileNewFuncCtx(), C4ValueNumbers::CompileValue(), StdCompiler::DoCompilation(), C4Network2RefClient::GetReferences(), C4Playback::ReadBinary(), C4PropListStatic::RefCompileFunc(), StdPtrAdaptCompileFunc(), StdPtrAdaptDecompileNewFunc(), and unpack_class< T >::unpack().

161 { rStruct.CompileFunc(this); }
template<class T >
void StdCompiler::Value ( T &  rStruct)
inlineinherited

Definition at line 162 of file StdCompiler.h.

References CompileFunc().

162 { CompileFunc(rStruct, this); }
void CompileFunc(T &rStruct, StdCompiler *pComp)
Definition: StdCompiler.h:301

Here is the call graph for this function:

void StdCompiler::Value ( int32_t &  rInt)
inlineinherited

Definition at line 164 of file StdCompiler.h.

References StdCompiler::DWord().

164 { DWord(rInt); }
virtual void DWord(int32_t &rInt)=0

Here is the call graph for this function:

void StdCompiler::Value ( uint32_t &  rInt)
inlineinherited

Definition at line 165 of file StdCompiler.h.

References StdCompiler::DWord().

165 { DWord(rInt); }
virtual void DWord(int32_t &rInt)=0

Here is the call graph for this function:

void StdCompiler::Value ( int16_t &  rInt)
inlineinherited

Definition at line 166 of file StdCompiler.h.

References StdCompiler::Word().

166 { Word(rInt); }
virtual void Word(int16_t &rShort)=0

Here is the call graph for this function:

void StdCompiler::Value ( uint16_t &  rInt)
inlineinherited

Definition at line 167 of file StdCompiler.h.

References StdCompiler::Word().

167 { Word(rInt); }
virtual void Word(int16_t &rShort)=0

Here is the call graph for this function:

void StdCompiler::Value ( int8_t &  rInt)
inlineinherited

Definition at line 168 of file StdCompiler.h.

References StdCompiler::Byte().

168 { Byte(rInt); }
virtual void Byte(int8_t &rByte)=0

Here is the call graph for this function:

void StdCompiler::Value ( uint8_t &  rInt)
inlineinherited

Definition at line 169 of file StdCompiler.h.

References StdCompiler::Byte().

169 { Byte(rInt); }
virtual void Byte(int8_t &rByte)=0

Here is the call graph for this function:

void StdCompiler::Value ( bool &  rBool)
inlineinherited

Definition at line 170 of file StdCompiler.h.

References StdCompiler::Boolean().

170 { Boolean(rBool); }
virtual void Boolean(bool &rBool)=0

Here is the call graph for this function:

void StdCompiler::Warn ( const char *  szWarning,
  ... 
)
inherited

Definition at line 21 of file StdCompiler.cpp.

References StdStrBuf::FormatV(), StdStrBuf::getData(), and StdCompiler::getPosition().

Referenced by Byte(), StdEnumAdapt< T, int_t >::CompileFunc(), StdBitfieldAdapt< T >::CompileFunc(), CreateNameTree(), NameEnd(), Raw(), ReadEscapedChar(), ReadString(), and Word().

22 {
23  // Got warning callback?
24  if (!pWarnCB) return;
25  // Format message
26  va_list args; va_start(args, szWarning);
27  StdStrBuf Msg; Msg.FormatV(szWarning, args);
28  // do callback
29  (*pWarnCB)(pWarnData, getPosition().getData(), Msg.getData());
30 }
const char * getData() const
Definition: StdBuf.h:442
virtual StdStrBuf getPosition() const
Definition: StdCompiler.h:151
void FormatV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:182

Here is the call graph for this function:

Here is the caller graph for this function:

void StdCompilerINIRead::Word ( int16_t &  rShort)
overridevirtual

Implements StdCompiler.

Definition at line 609 of file StdCompiler.cpp.

References Clamp(), ReadNum(), and StdCompiler::Warn().

610 {
611  const int MIN = -(1 << 15), MAX = (1 << 15) - 1;
612  int iNum = ReadNum();
613  if (iNum < MIN || iNum > MAX)
614  Warn("number out of range (%d to %d): %d ", MIN, MAX, iNum);
615  rShort = Clamp(iNum, MIN, MAX);
616 }
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:44
void Warn(const char *szWarning,...)
Definition: StdCompiler.cpp:21

Here is the call graph for this function:

void StdCompilerINIRead::Word ( uint16_t &  rShort)
overridevirtual

Implements StdCompiler.

Definition at line 617 of file StdCompiler.cpp.

References Clamp(), ReadUNum(), and StdCompiler::Warn().

618 {
619  const unsigned int MIN = 0, MAX = (1 << 16) - 1;
620  unsigned int iNum = ReadUNum();
621  if (iNum > MAX)
622  Warn("number out of range (%u to %u): %u ", MIN, MAX, iNum);
623  rShort = Clamp(iNum, MIN, MAX);
624 }
T Clamp(T bval, T lbound, T rbound)
Definition: Standard.h:44
unsigned long ReadUNum()
void Warn(const char *szWarning,...)
Definition: StdCompiler.cpp:21

Here is the call graph for this function:

Member Data Documentation

StdStrBuf StdCompilerINIRead::Buf
protected

Definition at line 700 of file StdCompiler.h.

Referenced by CreateNameTree(), Raw(), setInput(), and String().

int StdCompilerINIRead::iDepth {0}
protected
int StdCompilerINIRead::iRealDepth {0}
protected
StdCopyStrBuf StdCompilerINIRead::NotFoundName
protected

Definition at line 708 of file StdCompiler.h.

Referenced by getPosition(), and Name().

NameNode * StdCompilerINIRead::pName
protected
NameNode* StdCompilerINIRead::pNameRoot {nullptr}
protected

Definition at line 693 of file StdCompiler.h.

Referenced by Begin(), CreateNameTree(), and FreeNameTree().

const char* StdCompilerINIRead::pReenter
protected

Definition at line 705 of file StdCompiler.h.

Referenced by Begin(), Name(), NameEnd(), NoSeparator(), and Separator().


The documentation for this class was generated from the following files: