diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-09-25 14:59:58 -0700 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-09-25 14:59:58 -0700 |
commit | ffdaa0590d33ea89d116f6c56df2474cc0675ec9 (patch) | |
tree | 6b0d71337879892b43a4af90e6757d53ecc77853 /include/hiddenpointer.h | |
parent | 753402a84b40ff4dc9697dea1d2d4aa037ea7624 (diff) |
{auto} PHP objects can now be implemented in C++. Constructors and destructors get called at the appropriate time, but not yet any of the other methods
Diffstat (limited to 'include/hiddenpointer.h')
-rw-r--r-- | include/hiddenpointer.h | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/include/hiddenpointer.h b/include/hiddenpointer.h index 3502bc9..f432f65 100644 --- a/include/hiddenpointer.h +++ b/include/hiddenpointer.h @@ -113,19 +113,19 @@ public: /** * Change the pointer - * @param Type* + * @param Type* */ void setPointer(Type *pointer) { - // store pointer - _pointer = pointer; + // store pointer + _pointer = pointer; - // overwrite in data - _data.replace(0, sizeof(Type *), (const char *)&_pointer, sizeof(Type *)); - + // overwrite in data + _data.replace(0, sizeof(Type *), (const char *)&_pointer, sizeof(Type *)); + // for safety reasons, we recalculate text pointer _text = _data.c_str() + sizeof(Type *); - } + } /** * Retrieve the text @@ -138,14 +138,14 @@ public: /** * Change the text - * @param text - * @param size + * @param text + * @param size */ void setText(const char *text, int size=-1) { - // check if size was set - if (size < 0) size = strlen(text); - + // check if size was set + if (size < 0) size = strlen(text); + // reserve enough room for the text and the pointer _data.reserve(size + sizeof(Type *)); @@ -157,7 +157,7 @@ public: // store new text _text = _data.c_str() + sizeof(Type *); - } + } /** * Cast to the pointer @@ -183,8 +183,8 @@ public: */ int length() const { - return _data.size() - sizeof(Type *); - } + return _data.size() - sizeof(Type *); + } private: /** |