LGS::TSupportedParamType getParamType(); // template LGS::TSupportedParamType getParamType() { return LGS::TSupportedParamType::spt_uint32;} // template LGS::TSupportedParamType getParamType() { return LGS::TSupportedParamType::spt_uint64;} // template LGS::TSupportedParamType getParamType() { return LGS::TSupportedParamType::spt_sint32;} // template LGS::TSupportedParamType getParamType() { return LGS::TSupportedParamType::spt_float;} // template LGS::TSupportedParamType getParamType() { return LGS::TSupportedParamType::spt_string;} // template LGS::TSupportedParamType getParamType() { return LGS::TSupportedParamType::spt_entityId;} // template LGS::TSupportedParamType getParamType() { return LGS::TSupportedParamType::spt_sheetId;} // template LGS::TSupportedParamType getParamType() { return LGS::TSupportedParamType::spt_itemId;} struct TParamValue { TParamValue() : _Type(TSupportedParamType::invalid_val) {} TParamValue(uint32 value) { _Type = TSupportedParamType::spt_uint32; _UInt32Val = value; } TParamValue(uint64 value) { _Type = TSupportedParamType::spt_uint64; _UInt64Val = value; } TParamValue(bool value) { _Type = TSupportedParamType::spt_uint32; _UInt32Val = value ? 1 : 0; } TParamValue(sint32 value) { _Type = TSupportedParamType::spt_sint32; _SInt32Val = value; } TParamValue(float value) { _Type = TSupportedParamType::spt_float; _FloatVal = value; } TParamValue(const std::string &value) { _Type = TSupportedParamType::spt_string; _StringVal = value; } TParamValue(const NLMISC::CEntityId &value) { _Type = TSupportedParamType::spt_entityId; _EntityId = value; } TParamValue(const NLMISC::CSheetId &value) { _Type = TSupportedParamType::spt_sheetId; _SheetId = value; } TParamValue(INVENTORIES::TItemId itemId) { _Type = TSupportedParamType::spt_itemId; _ItemId = itemId; } TParamValue &operator = (const TParamValue &other) { _Type = other._Type; switch (_Type.getValue()) { case TSupportedParamType::spt_uint32: _UInt32Val = other._UInt32Val; break; case TSupportedParamType::spt_uint64: _UInt64Val = other._UInt64Val; break; case TSupportedParamType::spt_sint32: _SInt32Val = other._SInt32Val; break; case TSupportedParamType::spt_float: _FloatVal = other._FloatVal; break; case TSupportedParamType::spt_string: _StringVal = other._StringVal; break; case TSupportedParamType::spt_entityId: _EntityId = other._EntityId; break; case TSupportedParamType::spt_sheetId: _SheetId = other._SheetId; break; case TSupportedParamType::spt_itemId: _ItemId = other._ItemId; break; default: nlstop; }; return *this; } void serial(NLMISC::IStream &s) { // read the type s.serial(_Type); // serial the value switch (_Type.getValue()) { case TSupportedParamType::spt_uint32: s.serial(_UInt32Val); break; case TSupportedParamType::spt_uint64: s.serial(_UInt64Val); break; case TSupportedParamType::spt_sint32: s.serial(_SInt32Val); break; case TSupportedParamType::spt_float: s.serial(_FloatVal); break; case TSupportedParamType::spt_string: s.serial(_StringVal); break; case TSupportedParamType::spt_entityId: s.serial(_EntityId); break; case TSupportedParamType::spt_sheetId: s.serial(_SheetId); break; case TSupportedParamType::spt_itemId: s.serial(_ItemId); break; default: nlstop; }; } std::string toString() const { switch (_Type.getValue()) { case TSupportedParamType::spt_uint32: return NLMISC::toString(_UInt32Val); break; case TSupportedParamType::spt_uint64: return NLMISC::toString(_UInt64Val); break; case TSupportedParamType::spt_sint32: return NLMISC::toString(_SInt32Val); break; case TSupportedParamType::spt_float: return NLMISC::toString(_FloatVal); break; case TSupportedParamType::spt_string: return _StringVal; break; case TSupportedParamType::spt_entityId: return _EntityId.toString(); break; case TSupportedParamType::spt_sheetId: return _SheetId.toString(); break; case TSupportedParamType::spt_itemId: return NLMISC::toString(_ItemId); break; default: nlstop; return ""; }; } TSupportedParamType getType() const { return _Type; } uint32 get_uint32() const { nlassert(_Type == TSupportedParamType::spt_uint32); return _UInt32Val; } uint64 get_uint64() const { nlassert(_Type == TSupportedParamType::spt_uint64); return _UInt64Val; } sint32 get_sint32() const { nlassert(_Type == TSupportedParamType::spt_sint32); return _SInt32Val; } float get_float() const { nlassert(_Type == TSupportedParamType::spt_float); return _FloatVal; } const std::string &get_string() const { nlassert(_Type == TSupportedParamType::spt_string); return _StringVal; } const NLMISC::CEntityId &get_entityId() const { nlassert(_Type == TSupportedParamType::spt_entityId); return _EntityId; } const NLMISC::CSheetId &get_sheetId() const { nlassert(_Type == TSupportedParamType::spt_sheetId); return _SheetId; } const INVENTORIES::TItemId &get_itemId() const { nlassert(_Type == TSupportedParamType::spt_itemId); return _ItemId; } const uint32 &get(const uint32 *typeTag) const { nlassert(_Type == TSupportedParamType::spt_uint32); return _UInt32Val; } const uint64 &get(const uint64 *typeTag) const { nlassert(_Type == TSupportedParamType::spt_uint64); return _UInt64Val; } const sint32 &get(const sint32 *typeTag) const { nlassert(_Type == TSupportedParamType::spt_sint32); return _SInt32Val; } const float &get(const float *typeTag) const { nlassert(_Type == TSupportedParamType::spt_float); return _FloatVal; } const std::string &get(const std::string *typeTag) const { nlassert(_Type == TSupportedParamType::spt_string); return _StringVal; } const NLMISC::CEntityId &get(const NLMISC::CEntityId *typeTag) const { nlassert(_Type == TSupportedParamType::spt_entityId); return _EntityId; } const NLMISC::CSheetId &get(const NLMISC::CSheetId *typeTag) const { nlassert(_Type == TSupportedParamType::spt_sheetId); return _SheetId; } const INVENTORIES::TItemId &get(const INVENTORIES::TItemId *typeTag) const { nlassert(_Type == TSupportedParamType::spt_itemId); return _ItemId; } bool operator == (const TParamValue &other) const { if (_Type != other._Type) return false; switch (_Type.getValue()) { case TSupportedParamType::spt_uint32: return _UInt32Val == other._UInt32Val; break; case TSupportedParamType::spt_uint64: return _UInt64Val == other._UInt64Val; break; case TSupportedParamType::spt_sint32: return _SInt32Val == other._SInt32Val; break; case TSupportedParamType::spt_float: return _FloatVal == other._FloatVal; break; case TSupportedParamType::spt_string: return _StringVal == other._StringVal; break; case TSupportedParamType::spt_entityId: return _EntityId == other._EntityId; break; case TSupportedParamType::spt_sheetId: return _SheetId == other._SheetId; break; case TSupportedParamType::spt_itemId: return _ItemId == other._ItemId; break; default: return false;; }; } bool operator < (const TParamValue &other) const { if (_Type != other._Type) return false; switch (_Type.getValue()) { case TSupportedParamType::spt_uint32: return _UInt32Val < other._UInt32Val; break; case TSupportedParamType::spt_uint64: return _UInt64Val < other._UInt64Val; break; case TSupportedParamType::spt_sint32: return _SInt32Val < other._SInt32Val; break; case TSupportedParamType::spt_float: return _FloatVal < other._FloatVal; break; case TSupportedParamType::spt_string: return _StringVal < other._StringVal; break; case TSupportedParamType::spt_entityId: return _EntityId < other._EntityId; break; case TSupportedParamType::spt_sheetId: return _SheetId < other._SheetId; break; case TSupportedParamType::spt_itemId: return _ItemId < other._ItemId; break; default: return false;; }; } private: TSupportedParamType _Type; union { uint32 _UInt32Val; uint64 _UInt64Val; sint32 _SInt32Val; float _FloatVal; }; std::string _StringVal; NLMISC::CEntityId _EntityId; NLMISC::CSheetId _SheetId; INVENTORIES::TItemId _ItemId; }; ]]>