Add some convenience overloads to UnknownElement's constructor

Originally committed to SVN as r5749.
This commit is contained in:
Thomas Goyne 2011-10-17 22:00:09 +00:00
parent 36280b7a2b
commit 0dee6ea223
3 changed files with 31 additions and 27 deletions

View file

@ -80,26 +80,26 @@ LogSink::~LogSink() {
for (unsigned int i=0; i < sink.size(); i++) {
json::Object entry;
entry["sec"] = (double)sink[i]->tv.tv_sec;
entry["usec"] = (double)sink[i]->tv.tv_usec;
entry["severity"] = (double)sink[i]->severity,
entry["section"] = (std::string)sink[i]->section;
entry["file"] = (std::string)sink[i]->file;
entry["func"] = (std::string)sink[i]->func;
entry["line"] = (double)sink[i]->line;
entry["sec"] = sink[i]->tv.tv_sec;
entry["usec"] = sink[i]->tv.tv_usec;
entry["severity"] = sink[i]->severity,
entry["section"] = sink[i]->section;
entry["file"] = sink[i]->file;
entry["func"] = sink[i]->func;
entry["line"] = sink[i]->line;
entry["message"] = std::string(sink[i]->message, sink[i]->len);
array.push_back(entry);
}
json::Array timeval_open;
timeval_open.push_back((double)time_start.tv_sec);
timeval_open.push_back((double)time_start.tv_usec);
timeval_open.push_back(time_start.tv_sec);
timeval_open.push_back(time_start.tv_usec);
root["timeval"]["open"] = timeval_open;
json::Array timeval_close;
timeval_close.push_back((double)time_close.tv_sec);
timeval_close.push_back((double)time_close.tv_usec);
timeval_close.push_back(time_close.tv_sec);
timeval_close.push_back(time_close.tv_usec);
root["timeval"]["close"] = timeval_close;

View file

@ -64,8 +64,10 @@ public:
UnknownElement(const UnknownElement& unknown);
UnknownElement(const Object& object);
UnknownElement(const Array& array);
UnknownElement(const Number& number);
UnknownElement(const Boolean& boolean);
UnknownElement(double number);
UnknownElement(int number);
UnknownElement(bool boolean);
UnknownElement(const char *string);
UnknownElement(const String& string);
UnknownElement(const Null& null);

View file

@ -99,26 +99,28 @@ inline UnknownElement::UnknownElement() : m_pImp(
inline UnknownElement::UnknownElement(const UnknownElement& unknown) : m_pImp( unknown.m_pImp->Clone()) {}
inline UnknownElement::UnknownElement(const Object& object) : m_pImp( new Imp_T<Object>(object) ) {}
inline UnknownElement::UnknownElement(const Array& array) : m_pImp( new Imp_T<Array>(array) ) {}
inline UnknownElement::UnknownElement(const Number& number) : m_pImp( new Imp_T<Number>(number) ) {}
inline UnknownElement::UnknownElement(const Boolean& boolean) : m_pImp( new Imp_T<Boolean>(boolean) ) {}
inline UnknownElement::UnknownElement(double number) : m_pImp( new Imp_T<Number>(number) ) {}
inline UnknownElement::UnknownElement(int number) : m_pImp( new Imp_T<Number>(number) ) {}
inline UnknownElement::UnknownElement(bool boolean) : m_pImp( new Imp_T<Boolean>(boolean) ) {}
inline UnknownElement::UnknownElement(const char *string) : m_pImp( new Imp_T<String>(string) ) {}
inline UnknownElement::UnknownElement(const String& string) : m_pImp( new Imp_T<String>(string) ) {}
inline UnknownElement::UnknownElement(const Null& null) : m_pImp( new Imp_T<Null>(null) ) {}
inline UnknownElement::~UnknownElement() { delete m_pImp; }
inline UnknownElement::operator const Object& () const { return CastTo<Object>(); }
inline UnknownElement::operator const Array& () const { return CastTo<Array>(); }
inline UnknownElement::operator const Number& () const { return CastTo<Number>(); }
inline UnknownElement::operator const Boolean& () const { return CastTo<Boolean>(); }
inline UnknownElement::operator const String& () const { return CastTo<String>(); }
inline UnknownElement::operator const Null& () const { return CastTo<Null>(); }
inline UnknownElement::operator const Object& () const { return CastTo<Object>(); }
inline UnknownElement::operator const Array& () const { return CastTo<Array>(); }
inline UnknownElement::operator const Number& () const { return CastTo<Number>(); }
inline UnknownElement::operator const Boolean& () const { return CastTo<Boolean>(); }
inline UnknownElement::operator const String& () const { return CastTo<String>(); }
inline UnknownElement::operator const Null& () const { return CastTo<Null>(); }
inline UnknownElement::operator Object& () { return ConvertTo<Object>(); }
inline UnknownElement::operator Array& () { return ConvertTo<Array>(); }
inline UnknownElement::operator Number& () { return ConvertTo<Number>(); }
inline UnknownElement::operator Boolean& () { return ConvertTo<Boolean>(); }
inline UnknownElement::operator String& () { return ConvertTo<String>(); }
inline UnknownElement::operator Null& () { return ConvertTo<Null>(); }
inline UnknownElement::operator Object& () { return ConvertTo<Object>(); }
inline UnknownElement::operator Array& () { return ConvertTo<Array>(); }
inline UnknownElement::operator Number& () { return ConvertTo<Number>(); }
inline UnknownElement::operator Boolean& () { return ConvertTo<Boolean>(); }
inline UnknownElement::operator String& () { return ConvertTo<String>(); }
inline UnknownElement::operator Null& () { return ConvertTo<Null>(); }
inline UnknownElement& UnknownElement::operator = (const UnknownElement& unknown)
{