mirror of https://gitee.com/bigwinds/arangodb
reorganised files
This commit is contained in:
parent
4207db1596
commit
e8d7b1b9ab
|
@ -0,0 +1,371 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result arrays
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantArray.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
#include <Variant/VariantBlob.h>
|
||||
#include <Variant/VariantBoolean.h>
|
||||
#include <Variant/VariantDate.h>
|
||||
#include <Variant/VariantDatetime.h>
|
||||
#include <Variant/VariantDouble.h>
|
||||
#include <Variant/VariantFloat.h>
|
||||
#include <Variant/VariantInt8.h>
|
||||
#include <Variant/VariantInt16.h>
|
||||
#include <Variant/VariantInt32.h>
|
||||
#include <Variant/VariantInt64.h>
|
||||
#include <Variant/VariantMatrix2.h>
|
||||
#include <Variant/VariantNull.h>
|
||||
#include <Variant/VariantString.h>
|
||||
#include <Variant/VariantUInt8.h>
|
||||
#include <Variant/VariantUInt16.h>
|
||||
#include <Variant/VariantUInt32.h>
|
||||
#include <Variant/VariantUInt64.h>
|
||||
#include <Variant/VariantVector.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantArray::VariantArray ()
|
||||
: attributes(), mapping(), nextKey() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
VariantArray::~VariantArray () {
|
||||
for (map<string, VariantObject*>::const_iterator i = mapping.begin(); i != mapping.end(); ++i) {
|
||||
VariantObject* value = i->second;
|
||||
|
||||
if (value != 0) {
|
||||
delete value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantObject* VariantArray::clone () const {
|
||||
VariantArray* copy = new VariantArray();
|
||||
|
||||
for (map<string, VariantObject*>::const_iterator i = mapping.begin(); i != mapping.end(); ++i) {
|
||||
copy->add(i->first, i->second->clone());
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VariantArray::print (StringBuffer& buffer, size_t indent) const {
|
||||
buffer.appendText("{\n");
|
||||
|
||||
for (map<string, VariantObject*>::const_iterator i = mapping.begin(); i != mapping.end(); ++i) {
|
||||
printIndent(buffer, indent + 1);
|
||||
|
||||
buffer.appendText(i->first);
|
||||
buffer.appendText(" => ");
|
||||
|
||||
i->second->print(buffer, indent + 2);
|
||||
}
|
||||
|
||||
printIndent(buffer, indent);
|
||||
buffer.appendText("}\n");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
vector<VariantObject*> VariantArray::getValues () const {
|
||||
vector<VariantObject*> result;
|
||||
|
||||
for (vector<string>::const_iterator i = attributes.begin(); i != attributes.end(); ++i) {
|
||||
string const& key = *i;
|
||||
map<string, VariantObject*>::const_iterator j = mapping.find(key);
|
||||
|
||||
if (j == mapping.end()) {
|
||||
result.push_back(0);
|
||||
}
|
||||
else {
|
||||
result.push_back(j->second);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VariantArray::add (string const& key, VariantObject* value) {
|
||||
map<string, VariantObject*>::const_iterator j = mapping.find(key);
|
||||
|
||||
if (j == mapping.end()) {
|
||||
attributes.push_back(key);
|
||||
mapping[key] = value;
|
||||
}
|
||||
else {
|
||||
delete j->second;
|
||||
mapping[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VariantArray::add (string const& key, string const& valueString) {
|
||||
add(key, new VariantString(valueString));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VariantArray::add (vector<string> const& kv) {
|
||||
for (vector<string>::const_iterator i = kv.begin(); i != kv.end(); i += 2) {
|
||||
string const& key = *i;
|
||||
|
||||
add(key, new VariantString(*(i+1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VariantArray::addNextKey (string const& key) {
|
||||
nextKey = key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VariantArray::addNextValue (VariantObject* value) {
|
||||
if (! nextKey.empty()) {
|
||||
add(nextKey, value);
|
||||
nextKey = "";
|
||||
}
|
||||
else {
|
||||
delete value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
VariantObject* VariantArray::lookup (string const& name) {
|
||||
map<string,VariantObject*>::iterator i = mapping.find(name);
|
||||
|
||||
if (i == mapping.end()) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return i->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantArray* VariantArray::lookupArray (string const& name) {
|
||||
return dynamic_cast<VariantArray*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantBlob* VariantArray::lookupBlob (string const& name) {
|
||||
return dynamic_cast<VariantBlob*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantBoolean* VariantArray::lookupBoolean (string const& name) {
|
||||
return dynamic_cast<VariantBoolean*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantDate* VariantArray::lookupDate (string const& name) {
|
||||
return dynamic_cast<VariantDate*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantDatetime* VariantArray::lookupDatetime (string const& name) {
|
||||
return dynamic_cast<VariantDatetime*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantDouble* VariantArray::lookupDouble (string const& name) {
|
||||
return dynamic_cast<VariantDouble*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantFloat* VariantArray::lookupFloat (string const& name) {
|
||||
return dynamic_cast<VariantFloat*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantInt16* VariantArray::lookupInt16 (string const& name) {
|
||||
return dynamic_cast<VariantInt16*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
VariantInt8* VariantArray::lookupInt8 (string const& name) {
|
||||
return dynamic_cast<VariantInt8*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
VariantInt32* VariantArray::lookupInt32 (string const& name) {
|
||||
return dynamic_cast<VariantInt32*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantInt64* VariantArray::lookupInt64 (string const& name) {
|
||||
return dynamic_cast<VariantInt64*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantMatrix2* VariantArray::lookupMatrix2 (string const& name) {
|
||||
return dynamic_cast<VariantMatrix2*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantNull* VariantArray::lookupNull (string const& name) {
|
||||
return dynamic_cast<VariantNull*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantString* VariantArray::lookupString (string const& name) {
|
||||
return dynamic_cast<VariantString*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
string const& VariantArray::lookupString (string const& name, bool& found) {
|
||||
static string const empty = "";
|
||||
|
||||
VariantObject* o = lookup(name);
|
||||
|
||||
if (o == 0) {
|
||||
found = false;
|
||||
return empty;
|
||||
}
|
||||
else {
|
||||
if (o->is<VariantString>()) {
|
||||
found = true;
|
||||
return dynamic_cast<VariantString*>(o)->getValue();
|
||||
}
|
||||
else {
|
||||
found = false;
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
VariantUInt8* VariantArray::lookupUInt8 (string const& name) {
|
||||
return dynamic_cast<VariantUInt8*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
VariantUInt16* VariantArray::lookupUInt16 (string const& name) {
|
||||
return dynamic_cast<VariantUInt16*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantUInt32* VariantArray::lookupUInt32 (string const& name) {
|
||||
return dynamic_cast<VariantUInt32*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantUInt64* VariantArray::lookupUInt64 (string const& name) {
|
||||
return dynamic_cast<VariantUInt64*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VariantVector* VariantArray::lookupVector (string const& name) {
|
||||
return dynamic_cast<VariantVector*>(lookup(name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
vector<string> VariantArray::lookupStrings (string const& name, bool& error) {
|
||||
vector<string> result;
|
||||
error = false;
|
||||
|
||||
VariantVector* attr = lookupVector(name);
|
||||
|
||||
if (attr == 0) {
|
||||
error = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
vector<VariantObject*> const& elements = attr->getValues();
|
||||
|
||||
for (vector<VariantObject*>::const_iterator i = elements.begin(); i != elements.end(); ++i) {
|
||||
VariantObject* element = *i;
|
||||
VariantString* s = dynamic_cast<VariantString*>(element);
|
||||
|
||||
if (s == 0) {
|
||||
error = true;
|
||||
}
|
||||
else {
|
||||
result.push_back(s->getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,309 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for arrays
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_ARRAY_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_ARRAY_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
class VariantBlob;
|
||||
class VariantBoolean;
|
||||
class VariantDate;
|
||||
class VariantDatetime;
|
||||
class VariantDouble;
|
||||
class VariantFloat;
|
||||
class VariantInt8;
|
||||
class VariantInt16;
|
||||
class VariantInt32;
|
||||
class VariantInt64;
|
||||
class VariantMatrix2;
|
||||
class VariantNull;
|
||||
class VariantString;
|
||||
class VariantUInt8;
|
||||
class VariantUInt16;
|
||||
class VariantUInt32;
|
||||
class VariantUInt64;
|
||||
class VariantVector;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for arrays
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantArray : public VariantObject {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief type of VariantObject
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static ObjectType const TYPE = VARIANT_ARRAY;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new array
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantArray ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new array
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~VariantArray ();
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ObjectType type () const {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantObject* clone () const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the attributes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
vector<string> const& getAttributes () const {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the values
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
vector<VariantObject*> getValues () const;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief adds a key value pair
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void add (string const& key, VariantObject* value);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief adds a key value pair
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void add (string const& key, string const& value);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief adds many key value pairs
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void add (vector <string> const& kv);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief prepares next key/value pair
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void addNextKey (string const& key);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief finishes next key/value pair
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void addNextValue (VariantObject* value);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up an attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantObject* lookup (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up an array attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantArray* lookupArray (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a blob attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantBlob* lookupBlob (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a boolean attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantBoolean* lookupBoolean (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a date attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantDate* lookupDate (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a datetime attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantDatetime* lookupDatetime (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a double attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantDouble* lookupDouble (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a float attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantFloat* lookupFloat (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a int16 attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantInt8* lookupInt8 (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a int16 attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantInt16* lookupInt16 (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a int32 attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantInt32* lookupInt32 (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a int64 attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantInt64* lookupInt64 (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a matrix attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantMatrix2* lookupMatrix2 (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a null attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantNull* lookupNull (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a string attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantString* lookupString (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a string attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& lookupString (string const& name, bool& found);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a uint8 attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantUInt8* lookupUInt8 (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a uint16 attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantUInt16* lookupUInt16 (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a uint32 attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantUInt32* lookupUInt32 (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a uint64 attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantUInt64* lookupUInt64 (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a vector attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantVector* lookupVector (string const& name);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief looks up a vector attribute
|
||||
///
|
||||
/// The attribute must be a vector of VariantString. If there is an entry which
|
||||
/// is not a VariantString or the attribute is not a VariantVector than an
|
||||
/// error is flagged.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
vector<string> lookupStrings (string const& name, bool& error);
|
||||
|
||||
protected:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief attributes names
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
vector<string> attributes;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief values
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
map<string, VariantObject*> mapping;
|
||||
|
||||
private:
|
||||
string nextKey;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,79 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result blobs
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantBlob.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantBlob::VariantBlob ()
|
||||
: value(0), length(0) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
VariantBlob::VariantBlob (char const* pointer, size_t len)
|
||||
: value(0), length(0) {
|
||||
if (pointer != 0) {
|
||||
value = new char[len];
|
||||
memcpy(value, pointer, len);
|
||||
length = len;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
VariantBlob::~VariantBlob() {
|
||||
if (value) {
|
||||
delete[] value;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantObject* VariantBlob::clone () const {
|
||||
return new VariantBlob(value, length);
|
||||
}
|
||||
|
||||
|
||||
void VariantBlob::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(blob) ");
|
||||
buffer.appendInteger(length);
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for blobs
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_BLOB_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_BLOB_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for blobs
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantBlob : public VariantObject {
|
||||
VariantBlob (VariantBlob const&);
|
||||
VariantBlob const& operator= (VariantBlob const&);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief type of VariantObject
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static ObjectType const TYPE = VARIANT_BLOB;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new blob
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantBlob ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new blob
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantBlob (char const* pointer, size_t len);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructs a blob
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~VariantBlob ();
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ObjectType type () const {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantObject* clone () const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the value
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const char* getValue () const {
|
||||
return value;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the length
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
size_t getLength () const {
|
||||
return length;
|
||||
}
|
||||
|
||||
private:
|
||||
char* value;
|
||||
size_t length;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,59 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result booleans
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantBoolean.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantBoolean::VariantBoolean (bool value)
|
||||
: VariantObjectTemplate<bool, VariantObject::VARIANT_BOOLEAN, VariantBoolean>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantBoolean::print (StringBuffer& buffer, size_t) const {
|
||||
if (getValue()) {
|
||||
buffer.appendText("true");
|
||||
}
|
||||
else {
|
||||
buffer.appendText("false");
|
||||
}
|
||||
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for booleans
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_BOOLEAN_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_BOOLEAN_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for booleans
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantBoolean : public VariantObjectTemplate<bool, VariantObject::VARIANT_BOOLEAN, VariantBoolean> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new boolean
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantBoolean (bool value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result dates
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantDate.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantDate::VariantDate (date_t value)
|
||||
: VariantObjectTemplate<date_t, VariantObject::VARIANT_DATE, VariantDate>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantDate::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(date) ");
|
||||
buffer.appendDecimal(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for dates
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_DATE_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_DATE_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for dates
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantDate : public VariantObjectTemplate<date_t, VariantObject::VARIANT_DATE, VariantDate> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new date
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantDate (date_t value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result datetimes
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantDatetime.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantDatetime::VariantDatetime (datetime_t value)
|
||||
: VariantObjectTemplate<datetime_t, VariantObject::VARIANT_DATETIME, VariantDatetime>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantDatetime::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(datetime) ");
|
||||
buffer.appendDecimal(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for datetimes
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_DATETIME_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_DATETIME_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for datetimes
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantDatetime : public VariantObjectTemplate<datetime_t, VariantObject::VARIANT_DATETIME, VariantDatetime> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new datetime
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantDatetime (datetime_t value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result doubles
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantDouble.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantDouble::VariantDouble (double value)
|
||||
: VariantObjectTemplate<double, VariantObject::VARIANT_DOUBLE, VariantDouble>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantDouble::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(double) ");
|
||||
buffer.appendDecimal(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for doubles
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_DOUBLE_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_DOUBLE_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for doubles
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantDouble : public VariantObjectTemplate<double, VariantObject::VARIANT_DOUBLE, VariantDouble> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new double
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantDouble (double value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result floats
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantFloat.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantFloat::VariantFloat (float value)
|
||||
: VariantObjectTemplate<float, VariantObject::VARIANT_FLOAT, VariantFloat>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantFloat::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(float) ");
|
||||
buffer.appendDecimal(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for floats
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_FLOAT_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_FLOAT_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for floats
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantFloat : public VariantObjectTemplate<float, VariantObject::VARIANT_FLOAT, VariantFloat> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new float
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantFloat (float value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantInt16.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantInt16::VariantInt16 (int16_t value)
|
||||
: VariantObjectTemplate<int16_t, VariantObject::VARIANT_INT16, VariantInt16>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantInt16::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(int16) ");
|
||||
buffer.appendInteger(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_INT16_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_INT16_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for integers
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantInt16 : public VariantObjectTemplate<int16_t, VariantObject::VARIANT_INT16, VariantInt16> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new int16
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantInt16 (int16_t value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantInt32.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantInt32::VariantInt32 (int32_t value)
|
||||
: VariantObjectTemplate<int32_t, VariantObject::VARIANT_INT32, VariantInt32>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantInt32::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(int32) ");
|
||||
buffer.appendInteger(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_INT32_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_INT32_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for integers
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantInt32 : public VariantObjectTemplate<int32_t, VariantObject::VARIANT_INT32, VariantInt32> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new int32
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantInt32 (int32_t value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantInt64.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantInt64::VariantInt64 (int64_t value)
|
||||
: VariantObjectTemplate<int64_t, VariantObject::VARIANT_INT64, VariantInt64>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantInt64::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(int64) ");
|
||||
buffer.appendInteger(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_INT64_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_INT64_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for integers
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantInt64 : public VariantObjectTemplate<int64_t, VariantObject::VARIANT_INT64, VariantInt64> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new int64
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantInt64 (int64_t value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantInt8.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantInt8::VariantInt8 (int8_t value)
|
||||
: VariantObjectTemplate<int8_t, VariantObject::VARIANT_INT8, VariantInt8>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantInt8::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(int8) ");
|
||||
buffer.appendInteger(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_INT8_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_INT8_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for integers
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantInt8 : public VariantObjectTemplate<int8_t, VariantObject::VARIANT_INT8, VariantInt8> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new int16
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantInt8 (int8_t value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,166 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for two-dimensional result matrixs
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2009-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantMatrix2.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
#include <Variant/VariantString.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantMatrix2::VariantMatrix2 () {
|
||||
}
|
||||
|
||||
|
||||
|
||||
VariantMatrix2::~VariantMatrix2 () {
|
||||
for (vector< vector<VariantObject*> >::const_iterator i = values.begin(); i != values.end(); ++i) {
|
||||
vector<VariantObject*> const& line = *i;
|
||||
|
||||
for (vector<VariantObject*>::const_iterator j = line.begin(); j != line.end(); ++j) {
|
||||
if (*j != 0) {
|
||||
delete *j;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantObject* VariantMatrix2::clone () const {
|
||||
VariantMatrix2* copy = new VariantMatrix2();
|
||||
|
||||
copy->dimensions[0] = dimensions[0];
|
||||
copy->dimensions[1] = dimensions[1];
|
||||
|
||||
for (vector< vector<VariantObject*> >::const_iterator i = values.begin(); i != values.end(); ++i) {
|
||||
vector<VariantObject*> const& inner = *i;
|
||||
vector<VariantObject*> innerCopy;
|
||||
|
||||
for (vector<VariantObject*>::const_iterator j = inner.begin(); j != inner.end(); ++j) {
|
||||
VariantObject* vs = *j;
|
||||
|
||||
innerCopy.push_back(vs->clone());
|
||||
}
|
||||
|
||||
copy->values.push_back(innerCopy);
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VariantMatrix2::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(matrix)");
|
||||
buffer.appendEol();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
vector<string> const& VariantMatrix2::getDimension (size_t n) const {
|
||||
if (n >= 2) {
|
||||
THROW_PARAMETER_ERROR("n", "getDimension", "too large");
|
||||
}
|
||||
|
||||
return dimensions[n];
|
||||
}
|
||||
|
||||
|
||||
|
||||
VariantObject* VariantMatrix2::getValue (size_t x, size_t y) const {
|
||||
if (dimensions[0].size() <= x) {
|
||||
THROW_PARAMETER_ERROR("x", "setValue", "too large");
|
||||
}
|
||||
|
||||
if (dimensions[1].size() <= y) {
|
||||
THROW_PARAMETER_ERROR("y", "setValue", "too large");
|
||||
}
|
||||
|
||||
if (values.size() <= x) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
vector<VariantObject*> const& line = values[x];
|
||||
|
||||
if (line.size() <= y) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return line[y];
|
||||
}
|
||||
|
||||
|
||||
void VariantMatrix2::setValue (size_t x, size_t y, VariantObject* object) {
|
||||
if (dimensions[0].size() <= x) {
|
||||
THROW_PARAMETER_ERROR("x", "setValue", "too large");
|
||||
}
|
||||
|
||||
if (dimensions[1].size() <= y) {
|
||||
THROW_PARAMETER_ERROR("y", "setValue", "too large");
|
||||
}
|
||||
|
||||
if (values.size() <= x) {
|
||||
values.resize(x + 1);
|
||||
}
|
||||
|
||||
vector<VariantObject*>& line = values[x];
|
||||
|
||||
if (line.size() <= y) {
|
||||
line.resize(y + 1);
|
||||
}
|
||||
|
||||
if (line[y] != 0) {
|
||||
delete line[y];
|
||||
}
|
||||
|
||||
line[y] = object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t VariantMatrix2::addDimension (size_t n, string const& name) {
|
||||
if (n >= 2) {
|
||||
THROW_PARAMETER_ERROR("n", "addDimension", "too large");
|
||||
}
|
||||
|
||||
dimensions[n].push_back(name);
|
||||
|
||||
return dimensions[n].size() - 1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for two-dimensional matrices
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2009-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_MATRIX2_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_MATRIX2_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for two-dimensional matrices
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantMatrix2 : public VariantObject {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief type of VariantObject
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static ObjectType const TYPE = VARIANT_MATRIX2;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new matrix2
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantMatrix2 ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new matrix2
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~VariantMatrix2 ();
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ObjectType type () const {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantObject* clone () const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the dimensions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
vector<string> const& getDimension (size_t n) const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the values
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
vector< vector<VariantObject*> > const& getValues () const {
|
||||
return values;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the values
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantObject* getValue (size_t x, size_t y) const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief set a value
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void setValue (size_t x, size_t y, VariantObject*);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief adds a dimension element
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
size_t addDimension (size_t n, string const& name);
|
||||
|
||||
private:
|
||||
vector<string> dimensions[2];
|
||||
vector< vector<VariantObject*> > values;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,45 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result nulls
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantNull.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantNull::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(null)");
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for nulls
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_NULL_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_NULL_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for nulls
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantNull : public VariantObject {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief type of VariantObject
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static ObjectType const TYPE = VARIANT_NULL;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ObjectType type () const {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantObject* clone () const {
|
||||
return new VariantNull();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,88 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief abstract base class for result objects
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantObject.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// static methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
string VariantObject::NameObjectType (ObjectType type) {
|
||||
switch (type) {
|
||||
case VARIANT_ARRAY: return "ARRAY";
|
||||
case VARIANT_BLOB: return "BLOB";
|
||||
case VARIANT_BOOLEAN: return "BOOLEAN";
|
||||
case VARIANT_DATE: return "DATE";
|
||||
case VARIANT_DATETIME: return "DATETIME";
|
||||
case VARIANT_DOUBLE: return "DOUBLE";
|
||||
case VARIANT_FLOAT: return "FLOAT";
|
||||
case VARIANT_INT8: return "INT8";
|
||||
case VARIANT_INT16: return "INT16";
|
||||
case VARIANT_INT32: return "INT32";
|
||||
case VARIANT_INT64: return "INT64";
|
||||
case VARIANT_MATRIX2: return "MATRIX2";
|
||||
case VARIANT_NULL: return "NULL";
|
||||
case VARIANT_ROW: return "ROW";
|
||||
case VARIANT_STRING: return "STRING";
|
||||
case VARIANT_UINT8: return "UINT8";
|
||||
case VARIANT_UINT16: return "UINT16";
|
||||
case VARIANT_UINT32: return "UINT32";
|
||||
case VARIANT_UINT64: return "UINT64";
|
||||
case VARIANT_VECTOR: return "VECTOR";
|
||||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantObject::VariantObject () {
|
||||
}
|
||||
|
||||
|
||||
|
||||
VariantObject::~VariantObject () {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantObject::printIndent (StringBuffer& buffer, size_t indent) const {
|
||||
for (size_t i = 0; i < indent; ++i) {
|
||||
buffer.appendText(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,214 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief abstract base class for variant objects
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_OBJECT_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_OBJECT_H 1
|
||||
|
||||
#include <Basics/Common.h>
|
||||
|
||||
#include <Basics/Exceptions.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @defgroup Variants Variant Objects
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
struct StringBuffer;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief abstract base class for variant objects
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantObject {
|
||||
private:
|
||||
VariantObject (VariantObject const&);
|
||||
VariantObject& operator= (VariantObject const&);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief enumeration of all non-abstract object types
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
enum ObjectType {
|
||||
VARIANT_ARRAY,
|
||||
VARIANT_BLOB,
|
||||
VARIANT_BOOLEAN,
|
||||
VARIANT_DATE,
|
||||
VARIANT_DATETIME,
|
||||
VARIANT_DOUBLE,
|
||||
VARIANT_FLOAT,
|
||||
VARIANT_INT8,
|
||||
VARIANT_INT16,
|
||||
VARIANT_INT32,
|
||||
VARIANT_INT64,
|
||||
VARIANT_MATRIX2,
|
||||
VARIANT_NULL,
|
||||
VARIANT_ROW,
|
||||
VARIANT_STRING,
|
||||
VARIANT_UINT8,
|
||||
VARIANT_UINT16,
|
||||
VARIANT_UINT32,
|
||||
VARIANT_UINT64,
|
||||
VARIANT_VECTOR
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief name of an object types
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static string NameObjectType (ObjectType);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a result object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantObject ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructs a result object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual ~VariantObject ();
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief converts into specific subtype or raises an error
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T> T* as () {
|
||||
T* c = dynamic_cast<T*>(this);
|
||||
|
||||
if (c == 0) {
|
||||
THROW_INTERNAL_ERROR("illegal cast");
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief checks for specific subtype
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename T> bool is () const {
|
||||
return this->type() == T::TYPE;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the object type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual ObjectType type () const = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief clones an object
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual VariantObject* clone () const = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief prints an object to a string buffer für debugging
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void print (StringBuffer&, size_t indent) const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief print indentation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void printIndent (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief helper class for simple types
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<typename C, enum VariantObject::ObjectType OT, typename VT>
|
||||
class VariantObjectTemplate : public VariantObject {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief type of VariantObject
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static ObjectType const TYPE = OT;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new simple variant
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantObjectTemplate (C value)
|
||||
: value(value) {
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ObjectType type () const {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantObject* clone () const {
|
||||
return new VT(value);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the name
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
C getValue () const {
|
||||
return value;
|
||||
}
|
||||
|
||||
private:
|
||||
C value;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,46 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result strings
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantString.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantString::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText(value.c_str(), value.length());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for strings
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_STRING_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_STRING_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for strings
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantString : public VariantObject {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief type of VariantObject
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static ObjectType const TYPE = VARIANT_STRING;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new string
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantString (string const& value)
|
||||
: value(value) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new string
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantString (char const* value, size_t length)
|
||||
: value(string(value, length)) {
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ObjectType type () const {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantObject* clone () const {
|
||||
return new VariantString(value);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the value
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string const& getValue () const {
|
||||
return value;
|
||||
}
|
||||
|
||||
private:
|
||||
string value;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantUInt16.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantUInt16::VariantUInt16 (uint16_t value)
|
||||
: VariantObjectTemplate<uint16_t, VariantObject::VARIANT_UINT16, VariantUInt16>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantUInt16::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(uint16) ");
|
||||
buffer.appendInteger(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_UINT16_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_UINT16_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for integers
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantUInt16 : public VariantObjectTemplate<uint16_t, VariantObject::VARIANT_UINT16, VariantUInt16> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new uint16
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantUInt16 (uint16_t value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantUInt32.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantUInt32::VariantUInt32 (uint32_t value)
|
||||
: VariantObjectTemplate<uint32_t, VariantObject::VARIANT_UINT32, VariantUInt32>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantUInt32::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(uint32) ");
|
||||
buffer.appendInteger(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_UINT32_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_UINT32_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for integers
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantUInt32 : public VariantObjectTemplate<uint32_t, VariantObject::VARIANT_UINT32, VariantUInt32> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new uint32
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantUInt32 (uint32_t value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantUInt64.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantUInt64::VariantUInt64 (uint64_t value)
|
||||
: VariantObjectTemplate<uint64_t, VariantObject::VARIANT_UINT64, VariantUInt64>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantUInt64::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(uint64) ");
|
||||
buffer.appendInteger(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_UINT64_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_UINT64_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for integers
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantUInt64 : public VariantObjectTemplate<uint64_t, VariantObject::VARIANT_UINT64, VariantUInt64> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new uint64
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantUInt64 (uint64_t value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,54 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantUInt8.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantUInt8::VariantUInt8 (uint8_t value)
|
||||
: VariantObjectTemplate<uint8_t, VariantObject::VARIANT_UINT8, VariantUInt8>(value) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantUInt8::print (StringBuffer& buffer, size_t) const {
|
||||
buffer.appendText("(uint8) ");
|
||||
buffer.appendInteger(getValue());
|
||||
buffer.appendEol();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for integers
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_UINT8_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_UINT8_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for integers
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantUInt8 : public VariantObjectTemplate<uint8_t, VariantObject::VARIANT_UINT8, VariantUInt8> {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new int16
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantUInt8 (uint8_t value);
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,132 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief class for result vectors
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "VariantVector.h"
|
||||
|
||||
#include <Basics/StringBuffer.h>
|
||||
#include <Variant/VariantString.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// constructors and destructors
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantVector::VariantVector () {
|
||||
}
|
||||
|
||||
|
||||
|
||||
VariantVector::VariantVector (vector<string> const& elements) {
|
||||
for (vector<string>::const_iterator i = elements.begin(); i != elements.end(); ++i) {
|
||||
string const& value = *i;
|
||||
values.push_back(new VariantString(value));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
VariantVector::~VariantVector () {
|
||||
for (vector<VariantObject*>::const_iterator i = values.begin(); i != values.end(); ++i) {
|
||||
delete (*i);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// VariantObject methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
VariantObject* VariantVector::clone () const {
|
||||
VariantVector* copy = new VariantVector();
|
||||
|
||||
for (vector<VariantObject*>::const_iterator i = values.begin(); i != values.end(); ++i) {
|
||||
VariantObject* o = *i;
|
||||
|
||||
copy->add(o->clone());
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VariantVector::print (StringBuffer& buffer, size_t indent) const {
|
||||
buffer.appendText("{\n");
|
||||
|
||||
vector<VariantObject*>::const_iterator j = values.begin();
|
||||
|
||||
for (size_t i = 0; j != values.end(); ++i, ++j) {
|
||||
printIndent(buffer, indent+1);
|
||||
|
||||
buffer.appendInteger(i);
|
||||
buffer.appendText(" => ");
|
||||
|
||||
(*j)->print(buffer, indent + 2);
|
||||
}
|
||||
|
||||
printIndent(buffer, indent);
|
||||
buffer.appendText("}\n");
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void VariantVector::add (VariantObject* value) {
|
||||
values.push_back(value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VariantVector::add (vector<VariantObject*> const& v) {
|
||||
for (vector<VariantObject*>::const_iterator i = v.begin(); i != v.end(); ++i) {
|
||||
VariantObject* value = *i;
|
||||
|
||||
values.push_back(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VariantVector::add (string const& value) {
|
||||
values.push_back(new VariantString(value));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void VariantVector::add (vector<string> const& v) {
|
||||
for (vector<string>::const_iterator i = v.begin(); i != v.end(); ++i) {
|
||||
string const& value = *i;
|
||||
|
||||
values.push_back(new VariantString(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief variant class for vectors
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Achim Brandt
|
||||
/// @author Copyright 2008-2011, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TRIAGENS_JUTLAND_BASICS_VARIANT_VECTOR_H
|
||||
#define TRIAGENS_JUTLAND_BASICS_VARIANT_VECTOR_H 1
|
||||
|
||||
#include <Variant/VariantObject.h>
|
||||
|
||||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @ingroup Variants
|
||||
/// @brief variant class for vectors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class VariantVector : public VariantObject {
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief type of VariantObject
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static ObjectType const TYPE = VARIANT_VECTOR;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new vector
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantVector ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new vector
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
explicit
|
||||
VariantVector (vector<string> const&);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructs a new vector
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
~VariantVector ();
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ObjectType type () const {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VariantObject* clone () const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void print (StringBuffer&, size_t indent) const;
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the values
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
vector<VariantObject*> const& getValues () const {
|
||||
return values;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief adds a value
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void add (VariantObject* value);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief adds many values
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void add (vector<VariantObject*> const& v);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief adds a string value
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void add (string const& value);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief adds many string values
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void add (vector<string> const& v);
|
||||
|
||||
private:
|
||||
vector<VariantObject*> values;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue