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 ()
 
void setInput (const InT &In)
 
virtual bool isDeserializer () override
 
virtual bool hasNaming () override
 
virtual bool Name (const char *szName) override
 
virtual void NameEnd (bool fBreak=false) override
 
virtual bool FollowName (const char *szName) override
 
virtual const char * GetNameByIndex (size_t idx) const override
 
virtual bool Separator (Sep eSep) override
 
virtual void NoSeparator () override
 
virtual int NameCount (const char *szName=nullptr) override
 
virtual void DWord (int32_t &rInt) override
 
virtual void DWord (uint32_t &rInt) override
 
virtual void Word (int16_t &rShort) override
 
virtual void Word (uint16_t &rShort) override
 
virtual void Byte (int8_t &rByte) override
 
virtual void Byte (uint8_t &rByte) override
 
virtual void Boolean (bool &rBool) override
 
virtual void Character (char &rChar) override
 
virtual void String (char *szString, size_t iMaxLength, RawCompileType eType=RCT_Escaped) override
 
virtual void String (char **pszString, RawCompileType eType=RCT_Escaped) override
 
virtual void String (std::string &str, RawCompileType eType=RCT_Escaped) override
 
virtual void Raw (void *pData, size_t iSize, RawCompileType eType=RCT_Escaped) override
 
virtual StdStrBuf getPosition () const override
 
virtual void Begin () override
 
virtual 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
 
NameNodepName
 
int iDepth
 
int iRealDepth
 
StdStrBuf Buf
 
const char * pPos
 
const char * pReenter
 
StdCopyStrBuf NotFoundName
 

Detailed Description

Definition at line 630 of file StdCompiler.h.

Member Typedef Documentation

Definition at line 638 of file StdCompiler.h.

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

Definition at line 291 of file StdCompiler.h.

Member Enumeration Documentation

Enumerator
RCT_Escaped 
RCT_All 
RCT_Idtf 
RCT_IdtfAllowEmpty 
RCT_ID 

Definition at line 145 of file StdCompiler.h.

146  {
147  RCT_Escaped=0,// Any data allowed, no separator needed (default)
148  RCT_All, // Printable characters only, must be last element in naming.
149  RCT_Idtf, // Alphanumerical characters or '_', separator needed.
150  RCT_IdtfAllowEmpty, // Like RCT_Idtf, but empty strings are also allowed
151  RCT_ID // Like RCT_Idtf (only used for special compilers that treat IDs differently)
152  };
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 113 of file StdCompiler.h.

114  {
115  SEP_NONE=0, // No separator ("")
116  SEP_SEP, // Array separation (",")
117  SEP_SEP2, // Array separation 2 (";")
118  SEP_SET, // Map pair separation ("=")
119  SEP_PART, // Value part separation (".")
120  SEP_PART2, // Value part separation 2 (":")
121  SEP_PLUS, // Value separation with a '+' char ("+")
122  SEP_START, // Start some sort of list ('(')
123  SEP_END, // End some sort of list ('(')
124  SEP_START2, // Start some sort of list ('[')
125  SEP_END2, // End some sort of list (']')
126  SEP_VLINE, // Vertical line separator ('|')
127  SEP_DOLLAR // Dollar sign ('$')
128  };

Constructor & Destructor Documentation

StdCompilerINIRead::StdCompilerINIRead ( )

Definition at line 446 of file StdCompiler.cpp.

447  : pNameRoot(nullptr), iDepth(0), iRealDepth(0)
448 {
449 
450 }
NameNode * pNameRoot
Definition: StdCompiler.h:704
StdCompilerINIRead::~StdCompilerINIRead ( )

Definition at line 452 of file StdCompiler.cpp.

References FreeNameTree().

453 {
454  FreeNameTree();
455 }

Here is the call graph for this function:

Member Function Documentation

void StdCompilerINIRead::Begin ( )
overridevirtual

Reimplemented from StdCompiler.

Definition at line 742 of file StdCompiler.cpp.

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

Referenced by C4Network2RefClient::GetReferences().

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

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

Referenced by StdCompiler::DoCompilation().

165 { }

Here is the caller graph for this function:

void StdCompilerINIRead::Boolean ( bool &  rBool)
overridevirtual

Implements StdCompiler.

Definition at line 643 of file StdCompiler.cpp.

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

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

Here is the call graph for this function:

void StdCompilerINIRead::Byte ( int8_t &  rByte)
overridevirtual

Implements StdCompiler.

Definition at line 627 of file StdCompiler.cpp.

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

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

Here is the call graph for this function:

void StdCompilerINIRead::Byte ( uint8_t &  rByte)
overridevirtual

Implements StdCompiler.

Definition at line 635 of file StdCompiler.cpp.

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

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

Here is the call graph for this function:

void StdCompilerINIRead::Character ( char &  rChar)
overridevirtual

Implements StdCompiler.

Definition at line 657 of file StdCompiler.cpp.

References notFound(), and pPos.

658 {
659  if (!pPos || !isalpha((unsigned char)*pPos))
660  { notFound("Character"); return; }
661  rChar = *pPos++;
662 }
const char * pPos
Definition: StdCompiler.h:713
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 183 of file StdCompiler.h.

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

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

184  {
185  assert(isDeserializer());
186  DoCompilation(rStruct);
187  }
void DoCompilation(T &rStruct)
Definition: StdCompiler.h:198
virtual bool isDeserializer()
Definition: StdCompiler.h:63

Here is the call graph for this function:

Here is the caller graph for this function:

void StdCompilerINIRead::CreateNameTree ( )
protected

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

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

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

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

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

189  {
190  assert(!isDeserializer());
191  DoCompilation(const_cast<T &>(rStruct));
192  }
void DoCompilation(T &rStruct)
Definition: StdCompiler.h:198
virtual bool isDeserializer()
Definition: StdCompiler.h:63

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

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

98 { return true; }

Here is the caller graph for this function:

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

Definition at line 198 of file StdCompiler.h.

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

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

199  {
200  // Start compilation, do first pass
201  Begin();
202  Value(rStruct);
203  // Second pass needed?
204  if (isDoublePass())
205  {
206  BeginSecond();
207  Value(rStruct);
208  }
209  // Finish
210  End();
211  }
virtual void End()
Definition: StdCompiler.h:166
virtual bool isDoublePass()
Definition: StdCompiler.h:60
void Value(const T &rStruct)
Definition: StdCompiler.h:171
virtual void Begin()
Definition: StdCompiler.h:164
virtual void BeginSecond()
Definition: StdCompiler.h:165

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

References ReadNum().

604 {
605  rInt = ReadNum();
606 }

Here is the call graph for this function:

void StdCompilerINIRead::DWord ( uint32_t &  rInt)
overridevirtual

Implements StdCompiler.

Definition at line 607 of file StdCompiler.cpp.

References ReadUNum().

608 {
609  rInt = ReadUNum();
610 }
unsigned long ReadUNum()

Here is the call graph for this function:

void StdCompilerINIRead::End ( )
overridevirtual

Reimplemented from StdCompiler.

Definition at line 752 of file StdCompiler.cpp.

References FreeNameTree(), iDepth, and iRealDepth.

Referenced by C4Network2RefClient::GetReferences().

753 {
754  assert(!iDepth && !iRealDepth);
755  FreeNameTree();
756 }

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 259 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().

260  {
261  // Throw the appropriate exception
262  va_list args; va_start(args, szMessage);
263  throw new CorruptException(getPosition(), FormatStringV(szMessage, args));
264  }
virtual StdStrBuf getPosition() const
Definition: StdCompiler.h:161
StdStrBuf FormatStringV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:283

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

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

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

254  {
255  // Throw the appropriate exception
256  va_list args; va_start(args, szMessage);
257  throw new EOFException(getPosition(), FormatStringV(szMessage, args));
258  }
virtual StdStrBuf getPosition() const
Definition: StdCompiler.h:161
StdStrBuf FormatStringV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:283

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 243 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().

244  {
245 #ifdef STDCOMPILER_EXCEPTION_WORKAROUND
246  // Exception workaround: Just set a flag in failesafe mode.
247  if (fFailSafe) { fFail = true; return; }
248 #endif
249  // Throw the appropriate exception
250  va_list args; va_start(args, szMessage);
251  throw new NotFoundException(getPosition(), FormatStringV(szMessage, args));
252  }
virtual StdStrBuf getPosition() const
Definition: StdCompiler.h:161
StdStrBuf FormatStringV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:283

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

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

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

Here is the call graph for this function:

void StdCompilerINIRead::FreeNameNode ( NameNode pNode)
protected

Definition at line 827 of file StdCompiler.cpp.

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

Referenced by FreeNameTree().

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

Here is the caller graph for this function:

void StdCompilerINIRead::FreeNameTree ( )
protected

Definition at line 820 of file StdCompiler.cpp.

References FreeNameNode(), pName, and pNameRoot.

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

821 {
822  // free all nodes
824  pName = pNameRoot = nullptr;
825 }
NameNode * pNameRoot
Definition: StdCompiler.h:704
void FreeNameNode(NameNode *pNode)
NameNode * pName
Definition: StdCompiler.h:704

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

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

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

Here is the call graph for this function:

StdStrBuf StdCompilerINIRead::getPosition ( ) const
overridevirtual

Reimplemented from StdCompiler.

Definition at line 730 of file StdCompiler.cpp.

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

731 {
732  if (pPos)
733  return FormatString("line %d", getLineNumberOfPos(pPos));
734  else if (iDepth == iRealDepth)
735  return FormatString(pName->Section ? "section \"%s\", after line %d" : "value \"%s\", line %d", pName->Name.getData(), getLineNumberOfPos(pName->Pos));
736  else if (iRealDepth)
737  return FormatString("missing value/section \"%s\" inside section \"%s\" (line %d)", NotFoundName.getData(), pName->Name.getData(), getLineNumberOfPos(pName->Pos));
738  else
739  return FormatString("missing value/section \"%s\"", NotFoundName.getData());
740 }
const char * getData() const
Definition: StdBuf.h:450
const char * pPos
Definition: StdCompiler.h:713
StdCopyStrBuf NotFoundName
Definition: StdCompiler.h:719
NameNode * pName
Definition: StdCompiler.h:704
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

Here is the call graph for this function:

size_t StdCompilerINIRead::GetStringLength ( RawCompileType  eTyped)
protected

Definition at line 896 of file StdCompiler.cpp.

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

Referenced by String().

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

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool StdCompilerINIRead::hasNaming ( )
inlineoverridevirtual

Reimplemented from StdCompiler.

Definition at line 643 of file StdCompiler.h.

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

Reimplemented from StdCompiler.

Definition at line 642 of file StdCompiler.h.

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

Reimplemented in StdCompilerBinWrite.

Definition at line 60 of file StdCompiler.h.

Referenced by StdCompiler::DoCompilation().

60 { return false; }

Here is the caller graph for this function:

virtual bool StdCompiler::isRegistry ( )
inlinevirtualinherited

Definition at line 75 of file StdCompiler.h.

Referenced by C4PlayerControlAssignmentSets::CompileFunc().

75 { return false; }

Here is the caller graph for this function:

bool StdCompiler::isSerializer ( )
inlineinherited

Definition at line 64 of file StdCompiler.h.

References StdCompiler::isDeserializer().

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

64 { return !isDeserializer(); }
virtual bool isDeserializer()
Definition: StdCompiler.h:63

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

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

Referenced by TestStringEnd().

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

Here is the caller graph for this function:

virtual bool StdCompiler::isVerbose ( )
inlinevirtualinherited

Reimplemented in C4ValueCompiler.

Definition at line 72 of file StdCompiler.h.

References StdCompiler::hasNaming().

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

72 { return hasNaming(); }
virtual bool hasNaming()
Definition: StdCompiler.h:68

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 458 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().

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

Here is the caller graph for this function:

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

Reimplemented from StdCompiler.

Definition at line 573 of file StdCompiler.cpp.

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

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

Reimplemented from StdCompiler.

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

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

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

References pPos, and pReenter.

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

Definition at line 1033 of file StdCompiler.cpp.

References StdCompiler::excNotFound().

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

1034 {
1035  excNotFound("%s expected", szWhat);
1036 }
void excNotFound(const char *szMessage,...)
Definition: StdCompiler.h:243

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

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

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

Here is the call graph for this function:

char StdCompilerINIRead::ReadEscapedChar ( )
protected

Definition at line 976 of file StdCompiler.cpp.

References pPos, and StdCompiler::Warn().

Referenced by GetStringLength(), and ReadString().

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

Here is the call graph for this function:

Here is the caller graph for this function:

long StdCompilerINIRead::ReadNum ( )
protected

Definition at line 862 of file StdCompiler.cpp.

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

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

863 {
864  if (!pPos)
865  { notFound("Number"); return 0; }
866  // Skip whitespace
867  SkipWhitespace();
868  // Read number. If this breaks, GŁnther is to blame!
869  const char *pnPos = pPos;
870  long iNum = strtol(pPos, const_cast<char **>(&pnPos), 10);
871  // Could not read?
872  if (!iNum && pnPos == pPos)
873  { notFound("Number"); return 0; }
874  // Get over it
875  pPos = pnPos;
876  return iNum;
877 }
const char * pPos
Definition: StdCompiler.h:713
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 925 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().

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

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long StdCompilerINIRead::ReadUNum ( )
protected

Definition at line 879 of file StdCompiler.cpp.

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

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

880 {
881  if (!pPos)
882  { notFound("Number"); return 0; }
883  // Skip whitespace
884  SkipWhitespace();
885  // Read number. If this breaks, GŁnther is to blame!
886  const char *pnPos = pPos;
887  unsigned long iNum = strtoul(pPos, const_cast<char **>(&pnPos), 10);
888  // Could not read?
889  if (!iNum && pnPos == pPos)
890  { notFound("Number"); return 0; }
891  // Get over it
892  pPos = pnPos;
893  return iNum;
894 }
const char * pPos
Definition: StdCompiler.h:713
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 543 of file StdCompiler.cpp.

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

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

Here is the call graph for this function:

char StdCompiler::SeparatorToChar ( Sep  eSep)
staticprotectedinherited

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

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

Here is the caller graph for this function:

void StdCompilerINIRead::setInput ( const InT In)
inline

Definition at line 639 of file StdCompiler.h.

References Buf, and StdStrBuf::Ref().

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

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

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

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

78 { }

Here is the caller graph for this function:

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

Definition at line 292 of file StdCompiler.h.

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

Definition at line 856 of file StdCompiler.cpp.

References pPos.

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

Definition at line 850 of file StdCompiler.cpp.

References pPos.

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

851 {
852  while (*pPos == ' ' || *pPos == '\t')
853  pPos++;
854 }
const char * pPos
Definition: StdCompiler.h:713

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

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

664 {
665  // Read data
666  StdBuf Buf = ReadString(iMaxLength, eType, true);
667  // Copy
668  SCopy(getBufPtr<char>(Buf), szString, iMaxLength);
669 }
Definition: StdBuf.h:37
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
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 670 of file StdCompiler.cpp.

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

671 {
672  // Get length
673  size_t iLength = GetStringLength(eType);
674  // Read data
675  StdBuf Buf = ReadString(iLength, eType, true);
676  // Set
677  *pszString = reinterpret_cast<char *>(Buf.GrabPointer());
678 }
Definition: StdBuf.h:37
StdBuf ReadString(size_t iLength, RawCompileType eTyped, bool fAppendNull=true)
void * GrabPointer()
Definition: StdBuf.h:141
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 679 of file StdCompiler.cpp.

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

680 {
681  // Get length
682  size_t iLength = GetStringLength(type);
683  // Read data
684  StdBuf Buf = ReadString(iLength, type, true);
685  str = getBufPtr<char>(Buf);
686 }
Definition: StdBuf.h:37
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 734 of file StdCompiler.h.

References StdCompiler::IsStringEnd().

Referenced by GetStringLength(), and ReadString().

734 { return IsStringEnd(*pPos, eType); }
const char * pPos
Definition: StdCompiler.h:713
static bool IsStringEnd(char c, RawCompileType eType)
Definition: StdCompiler.cpp:58

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

Referenced by C4FolderHead::CompileFunc(), C4MeshDenumerator::CompileFunc(), C4NetpuncherID::CompileFunc(), C4UpdatePackageCore::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(), C4GameRes::CompileFunc(), C4GameLobby::C4PacketSetScenarioParameter::CompileFunc(), C4Network2Address::CompileFunc(), C4RoundResultsPlayer::CompileFunc(), C4MaterialReaction::CompileFunc(), C4LeagueRequestHead::CompileFunc(), C4ValueProviderLinear::CompileFunc(), C4ScenarioParameterDef::CompileFunc(), C4ValueArray::CompileFunc(), C4PlayerControlDef::CompileFunc(), C4ValueMapData::CompileFunc(), C4ConfigGeneral::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(), C4GameResList::CompileFunc(), C4ConfigDeveloper::CompileFunc(), C4TargetRect::CompileFunc(), C4Action::CompileFunc(), C4Network2Reference::CompileFunc(), C4Control::CompileFunc(), C4Network2Status::CompileFunc(), C4SDefinitions::CompileFunc(), C4LeagueRequestHeadEnd::CompileFunc(), C4Command::CompileFunc(), StdNamingDefaultAdapt< T, D >::CompileFunc(), C4ValueProviderY::CompileFunc(), C4Network2ResCore::CompileFunc(), C4RoundResultsPlayers::CompileFunc(), C4ScenarioParameters::CompileFunc(), C4DrawTransform::CompileFunc(), C4MusicSystem::CompileFunc(), C4PlayerInfoCore::CompileFunc(), C4RecordChunk::CompileFunc(), C4PlayerControlDefs::CompileFunc(), C4ValueProviderR::CompileFunc(), C4ConfigGraphics::CompileFunc(), C4LeagueResponseHead::CompileFunc(), C4ObjectList::CompileFunc(), C4SGame::CompileFunc(), C4Client::CompileFunc(), C4ConfigSound::CompileFunc(), C4FoWBeam::CompileFunc(), C4Effect::CompileFunc(), C4ValueProviderAbsX::CompileFunc(), C4FoWLightSection::CompileFunc(), StdDecompileAdapt< T >::CompileFunc(), C4PropList::CompileFunc(), C4MaterialCore::CompileFunc(), C4LeagueResponseHeadStart::CompileFunc(), EditorWindowState::CompileFunc(), C4PlayerInfo::CompileFunc(), C4ValueProviderAbsY::CompileFunc(), C4SPlrStart::CompileFunc(), C4Def::CompileFunc(), C4GameParameters::CompileFunc(), C4DefGraphicsAdapt::CompileFunc(), C4LeagueResponseHeadUpdate::CompileFunc(), C4RoundResults::CompileFunc(), StdRuntimeValueAdapt< T >::CompileFunc(), C4ValueProviderDist::CompileFunc(), C4ConfigNetwork::CompileFunc(), C4MessageBoardQuery::CompileFunc(), C4Network2ResChunkData::CompileFunc(), C4Landscape::CompileFunc(), C4LeagueResponseHeadAuthCheck::CompileFunc(), C4ClientList::CompileFunc(), C4ValueProviderXDir::CompileFunc(), C4TeamList::CompileFunc(), C4SLandscape::CompileFunc(), C4Player::CompileFunc(), C4ConfigStartup::CompileFunc(), C4Set< T >::CompileFunc(), C4ConfigLobby::CompileFunc(), C4PlayerControlAssignment::CompileFunc(), C4SWeather::CompileFunc(), C4GameControlPacket::CompileFunc(), C4ValueProviderYDir::CompileFunc(), C4NetIO::EndpointAddress::CompileFunc(), C4GraphicsOverlay::CompileFunc(), C4PacketAddr::CompileFunc(), C4Value::CompileFunc(), C4ConfigIRC::CompileFunc(), C4Object::CompileFunc(), C4SAnimals::CompileFunc(), C4ControlPlayerControl::ControlItem::CompileFunc(), StdIntAdapt< T, int_t >::CompileFunc(), C4PropListNumbered::CompileFunc(), C4ValueProviderRDir::CompileFunc(), C4SEnvironment::CompileFunc(), C4ConfigGamepad::CompileFunc(), C4PacketLeagueRoundResults::CompileFunc(), C4PktBuf::CompileFunc(), C4ConfigControls::CompileFunc(), C4KeyCodeEx::CompileFunc(), C4ValueProviderAbsRDir::CompileFunc(), C4PktDebugRec::CompileFunc(), StdCastAdapt< T, to_t >::CompileFunc(), C4ConfigSecurity::CompileFunc(), C4Scenario::CompileFunc(), C4PacketControlReq::CompileFunc(), C4PlayerControlAssignmentSet::CompileFunc(), C4KeyEventData::CompileFunc(), C4ValueProviderCosR::CompileFunc(), StdSubMeshInstance::CompileFunc(), C4IDPacket::CompileFunc(), DisconnectData::CompileFunc(), C4ValueNumbers::CompileFunc(), C4GraphicsOverlayListAdapt::CompileFunc(), C4PacketControlPkt::CompileFunc(), C4ClientPlayerInfos::CompileFunc(), C4Game::CompileFunc(), StdArrayAdapt< T, M >::CompileFunc(), C4ValueProviderSinR::CompileFunc(), C4PacketExecSyncCtrl::CompileFunc(), C4Config::CompileFunc(), C4PacketPlayerInfoUpdRequest::CompileFunc(), C4ValueProviderCosV::CompileFunc(), C4PacketList::CompileFunc(), C4PlayerControlAssignmentSets::CompileFunc(), C4PacketPlayerInfo::CompileFunc(), C4ValueProviderSinV::CompileFunc(), C4PlayerControlFile::CompileFunc(), C4Network2ResChunk::CompileFunc(), C4ValueProviderAction::CompileFunc(), StdArrayDefaultAdapt< T, D, M >::CompileFunc(), CompileFunc(), StdBuf::CompileFunc(), C4PacketPing::CompileFunc(), StdMeshInstanceAnimationNode::CompileFunc(), C4MapFolderData::CompileFunc(), C4PacketConn::CompileFunc(), C4PlayerControl::CSync::ControlDownState::CompileFunc(), StdArrayDefaultArrayAdapt< T, D, M >::CompileFunc(), C4PacketConnRe::CompileFunc(), C4PlayerControl::CSync::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(), StdMeshInstance::AttachedMesh::CompileFunc(), C4KeyboardInput::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().

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

Definition at line 172 of file StdCompiler.h.

References CompileFunc().

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

Here is the call graph for this function:

void StdCompiler::Value ( int32_t &  rInt)
inlineinherited

Definition at line 174 of file StdCompiler.h.

References StdCompiler::DWord().

174 { 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 175 of file StdCompiler.h.

References StdCompiler::DWord().

175 { 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 176 of file StdCompiler.h.

References StdCompiler::Word().

176 { 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 177 of file StdCompiler.h.

References StdCompiler::Word().

177 { 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 178 of file StdCompiler.h.

References StdCompiler::Byte().

178 { 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 179 of file StdCompiler.h.

References StdCompiler::Byte().

179 { 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 180 of file StdCompiler.h.

References StdCompiler::Boolean().

180 { 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 26 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().

27 {
28  // Got warning callback?
29  if (!pWarnCB) return;
30  // Format message
31  va_list args; va_start(args, szWarning);
32  StdStrBuf Msg; Msg.FormatV(szWarning, args);
33  // do callback
34  (*pWarnCB)(pWarnData, getPosition().getData(), Msg.getData());
35 }
const char * getData() const
Definition: StdBuf.h:450
virtual StdStrBuf getPosition() const
Definition: StdCompiler.h:161
void FormatV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:189

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

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

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

Here is the call graph for this function:

void StdCompilerINIRead::Word ( uint16_t &  rShort)
overridevirtual

Implements StdCompiler.

Definition at line 619 of file StdCompiler.cpp.

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

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

Here is the call graph for this function:

Member Data Documentation

StdStrBuf StdCompilerINIRead::Buf
protected

Definition at line 711 of file StdCompiler.h.

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

int StdCompilerINIRead::iDepth
protected
int StdCompilerINIRead::iRealDepth
protected
StdCopyStrBuf StdCompilerINIRead::NotFoundName
protected

Definition at line 719 of file StdCompiler.h.

Referenced by getPosition(), and Name().

NameNode * StdCompilerINIRead::pName
protected
NameNode* StdCompilerINIRead::pNameRoot
protected

Definition at line 704 of file StdCompiler.h.

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

const char* StdCompilerINIRead::pReenter
protected

Definition at line 716 of file StdCompiler.h.

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


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