90 bool C4Value::FnCnvObject()
const
97 bool C4Value::FnCnvDef()
const
104 bool C4Value::FnCnvEffect()
const
126 default: assert(!
"C4Value::ConvertTo: impossible conversion target");
return false;
139 return StdStrBuf(Data ?
"true" :
"false");
149 if (!ignore_reference_parent || Def->
GetParent() != ignore_reference_parent)
153 DataString = (fx ?
"effect {" :
"{");
162 if (depth <= 0 && Data.Array->GetSize())
170 if (i) DataString.
Append(
", ");
197 return StdStrBuf(Data ?
"true" :
"false");
202 if (!ignore_reference_parent || Def->
GetParent() != ignore_reference_parent)
204 return Data.
PropList->
ToJSON(depth, Def && ignore_reference_parent);
220 if (depth <= 0 && Data.Array->GetSize())
228 if (i) DataString.
Append(
",");
245 if (n <= LoadedValues.size())
246 return LoadedValues[n - 1];
247 LogF(
"ERROR: Value number %d is missing.", n);
273 LogF(
"ERROR: Object number %d is missing.",
int(Data.
Int));
283 for (
auto & LoadedValue : LoadedValues)
284 LoadedValue.Denumerate(
this);
291 if (ValueNumbers.find(v->
GetData()) == ValueNumbers.end())
293 ValuesToSave.push_back(v);
294 ValueNumbers[v->
GetData()] = ValuesToSave.size();
295 return ValuesToSave.size();
297 return ValueNumbers[v->
GetData()];
307 assert(Type !=
C4V_Nil || !Data);
399 pComp->
excCorrupt(
"Cannot find global constant %s",
s.getData());
404 pComp->
excCorrupt(
"static proplist %s is not a proplist anymore",
s.getData());
451 pComp->
excCorrupt(
"unknown C4Value type tag '%c'", cC4VID);
465 default: assert(deserializing);
break;
486 pComp->
excCorrupt(
"Unexpected character '%c'", cC4VID);
504 if (!fNaming && !
iSize--)
509 LoadedValues.emplace_back();
529 int32_t
iSize = ValuesToSave.size();
532 for(std::list<C4Value *>::iterator i = ValuesToSave.begin(); i != ValuesToSave.end(); ++i)
550 return Type1 == Type2;
558 return Type1 == Type2 && Data1.
Str == Data2.
Str;
560 return Type1 == Type2 &&
563 return Type1 == Type2 && Data1.
Fn == Data2.
Fn;
565 assert(!
"Unexpected C4Value type (denumeration missing?)");
566 return Data1 == Data2;
583 return left == other.left &&
right == other.right;
585 inline bool recursion(Seen *new_top)
587 for (Seen *
s =
this;
s;
s =
s->prev)
595 while (
s->prev)
s =
s->prev;
599 static Seen *
top =
nullptr;
600 Seen here(
top,
this, &Value2);
602 bool recursion =
top &&
top->recursion(&here);
605 Seen *first =
top->first();
607 LogF(
"Caught infinite recursion comparing %s and %s",
608 first->left->GetDataString().getData(),
609 first->right->GetDataString().getData());
620 return !(*
this == Value2);
630 if (FnCnvDef())
return C4V_Def;
635 void C4Value::LogDeletedObjectWarning(
C4PropList * p)
640 LogF(
"Warning: using deleted proplist %p (%s)!",
static_cast<void*
>(p), p->
GetName());
C4AulScriptEngine ScriptEngine
bool LogF(const char *strMessage,...)
C4GameScriptHost GameScript
bool ComparisonImpl(const C4Value &Value1, const C4Value &Value2)
const char * GetC4VName(const C4V_Type Type)
C4Value C4VObj(C4Object *pObj)
StdPtrAdapt< T > mkPtrAdaptNoNull(T *&rpObj)
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
StdStrBuf FormatString(const char *szFmt,...)
virtual StdStrBuf GetFullName() const
const char * GetName() const
C4PropListStatic * Parent
bool GetGlobalConstant(const char *szName, C4Value *pTargetValue)
C4PropListStatic * GetPropList()
virtual C4Object * GetObject()
C4AulFunc * GetFunc(C4PropertyName k) const
virtual const char * GetName() const
virtual class C4PropListStatic * IsStatic()
virtual bool GetPropertyByS(const C4String *k, C4Value *pResult) const
virtual bool IsNumbered() const
virtual C4Effect * GetEffect()
StdStrBuf ToJSON(int depth=10, bool ignore_reference_parent=false) const
void AppendDataString(StdStrBuf *out, const char *delim, int depth=3, bool ignore_reference_parent=false) const
virtual void Denumerate(C4ValueNumbers *)
virtual C4PropListNumbered * GetPropListNumbered()
virtual C4Def const * GetDef() const
static C4PropList * GetByNumber(int32_t iNumber)
void RefCompileFunc(StdCompiler *pComp, C4ValueNumbers *numbers) const
StdStrBuf GetDataString() const
const C4PropListStatic * GetParent() const
StdStrBuf GetData() const
const char * GetCStr() const
C4String * FindString(const char *strString) const
C4String * RegString(StdStrBuf String)
const C4Value & GetItem(int32_t iElem) const
void Denumerate(C4ValueNumbers *)
ALWAYS_INLINE bool CheckConversion(C4V_Type vtToType) const
void SetPropList(C4PropList *PropList)
C4V_Type GetTypeEx() const
C4Object * getObj() const
StdStrBuf ToJSON(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
StdStrBuf GetDataString(int depth=10, const class C4PropListStatic *ignore_reference_parent=nullptr) const
C4PropList * _getPropList() const
static bool WarnAboutConversion(C4V_Type Type, C4V_Type vtToType)
bool operator!=(const C4Value &Value2) const
void SetArray(C4ValueArray *Array)
C4ValueArray * _getArray() const
bool operator==(const C4Value &Value2) const
void Set(const C4Value &nValue)
C4AulFunc * getFunction() const
C4PropList * getPropList() const
void SetString(C4String *Str)
void CompileFunc(StdCompiler *pComp, C4ValueNumbers *)
void Denumerate(C4ValueNumbers *)
C4Object * _getObj() const
void CompileValue(StdCompiler *, C4Value *)
void CompileFunc(StdCompiler *)
const C4Value & GetValue(uint32_t)
uint32_t GetNumberForValue(C4Value *v)
virtual bool Separator(Sep eSep=SEP_SEP)
virtual void Character(char &rChar)=0
void excCorrupt(const char *szMessage,...)
void Value(const T &rStruct)
virtual bool isDeserializer()
int Replace(const char *szOld, const char *szNew, size_t iStartSearch=0)
const char * getData() const
void AppendChar(char cChar)
void Append(const char *pnData, size_t iChars)