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 620 of file StdCompiler.h.

Member Typedef Documentation

Definition at line 628 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 443 of file StdCompiler.cpp.

References FreeNameTree().

444 {
445  FreeNameTree();
446 }

Here is the call graph for this function:

Member Function Documentation

void StdCompilerINIRead::Begin ( )
overridevirtual

Reimplemented from StdCompiler.

Definition at line 733 of file StdCompiler.cpp.

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

Referenced by C4Network2RefClient::GetReferences().

734 {
735  // Already running? This may happen if someone confuses Compile with Value.
736  assert(!iDepth && !iRealDepth && !pNameRoot);
737  // Create tree
738  CreateNameTree();
739  // Start must be inside a section
740  iDepth = iRealDepth = 0;
741  pPos = nullptr; pReenter = nullptr;
742 }
const char * pPos
Definition: StdCompiler.h:701
NameNode * pNameRoot
Definition: StdCompiler.h:692
const char * pReenter
Definition: StdCompiler.h:704

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 634 of file StdCompiler.cpp.

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

635 {
636  if (!pPos) { notFound("Boolean"); return; }
637  if (*pPos == '1' && !isdigit((unsigned char)*(pPos+1)))
638  { rBool = true; pPos ++; }
639  else if (*pPos == '0' && !isdigit((unsigned char)*(pPos+1)))
640  { rBool = false; pPos ++; }
641  else if (SEqual2(pPos, "true"))
642  { rBool = true; pPos += 4; }
643  else if (SEqual2(pPos, "false"))
644  { rBool = false; pPos += 5; }
645  else
646  { notFound("Boolean"); return; }
647 }
const char * pPos
Definition: StdCompiler.h:701
void notFound(const char *szWhat)
bool SEqual2(const char *szStr1, const char *szStr2)
Definition: Standard.cpp:176

Here is the call graph for this function:

void StdCompilerINIRead::Byte ( int8_t &  rByte)
overridevirtual

Implements StdCompiler.

Definition at line 618 of file StdCompiler.cpp.

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

619 {
620  const int MIN = -(1 << 7), MAX = (1 << 7) - 1;
621  int iNum = ReadNum();
622  if (iNum < MIN || iNum > MAX)
623  Warn("number out of range (%d to %d): %d ", MIN, MAX, iNum);
624  rByte = Clamp(iNum, MIN, MAX);
625 }
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 626 of file StdCompiler.cpp.

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

627 {
628  const unsigned int MIN = 0, MAX = (1 << 8) - 1;
629  unsigned int iNum = ReadUNum();
630  if (iNum > MAX)
631  Warn("number out of range (%u to %u): %u ", MIN, MAX, iNum);
632  rByte = Clamp(iNum, MIN, MAX);
633 }
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 648 of file StdCompiler.cpp.

References notFound(), and pPos.

649 {
650  if (!pPos || !isalpha((unsigned char)*pPos))
651  { notFound("Character"); return; }
652  rChar = *pPos++;
653 }
const char * pPos
Definition: StdCompiler.h:701
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 749 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().

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

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 594 of file StdCompiler.cpp.

References ReadNum().

595 {
596  rInt = ReadNum();
597 }

Here is the call graph for this function:

void StdCompilerINIRead::DWord ( uint32_t &  rInt)
overridevirtual

Implements StdCompiler.

Definition at line 598 of file StdCompiler.cpp.

References ReadUNum().

599 {
600  rInt = ReadUNum();
601 }
unsigned long ReadUNum()

Here is the call graph for this function:

void StdCompilerINIRead::End ( )
overridevirtual

Reimplemented from StdCompiler.

Definition at line 743 of file StdCompiler.cpp.

References FreeNameTree(), iDepth, and iRealDepth.

Referenced by C4Network2RefClient::GetReferences().

744 {
745  assert(!iDepth && !iRealDepth);
746  FreeNameTree();
747 }

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 511 of file StdCompiler.cpp.

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

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

Here is the call graph for this function:

void StdCompilerINIRead::FreeNameNode ( NameNode pNode)
protected

Definition at line 818 of file StdCompiler.cpp.

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

Referenced by FreeNameTree().

819 {
820  NameNode *pNode = pDelNode;
821  while (pNode)
822  {
823  if (pNode->FirstChild)
824  pNode = pNode->FirstChild;
825  else
826  {
827  NameNode *pDelete = pNode;
828  if (pDelete == pDelNode) { delete pDelete; break; }
829  if (pNode->NextChild)
830  pNode = pNode->NextChild;
831  else
832  {
833  pNode = pNode->Parent;
834  if (pNode) pNode->FirstChild = nullptr;
835  }
836  delete pDelete;
837  }
838  }
839 }

Here is the caller graph for this function:

void StdCompilerINIRead::FreeNameTree ( )
protected

Definition at line 811 of file StdCompiler.cpp.

References FreeNameNode(), pName, and pNameRoot.

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

812 {
813  // free all nodes
815  pName = pNameRoot = nullptr;
816 }
NameNode * pNameRoot
Definition: StdCompiler.h:692
void FreeNameNode(NameNode *pNode)
NameNode * pName
Definition: StdCompiler.h:692

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 578 of file StdCompiler.cpp.

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

579 {
580  // not in virtual naming
581  if (iDepth > iRealDepth || !pName) return nullptr;
582  // count within current name
583  NameNode *pNode;
584  for (pNode = pName->FirstChild; pNode; pNode = pNode->NextChild)
585  // all valid subsections are counted
586  if (pNode->Pos)
587  if (!idx--)
588  return pNode->Name.getData();
589  // index out of range
590  return nullptr;
591 }
NameNode * pName
Definition: StdCompiler.h:692

Here is the call graph for this function:

StdStrBuf StdCompilerINIRead::getPosition ( ) const
overridevirtual

Reimplemented from StdCompiler.

Definition at line 721 of file StdCompiler.cpp.

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

722 {
723  if (pPos)
724  return FormatString("line %d", getLineNumberOfPos(pPos));
725  else if (iDepth == iRealDepth)
726  return FormatString(pName->Section ? R"(section "%s", after line %d)" : R"(value "%s", line %d)", pName->Name.getData(), getLineNumberOfPos(pName->Pos));
727  else if (iRealDepth)
728  return FormatString(R"(missing value/section "%s" inside section "%s" (line %d))", NotFoundName.getData(), pName->Name.getData(), getLineNumberOfPos(pName->Pos));
729  else
730  return FormatString(R"(missing value/section "%s")", NotFoundName.getData());
731 }
const char * getData() const
Definition: StdBuf.h:442
const char * pPos
Definition: StdCompiler.h:701
StdCopyStrBuf NotFoundName
Definition: StdCompiler.h:707
NameNode * pName
Definition: StdCompiler.h:692
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 887 of file StdCompiler.cpp.

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

Referenced by String().

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

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 633 of file StdCompiler.h.

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

Reimplemented from StdCompiler.

Definition at line 632 of file StdCompiler.h.

632 { 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 449 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().

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

Here is the caller graph for this function:

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

Reimplemented from StdCompiler.

Definition at line 564 of file StdCompiler.cpp.

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

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

Reimplemented from StdCompiler.

Definition at line 481 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().

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

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 558 of file StdCompiler.cpp.

References pPos, and pReenter.

559 {
560  // Position saved back from separator mismatch?
561  if (pReenter) { pPos = pReenter; pReenter = nullptr; }
562 }
const char * pPos
Definition: StdCompiler.h:701
const char * pReenter
Definition: StdCompiler.h:704
void StdCompilerINIRead::notFound ( const char *  szWhat)
protected

Definition at line 1024 of file StdCompiler.cpp.

References StdCompiler::excNotFound().

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

1025 {
1026  excNotFound("%s expected", szWhat);
1027 }
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 678 of file StdCompiler.cpp.

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

679 {
680  // Read data
681  StdBuf Buf = ReadString(iSize, eType, false);
682  // Correct size?
683  if (Buf.getSize() != iSize)
684  Warn("got %u bytes raw data, but %u bytes expected!", Buf.getSize(), iSize);
685  // Copy
686  MemCopy(Buf.getData(), pData, iSize);
687 }
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 967 of file StdCompiler.cpp.

References pPos, and StdCompiler::Warn().

Referenced by GetStringLength(), and ReadString().

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

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

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

854 {
855  if (!pPos)
856  { notFound("Number"); return 0; }
857  // Skip whitespace
858  SkipWhitespace();
859  // Read number. If this breaks, Günther is to blame!
860  const char *pnPos = pPos;
861  long iNum = strtol(pPos, const_cast<char **>(&pnPos), 10);
862  // Could not read?
863  if (!iNum && pnPos == pPos)
864  { notFound("Number"); return 0; }
865  // Get over it
866  pPos = pnPos;
867  return iNum;
868 }
const char * pPos
Definition: StdCompiler.h:701
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 916 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().

917 {
918  // Excpect valid position
919  if (!pPos)
920  { notFound("String"); return StdBuf(); }
921  // Skip whitespace
922  SkipWhitespace();
923  // Escaped? Go over '"'
924  if (eRawType == RCT_Escaped && *pPos++ != '"')
925  { notFound("Escaped string"); return StdBuf(); }
926  // Create buffer
927  StdBuf OutBuf; OutBuf.New(iLength + (fAppendNull ? sizeof('\0') : 0));
928  // Read
929  char *pOut = getMBufPtr<char>(OutBuf);
930  while (iLength && !TestStringEnd(eRawType))
931  {
932  // Read a character
933  if (eRawType == RCT_Escaped)
934  *pOut++ = ReadEscapedChar();
935  else
936  *pOut++ = *pPos++;
937  // Count it
938  iLength--;
939  }
940  // Escaped: Go over '"'
941  if (eRawType == RCT_Escaped)
942  {
943  while (*pPos != '"')
944  {
945  if (!*pPos || *pPos == '\n' || *pPos == '\r')
946  {
947  Warn("string not terminated!");
948  pPos--;
949  break;
950  }
951  pPos++;
952  }
953  pPos++;
954  }
955  // Nothing read? Identifiers need to be non-empty
956  if (pOut == OutBuf.getData() && (eRawType == RCT_Idtf || eRawType == RCT_ID))
957  { notFound("String"); return StdBuf(); }
958  // Append null
959  if (fAppendNull)
960  *pOut = '\0';
961  // Shrink, if less characters were read
962  OutBuf.Shrink(iLength);
963  // Done
964  return OutBuf;
965 }
const void * getData() const
Definition: StdBuf.h:99
Definition: StdBuf.h:29
const char * pPos
Definition: StdCompiler.h:701
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:722

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long StdCompilerINIRead::ReadUNum ( )
protected

Definition at line 870 of file StdCompiler.cpp.

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

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

871 {
872  if (!pPos)
873  { notFound("Number"); return 0; }
874  // Skip whitespace
875  SkipWhitespace();
876  // Read number. If this breaks, Günther is to blame!
877  const char *pnPos = pPos;
878  unsigned long iNum = strtoul(pPos, const_cast<char **>(&pnPos), 10);
879  // Could not read?
880  if (!iNum && pnPos == pPos)
881  { notFound("Number"); return 0; }
882  // Get over it
883  pPos = pnPos;
884  return iNum;
885 }
const char * pPos
Definition: StdCompiler.h:701
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 534 of file StdCompiler.cpp.

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

535 {
536  if (iDepth > iRealDepth) return false;
537  // In section?
538  if (pName->Section)
539  {
540  // Store current name, search another section with the same name
541  StdStrBuf CurrName = pName->Name;
542  NameEnd();
543  return Name(CurrName.getData());
544  }
545  // Position saved back from separator mismatch?
546  if (pReenter) { pPos = pReenter; pReenter = nullptr; }
547  // Nothing to read?
548  if (!pPos) return false;
549  // Read (while skipping over whitespace)
550  SkipWhitespace();
551  // Separator mismatch? Let all read attempts fail until the correct separator is found or the naming ends.
552  if (*pPos != SeparatorToChar(eSep)) { pReenter = pPos; pPos = nullptr; return false; }
553  // Go over separator, success
554  pPos++;
555  return true;
556 }
const char * getData() const
Definition: StdBuf.h:442
const char * pPos
Definition: StdCompiler.h:701
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:692
const char * pReenter
Definition: StdCompiler.h:704

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 629 of file StdCompiler.h.

References Buf, and StdStrBuf::Ref().

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

629 { 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 847 of file StdCompiler.cpp.

References pPos.

848 {
849  while (*pPos == '+' || *pPos == '-' || isdigit((unsigned char)*pPos))
850  pPos++;
851 }
const char * pPos
Definition: StdCompiler.h:701
void StdCompilerINIRead::SkipWhitespace ( )
protected

Definition at line 841 of file StdCompiler.cpp.

References pPos.

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

842 {
843  while (*pPos == ' ' || *pPos == '\t')
844  pPos++;
845 }
const char * pPos
Definition: StdCompiler.h:701

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 654 of file StdCompiler.cpp.

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

655 {
656  // Read data
657  StdBuf Buf = ReadString(iMaxLength, eType, true);
658  // Copy
659  SCopy(getBufPtr<char>(Buf), szString, iMaxLength);
660 }
Definition: StdBuf.h:29
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:130
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 661 of file StdCompiler.cpp.

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

662 {
663  // Get length
664  size_t iLength = GetStringLength(eType);
665  // Read data
666  StdBuf Buf = ReadString(iLength, eType, true);
667  // Set
668  *pszString = reinterpret_cast<char *>(Buf.GrabPointer());
669 }
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 670 of file StdCompiler.cpp.

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

671 {
672  // Get length
673  size_t iLength = GetStringLength(type);
674  // Read data
675  StdBuf Buf = ReadString(iLength, type, true);
676  str = getBufPtr<char>(Buf);
677 }
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 722 of file StdCompiler.h.

References StdCompiler::IsStringEnd().

Referenced by GetStringLength(), and ReadString().

722 { return IsStringEnd(*pPos, eType); }
const char * pPos
Definition: StdCompiler.h:701
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(), C4ParticleDefCore::CompileFunc(), C4Shape::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(), C4ValueProviderAbsY::CompileFunc(), C4Def::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(), C4MapFolderData::CompileFunc(), C4PlayerControl::CSync::ControlDownState::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 602 of file StdCompiler.cpp.

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

603 {
604  const int MIN = -(1 << 15), MAX = (1 << 15) - 1;
605  int iNum = ReadNum();
606  if (iNum < MIN || iNum > MAX)
607  Warn("number out of range (%d to %d): %d ", MIN, MAX, iNum);
608  rShort = Clamp(iNum, MIN, MAX);
609 }
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 610 of file StdCompiler.cpp.

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

611 {
612  const unsigned int MIN = 0, MAX = (1 << 16) - 1;
613  unsigned int iNum = ReadUNum();
614  if (iNum > MAX)
615  Warn("number out of range (%u to %u): %u ", MIN, MAX, iNum);
616  rShort = Clamp(iNum, MIN, MAX);
617 }
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 699 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 707 of file StdCompiler.h.

Referenced by getPosition(), and Name().

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

Definition at line 692 of file StdCompiler.h.

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

const char* StdCompilerINIRead::pReenter
protected

Definition at line 704 of file StdCompiler.h.

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


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