summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-15 21:57:08 +0100
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2014-03-15 21:57:08 +0100
commit895f6315eb306a677bddba86980de8f8ee824efe (patch)
tree75380e6151407cba36ea2fc186268290a363774b /include
parent3bcd6e21d1142b5ec35f99c4bdcd925bf7ae5083 (diff)
removed HardCoded class because it turned out to be too difficult to implement it for now
Diffstat (limited to 'include')
-rw-r--r--include/hardcoded.h89
-rw-r--r--include/hashmember.h10
-rw-r--r--include/value.h30
3 files changed, 17 insertions, 112 deletions
diff --git a/include/hardcoded.h b/include/hardcoded.h
deleted file mode 100644
index f48fc61..0000000
--- a/include/hardcoded.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/**
- * HardCoded.h
- *
- * Small class that can be wrapped around a "hardcoded string". Normally, the
- * Value object always makes a full copy of a string, because the value object
- * may exist for a longer period than the pointer-to-a-string that is wrapped
- * in it.
- *
- * However, in some situations it is already certain that the buffer in
- * which the original string is stored will outlive the Value object. This is
- * for example true for hardcoded strings. Such const-char* can be wrapped into
- * a Php::HardCoded instance before they are assigned to a Php::Value object
- *
- * This class is called HardCoded because it is often used for hardcoded
- * strings, but you can use it for other values as well.
- *
- * @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
- * @copyright 2014 Copernica BV
- */
-
-/**
- * Php namespace
- */
-namespace Php {
-
-/**
- * Class definition
- */
-class HardCoded
-{
-public:
- /**
- * Constructors
- *
- * The class has a regular constructor with a size or not, a copy constructor
- * and move constructor.
- *
- * @param buffer
- * @param size
- * @param that
- */
- HardCoded(const char *buffer, size_t size) : _buffer(buffer), _size(size) {}
- HardCoded(const char *buffer) : _buffer(buffer), _size(strlen(buffer)) {}
- HardCoded(const char buffer) : _buffer(&buffer), _size(1) {}
- HardCoded(const HardCoded &that) : _buffer(that._buffer), _size(that._size) {}
- HardCoded(HardCoded &&that) : _buffer(that._buffer), _size(that._size) {}
-
- /**
- * Destructor
- */
- virtual ~HardCoded() {}
-
- /**
- * Method to get access to the buffer
- * @return const char *
- */
- const char *buffer() const
- {
- return _buffer;
- }
-
- /**
- * Size of the buffer
- * @return size_t
- */
- size_t size() const
- {
- return _size;
- }
-
-private:
- /**
- * The actual buffer
- * @var const char *
- */
- const char *_buffer;
-
- /**
- * Size of the buffer
- * @var size_t
- */
- size_t _size;
-};
-
-/**
- * End namespace
- */
-}
-
diff --git a/include/hashmember.h b/include/hashmember.h
index d61e5c9..b8f4dcd 100644
--- a/include/hashmember.h
+++ b/include/hashmember.h
@@ -189,7 +189,6 @@ public:
HashMember &operator+=(char value) { return operator=(this->value() + value); }
HashMember &operator+=(const std::string &value) { return operator=(this->value() + value); }
HashMember &operator+=(const char *value) { return operator=(this->value() + value); }
- HashMember &operator+=(const HardCoded &value) { return operator=(this->value() + value); }
HashMember &operator+=(double value) { return operator=(this->value() + value); }
/**
@@ -205,7 +204,6 @@ public:
HashMember &operator-=(char value) { return operator=(this->value() - value); }
HashMember &operator-=(const std::string &value) { return operator=(this->value() - value); }
HashMember &operator-=(const char *value) { return operator=(this->value() - value); }
- HashMember &operator-=(const HardCoded &value) { return operator=(this->value() - value); }
HashMember &operator-=(double value) { return operator=(this->value() - value); }
/**
@@ -221,7 +219,6 @@ public:
HashMember &operator*=(char value) { return operator=(this->value() * value); }
HashMember &operator*=(const std::string &value) { return operator=(this->value() * value); }
HashMember &operator*=(const char *value) { return operator=(this->value() * value); }
- HashMember &operator*=(const HardCoded &value) { return operator=(this->value() * value); }
HashMember &operator*=(double value) { return operator=(this->value() * value); }
/**
@@ -237,7 +234,6 @@ public:
HashMember &operator/=(char value) { return operator=(this->value() / value); }
HashMember &operator/=(const std::string &value) { return operator=(this->value() / value); }
HashMember &operator/=(const char *value) { return operator=(this->value() / value); }
- HashMember &operator/=(const HardCoded &value) { return operator=(this->value() / value); }
HashMember &operator/=(double value) { return operator=(this->value() / value); }
/**
@@ -253,7 +249,6 @@ public:
HashMember &operator%=(char value) { return operator=(this->value() % value); }
HashMember &operator%=(const std::string &value) { return operator=(this->value() % value); }
HashMember &operator%=(const char *value) { return operator=(this->value() % value); }
- HashMember &operator%=(const HardCoded &value) { return operator=(this->value() % value); }
HashMember &operator%=(double value) { return operator=(this->value() % value); }
/**
@@ -269,7 +264,6 @@ public:
Value operator+(char value) { return this->value() + value; }
Value operator+(const std::string &value) { return this->value() + value; }
Value operator+(const char *value) { return this->value() + value; }
- Value operator+(const HardCoded &value) { return this->value() + value; }
Value operator+(double value) { return this->value() + value; }
/**
@@ -285,7 +279,6 @@ public:
Value operator-(char value) { return this->value() - value; }
Value operator-(const std::string &value) { return this->value() - value; }
Value operator-(const char *value) { return this->value() - value; }
- Value operator-(const HardCoded &value) { return this->value() - value; }
Value operator-(double value) { return this->value() - value; }
/**
@@ -301,7 +294,6 @@ public:
Value operator*(char value) { return this->value() * value; }
Value operator*(const std::string &value) { return this->value() * value; }
Value operator*(const char *value) { return this->value() * value; }
- Value operator*(const HardCoded &value) { return this->value() * value; }
Value operator*(double value) { return this->value() * value; }
/**
@@ -317,7 +309,6 @@ public:
Value operator/(char value) { return this->value() / value; }
Value operator/(const std::string &value) { return this->value() / value; }
Value operator/(const char *value) { return this->value() / value; }
- Value operator/(const HardCoded &value) { return this->value() / value; }
Value operator/(double value) { return this->value() / value; }
/**
@@ -333,7 +324,6 @@ public:
Value operator%(char value) { return this->value() % value; }
Value operator%(const std::string &value) { return this->value() % value; }
Value operator%(const char *value) { return this->value() % value; }
- Value operator%(const HardCoded &value) { return this->value() % value; }
Value operator%(double value) { return this->value() % value; }
/**
diff --git a/include/value.h b/include/value.h
index 13cea38..ed0367c 100644
--- a/include/value.h
+++ b/include/value.h
@@ -57,7 +57,6 @@ public:
Value(char value);
Value(const std::string &value);
Value(const char *value, int size = -1);
- Value(const HardCoded &value);
Value(double value);
/**
@@ -162,7 +161,6 @@ public:
Value &operator=(char value);
Value &operator=(const std::string &value);
Value &operator=(const char *value);
- Value &operator=(const HardCoded &value);
Value &operator=(double value);
/**
@@ -178,7 +176,6 @@ public:
Value &operator+=(char value);
Value &operator+=(const std::string &value);
Value &operator+=(const char *value);
- Value &operator+=(const HardCoded &value);
Value &operator+=(double value);
/**
@@ -194,7 +191,6 @@ public:
Value &operator-=(char value);
Value &operator-=(const std::string &value);
Value &operator-=(const char *value);
- Value &operator-=(const HardCoded &value);
Value &operator-=(double value);
/**
@@ -210,7 +206,6 @@ public:
Value &operator*=(char value);
Value &operator*=(const std::string &value);
Value &operator*=(const char *value);
- Value &operator*=(const HardCoded &value);
Value &operator*=(double value);
/**
@@ -226,7 +221,6 @@ public:
Value &operator/=(char value);
Value &operator/=(const std::string &value);
Value &operator/=(const char *value);
- Value &operator/=(const HardCoded &value);
Value &operator/=(double value);
/**
@@ -242,7 +236,6 @@ public:
Value &operator%=(char value);
Value &operator%=(const std::string &value);
Value &operator%=(const char *value);
- Value &operator%=(const HardCoded &value);
Value &operator%=(double value);
/**
@@ -258,7 +251,6 @@ public:
Value operator+(char value);
Value operator+(const std::string &value);
Value operator+(const char *value);
- Value operator+(const HardCoded &value);
Value operator+(double value);
/**
@@ -274,7 +266,6 @@ public:
Value operator-(char value);
Value operator-(const std::string &value);
Value operator-(const char *value);
- Value operator-(const HardCoded &value);
Value operator-(double value);
/**
@@ -290,7 +281,6 @@ public:
Value operator*(char value);
Value operator*(const std::string &value);
Value operator*(const char *value);
- Value operator*(const HardCoded &value);
Value operator*(double value);
/**
@@ -306,7 +296,6 @@ public:
Value operator/(char value);
Value operator/(const std::string &value);
Value operator/(const char *value);
- Value operator/(const HardCoded &value);
Value operator/(double value);
/**
@@ -322,7 +311,6 @@ public:
Value operator%(char value);
Value operator%(const std::string &value);
Value operator%(const char *value);
- Value operator%(const HardCoded &value);
Value operator%(double value);
/**
@@ -388,12 +376,28 @@ public:
/**
* Get access to the raw buffer - you can use this for direct reading and
* writing to and from the buffer. Note that this only works for string
- * variables - other variables return nullptr
+ * variables - other variables return nullptr.
+ *
+ * If you are going to write to the buffer, make sure that you first call
+ * the reserve() method to ensure that the buffer is big enough.
+ *
* @return char *
*/
char *buffer() const;
/**
+ * Reserve enough space in the buffer. If you want to write directly to
+ * the buffer (which is returned by the buffer() method), you should first
+ * reserve enough space in it. This can be done with this reserve() method.
+ * This will also turn the Value object into a string (if it was not
+ * already a string). The writable buffer is returned.
+ *
+ * @param size
+ * @return char*
+ */
+ char *reserve(size_t size);
+
+ /**
* Get access to the raw buffer for read operationrs.
* @return const char *
*/