diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-02-28 15:17:53 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-02-28 15:17:53 +0100 |
commit | 7cf89f18d766368dd4a14d35e4e144107ad7be36 (patch) | |
tree | 0bd4e449cbfddc928c25aaa1abac8b44c028c8e2 /src/classbase.cpp | |
parent | 6072701319a3bf085bbc354c3e3dae9b7d021be0 (diff) |
implemented properties
Diffstat (limited to 'src/classbase.cpp')
-rw-r--r-- | src/classbase.cpp | 113 |
1 files changed, 110 insertions, 3 deletions
diff --git a/src/classbase.cpp b/src/classbase.cpp index 2ad51b1..8c5e238 100644 --- a/src/classbase.cpp +++ b/src/classbase.cpp @@ -202,9 +202,8 @@ void ClassBase::initialize() // @todo something with the flags, but before or after the register_internal_class? //setFlags(entry, _type.getFlags()); - // declare all properties - // @todo enable this -// _properties.initialize(_entry); + // declare all member variables + for (auto &member : _members) member->initialize(_entry); } /** @@ -258,6 +257,114 @@ void ClassBase::add(const char *name, method_callback_3 callback, int flags, con // add the method _methods.insert(std::make_shared<Method>(name, callback, flags, args)); } + +/** + * Add a property to the class + * @param name Name of the property + * @param value Actual property value + * @param flags Optional flags + */ +void ClassBase::add(const char *name, std::nullptr_t value, int flags) +{ + // add property + _members.insert(std::make_shared<NullMember>(name, flags)); +} + +/** + * Add a property to the class + * @param name Name of the property + * @param value Actual property value + * @param flags Optional flags + */ +void ClassBase::add(const char *name, int16_t value, int flags) +{ + // add property + _members.insert(std::make_shared<LongMember>(name, value, flags)); +} + +/** + * Add a property to the class + * @param name Name of the property + * @param value Actual property value + * @param flags Optional flags + */ +void ClassBase::add(const char *name, int32_t value, int flags) +{ + // add property + _members.insert(std::make_shared<LongMember>(name, value, flags)); +} + +/** + * Add a property to the class + * @param name Name of the property + * @param value Actual property value + * @param flags Optional flags + */ +void ClassBase::add(const char *name, int64_t value, int flags) +{ + // add property + _members.insert(std::make_shared<LongMember>(name, value, flags)); +} + +/** + * Add a property to the class + * @param name Name of the property + * @param value Actual property value + * @param flags Optional flags + */ +void ClassBase::add(const char *name, bool value, int flags) +{ + // add property + _members.insert(std::make_shared<BoolMember>(name, value, flags)); +} + +/** + * Add a property to the class + * @param name Name of the property + * @param value Actual property value + * @param flags Optional flags + */ +void ClassBase::add(const char *name, char value, int flags) +{ + // add property + _members.insert(std::make_shared<StringMember>(name, &value, 1, flags)); +} + +/** + * Add a property to the class + * @param name Name of the property + * @param value Actual property value + * @param flags Optional flags + */ +void ClassBase::add(const char *name, const std::string &value, int flags) +{ + // add property + _members.insert(std::make_shared<StringMember>(name, value, flags)); +} + +/** + * Add a property to the class + * @param name Name of the property + * @param value Actual property value + * @param flags Optional flags + */ +void ClassBase::add(const char *name, const char *value, int flags) +{ + // add property + _members.insert(std::make_shared<StringMember>(name, value, strlen(value), flags)); +} + +/** + * Add a property to the class + * @param name Name of the property + * @param value Actual property value + * @param flags Optional flags + */ +void ClassBase::add(const char *name, double value, int flags) +{ + // add property + _members.insert(std::make_shared<FloatMember>(name, value, flags)); +} /** * End namespace |