Go to the documentation of this file. 1 #ifndef CNOID_UTIL_GENERAL_ID_H
2 #define CNOID_UTIL_GENERAL_ID_H
5 #include "exportdecl.h"
17 : valueType(Int), intId(-1) { }
19 : valueType(Int), intId(id) { }
21 : valueType(String), intId(0), stringId(id) { }
23 : valueType(org.valueType), intId(org.intId), stringId(org.stringId) { }
26 valueType = rhs.valueType;
28 stringId = rhs.stringId;
45 return rhs.valueType == Int && intId == rhs.intId;
47 return rhs.valueType == String && stringId == rhs.stringId;
54 return (valueType == Int && intId == rhs);
60 return (valueType == String && stringId == rhs);
66 bool isValid()
const {
return intId >= 0; }
67 bool isInt()
const {
return valueType == Int; }
68 bool isString()
const {
return valueType == String; }
69 int toInt()
const {
return intId; }
70 const std::string&
toString()
const {
return stringId; }
71 std::string label()
const;
80 return std::hash<int>()(key.
toInt());
82 return std::hash<std::string>()(key.
toString());
88 enum IdValueType { Int, String } valueType;
Definition: ValueTree.h:253
Definition: GeneralId.h:11
Listing * write(Mapping *mapping, const std::string &key, const Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:145
GeneralId(const std::string &id)
Definition: GeneralId.h:20
int toInt() const
Definition: GeneralId.h:69
bool operator!=(const std::string &rhs) const
Definition: GeneralId.h:62
Definition: GeneralId.h:76
bool isInt() const
Definition: GeneralId.h:67
bool read(const Mapping *mapping, const std::string &key, Eigen::MatrixBase< Derived > &x)
Definition: EigenArchive.h:43
GeneralId()
Definition: GeneralId.h:16
bool operator!=(int rhs) const
Definition: GeneralId.h:56
bool isValid() const
Definition: GeneralId.h:66
bool operator==(const std::string &rhs) const
Definition: GeneralId.h:59
static GeneralId defaultId()
Definition: GeneralId.h:14
Definition: AbstractSceneLoader.h:11
bool operator==(ref_ptr< T > const &a, ref_ptr< U > const &b)
Definition: Referenced.h:211
bool operator==(int rhs) const
Definition: GeneralId.h:53
GeneralId(int id)
Definition: GeneralId.h:18
bool operator!=(const GeneralId &rhs) const
Definition: GeneralId.h:50
size_t result_type
Definition: GeneralId.h:77
bool operator==(const GeneralId &rhs) const
Definition: GeneralId.h:43
const std::string & toString() const
Definition: GeneralId.h:70
result_type operator()(const GeneralId &key) const
Definition: GeneralId.h:78
bool isString() const
Definition: GeneralId.h:68
GeneralId & operator=(int rhs)
Definition: GeneralId.h:31
GeneralId & operator=(const GeneralId &rhs)
Definition: GeneralId.h:25
GeneralId(const GeneralId &org)
Definition: GeneralId.h:22
GeneralId & operator=(const std::string &rhs)
Definition: GeneralId.h:37