Hi, I am in the process of extending the json serializer to accept arguments which are json already and don't require further processing (my data contains mixed elements - partly raw data requiring conversion as well as json i'd like to output). As it so happens I have developed a patch which does not work as expected (see below). Any idea what I am missing ?
Cheers,
Marek
diff -ur cxxtools-2.2.1-orig/include/cxxtools/bin/formatter.h
cxxtools-2.2.1/include/cxxtools/bin/formatter.h
--- cxxtools-2.2.1-orig/include/cxxtools/bin/formatter.h 2013-12-26
17:33:48.000000000 +0800
+++ cxxtools-2.2.1/include/cxxtools/bin/formatter.h 2014-03-24
03:27:15.683283726 +0800
@@ -67,6 +67,8 @@
virtual void addNull(const std::string& name, const
std::string& type);
+ virtual void addPlain(const cxxtools::String& value);
+
virtual void beginArray(const std::string& name, const
std::string& type);
virtual void finishArray();
diff -ur cxxtools-2.2.1-orig/include/cxxtools/formatter.h
cxxtools-2.2.1/include/cxxtools/formatter.h
--- cxxtools-2.2.1-orig/include/cxxtools/formatter.h 2013-12-26
17:33:48.000000000 +0800
+++ cxxtools-2.2.1/include/cxxtools/formatter.h 2014-03-24 03:16:07.791315782
+0800
@@ -73,6 +73,8 @@
virtual void addNull(const std::string& name, const std::string& type);
+ virtual void addPlain(const cxxtools::String& value);
+
virtual void beginArray(const std::string& name, const std::string&
type) = 0;
virtual void finishArray() = 0;
diff -ur cxxtools-2.2.1-orig/include/cxxtools/jsonformatter.h
cxxtools-2.2.1/include/cxxtools/jsonformatter.h
--- cxxtools-2.2.1-orig/include/cxxtools/jsonformatter.h 2013-12-26
17:33:48.000000000 +0800
+++ cxxtools-2.2.1/include/cxxtools/jsonformatter.h 2014-03-24
03:17:42.659311228 +0800
@@ -78,6 +78,8 @@
virtual void addNull(const std::string& name, const std::string&
type);
+ virtual void addPlain(const cxxtools::String& value);
+
virtual void beginArray(const std::string& name, const
std::string& type);
virtual void finishArray();
diff -ur cxxtools-2.2.1-orig/include/cxxtools/log/cxxtools.h
cxxtools-2.2.1/include/cxxtools/log/cxxtools.h
--- cxxtools-2.2.1-orig/include/cxxtools/log/cxxtools.h 2014-01-18
03:05:09.000000000 +0800
+++ cxxtools-2.2.1/include/cxxtools/log/cxxtools.h 2014-03-24
16:55:32.620956064 +0800
@@ -41,7 +41,7 @@
if (_cxxtools_logger != 0 &&
_cxxtools_logger->isEnabled(::cxxtools::Logger::LOG_LEVEL_ ## level)) \
{ \
::cxxtools::LogMessage _cxxtools_logMessage(_cxxtools_logger, #level); \
- _cxxtools_logMessage.out() << expr; \
+ _cxxtools_logMessage.out() << "plain: " << expr; \
_cxxtools_logMessage.finish(); \
} \
} while (false)
diff -ur cxxtools-2.2.1-orig/include/cxxtools/serializationinfo.h
cxxtools-2.2.1/include/cxxtools/serializationinfo.h
--- cxxtools-2.2.1-orig/include/cxxtools/serializationinfo.h 2014-01-18
03:05:09.000000000 +0800
+++ cxxtools-2.2.1/include/cxxtools/serializationinfo.h 2014-03-24
02:57:11.691370310 +0800
@@ -53,7 +53,7 @@
public:
enum Category {
- Void = 0, Value = 1, Object = 2, Array = 6
+ Void = 0, Value = 1, Object = 2, Array = 6, Plain = 20
};
class Iterator;
@@ -262,6 +262,7 @@
void swap(SerializationInfo& si);
bool isNull() const { return _t == t_none && _category == Void; }
+ bool isPlain() const { return _category == Plain; }
bool isString() const { return _t == t_string; }
bool isString8() const { return _t == t_string8; }
bool isChar() const { return _t == t_char; }
diff -ur cxxtools-2.2.1-orig/src/bin/formatter.cpp
cxxtools-2.2.1/src/bin/formatter.cpp
--- cxxtools-2.2.1-orig/src/bin/formatter.cpp 2013-12-26 17:33:48.000000000
+0800
+++ cxxtools-2.2.1/src/bin/formatter.cpp 2014-03-24 03:31:11.547272405
+0800
@@ -581,6 +581,11 @@
*_out << '\xff';
}
+void Formatter::addPlain(const cxxtools::String& value)
+{
+ *_out << value;
+}
+
void Formatter::beginArray(const std::string& name, const std::string& type)
{
log_trace("beginArray(\"" << name << "\", \"" << type << ')');
diff -ur cxxtools-2.2.1-orig/src/decomposer.cpp
cxxtools-2.2.1/src/decomposer.cpp
--- cxxtools-2.2.1-orig/src/decomposer.cpp 2013-12-26 17:33:48.000000000
+0800
+++ cxxtools-2.2.1/src/decomposer.cpp 2014-03-24 03:10:17.143332611 +0800
@@ -37,6 +37,12 @@
{
formatter.addNull( si.name(), si.typeName() );
}
+ else if (si.category() == SerializationInfo::Plain)
+ {
+ String value;
+ si.getValue(value);
+ formatter.addPlain( value );
+ }
else if (si.category() == SerializationInfo::Value)
{
if (si.isInt())
diff -ur cxxtools-2.2.1-orig/src/formatter.cpp cxxtools-2.2.1/src/formatter.cpp
--- cxxtools-2.2.1-orig/src/formatter.cpp 2013-12-26 17:33:48.000000000
+0800
+++ cxxtools-2.2.1/src/formatter.cpp 2014-03-24 17:22:06.092879584 +0800
@@ -66,5 +66,10 @@
addValueString(name, type, String());
}
+void Formatter::addPlain(const cxxtools::String& value)
+{
+ addPlain(value);
+}
+
}
diff -ur cxxtools-2.2.1-orig/src/jsonformatter.cpp
cxxtools-2.2.1/src/jsonformatter.cpp
--- cxxtools-2.2.1-orig/src/jsonformatter.cpp 2014-01-18 03:05:09.000000000
+0800
+++ cxxtools-2.2.1/src/jsonformatter.cpp 2014-03-24 03:17:09.307312829
+0800
@@ -199,6 +199,11 @@
finishValue();
}
+void JsonFormatter::addPlain(const cxxtools::String& value)
+{
+ *_ts << value;
+}
+
void JsonFormatter::beginArray(const std::string& name, const std::string&
type)
{
checkTs(_ts);
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech
_______________________________________________ Tntnet-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/tntnet-general
