Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Did some work to make it compile in C++11 and C++03

    The default is C++03    which means std::auto_ptr<> for owned pointers.
    When using     C++11    this means std::unique_ptr<> for owned pointers.

    You can specify C++11 by setting the CXXSTDVER flag for make.

    This will build all libs with either 11 or 03 extension so they
    can live together in the destination directory.
  • Loading branch information...
commit 35321dff77aa2d465bffc48c8ec3299d07f0c91c 1 parent 38d41cd
@martin-seomoz martin-seomoz authored
View
19 Json/JsonDom.h
@@ -2,6 +2,7 @@
#ifndef THORSANVIL_JSON_JSON_DOM
#define THORSANVIL_JSON_JSON_DOM
+#include "portability.h"
#include "JsonException.h"
#include <boost/ptr_container/ptr_vector.hpp>
@@ -48,7 +49,7 @@ struct JsonObject
JsonArray* array;
} data;
};
-typedef std::pair<std::auto_ptr<std::string>,std::auto_ptr<JsonValue> > JsonMapValue;
+typedef std::pair<SMART_OWNED_PTR<std::string>,SMART_OWNED_PTR<JsonValue> > JsonMapValue;
/*
* Json only supports three types:
@@ -117,8 +118,8 @@ struct JsonValue
};
struct JsonStringItem: JsonValue
{
- std::auto_ptr<std::string> value;
- JsonStringItem(std::auto_ptr<std::string>& data): value(data) {}
+ SMART_OWNED_PTR<std::string> value;
+ JsonStringItem(SMART_OWNED_PTR<std::string>& data): value(SMART_OWNED_MOVE(data)) {}
virtual void print(std::ostream& stream) const { stream << '"' << *value << '"'; }
private:
@@ -126,8 +127,8 @@ struct JsonStringItem: JsonValue
};
struct JsonNumberItem: JsonValue
{
- std::auto_ptr<std::string> value;
- JsonNumberItem(std::auto_ptr<std::string>& data): value(data) {}
+ SMART_OWNED_PTR<std::string> value;
+ JsonNumberItem(SMART_OWNED_PTR<std::string>& data): value(SMART_OWNED_MOVE(data)) {}
virtual void print(std::ostream& stream) const { stream << *value; }
private:
@@ -154,16 +155,16 @@ struct JsonNULLItem: JsonValue
};
struct JsonMapItem: JsonValue
{
- std::auto_ptr<JsonMap> value;
- JsonMapItem(std::auto_ptr<JsonMap>& data): value(data) {}
+ SMART_OWNED_PTR<JsonMap> value;
+ JsonMapItem(SMART_OWNED_PTR<JsonMap>& data): value(SMART_OWNED_MOVE(data)) {}
virtual void print(std::ostream& stream) const { stream << *value; }
private:
};
struct JsonArrayItem: JsonValue
{
- std::auto_ptr<JsonArray> value;
- JsonArrayItem(std::auto_ptr<JsonArray>& data): value(data) {}
+ SMART_OWNED_PTR<JsonArray> value;
+ JsonArrayItem(SMART_OWNED_PTR<JsonArray>& data): value(SMART_OWNED_MOVE(data)) {}
virtual void print(std::ostream& stream) const { stream << *value; }
private:
View
28 Json/ParserInterface.h
@@ -111,14 +111,14 @@ struct ParserCleanInterface: ParserInterface
virtual void mapClose() {}
virtual JsonMap* mapCreate() { return NULL;}
virtual JsonMap* mapCreate(JsonMapValue* val) { delete val; return NULL;}
- virtual JsonMap* mapAppend(JsonMap* map, JsonMapValue* val) { std::auto_ptr<JsonMapValue> aval(val); delete map; return NULL;}
- virtual JsonMapValue* mapCreateElement(std::string* k,JsonValue* val) { std::auto_ptr<JsonValue> aval(val); delete k; return NULL;}
+ virtual JsonMap* mapAppend(JsonMap* map, JsonMapValue* val) { SMART_OWNED_PTR<JsonMapValue> aval(val); delete map; return NULL;}
+ virtual JsonMapValue* mapCreateElement(std::string* k,JsonValue* val) { SMART_OWNED_PTR<JsonValue> aval(val); delete k; return NULL;}
virtual std::string* mapKeyNote(std::string* k) { delete k; return NULL;}
virtual void arrayOpen() {}
virtual void arrayClose() {}
virtual JsonArray* arrayCreate() { return NULL;}
virtual JsonArray* arrayCreate(JsonValue* val) { delete val; return NULL;}
- virtual JsonArray* arrayAppend(JsonArray* arr, JsonValue* val) { std::auto_ptr<JsonArray> aarr(arr); delete val; return NULL;}
+ virtual JsonArray* arrayAppend(JsonArray* arr, JsonValue* val) { SMART_OWNED_PTR<JsonArray> aarr(arr); delete val; return NULL;}
virtual JsonArray* arrayNote(JsonArray* arr) { delete arr; return NULL;}
virtual JsonValue* arrayCreateElement(JsonValue* val) { delete val; return NULL;}
virtual JsonValue* valueParseMap(JsonMap* map) { delete map; return NULL;}
@@ -134,23 +134,23 @@ struct ParserCleanInterface: ParserInterface
struct ParserDomInterface: ParserCleanInterface
{
virtual JsonMap* mapCreate() { return new JsonMap();}
- virtual JsonMap* mapCreate(JsonMapValue* val) { std::auto_ptr<JsonMapValue>aval(val);std::auto_ptr<JsonMap> amap(new JsonMap());amap->insert(*(aval->first), aval->second);return amap.release();}
- virtual JsonMap* mapAppend(JsonMap* map, JsonMapValue* val) { std::auto_ptr<JsonMapValue>aval(val);std::auto_ptr<JsonMap> amap(map); amap->insert(*(aval->first), aval->second);return amap.release();}
- virtual JsonMapValue* mapCreateElement(std::string* k,JsonValue* val) { std::auto_ptr<JsonValue> aval(val);std::auto_ptr<std::string> ak(k);
- std::auto_ptr<JsonMapValue> result(new JsonMapValue);result->first = ak;result->second = aval;
+ virtual JsonMap* mapCreate(JsonMapValue* val) { SMART_OWNED_PTR<JsonMapValue>aval(val);SMART_OWNED_PTR<JsonMap> amap(new JsonMap());amap->insert(*(aval->first), aval->second.release());return amap.release();}
+ virtual JsonMap* mapAppend(JsonMap* map, JsonMapValue* val) { SMART_OWNED_PTR<JsonMapValue>aval(val);SMART_OWNED_PTR<JsonMap> amap(map); amap->insert(*(aval->first), aval->second.release());return amap.release();}
+ virtual JsonMapValue* mapCreateElement(std::string* k,JsonValue* val) { SMART_OWNED_PTR<JsonValue> aval(val);SMART_OWNED_PTR<std::string> ak(k);
+ SMART_OWNED_PTR<JsonMapValue> result(new JsonMapValue);result->first = SMART_OWNED_MOVE(ak);result->second = SMART_OWNED_MOVE(aval);
return result.release();
}
virtual std::string* mapKeyNote(std::string* k) { return k;}
virtual JsonArray* arrayCreate() { return new JsonArray();}
- virtual JsonArray* arrayCreate(JsonValue* val) { std::auto_ptr<JsonValue> aval(val);std::auto_ptr<JsonArray> aarr(new JsonArray());aarr->push_back(aval); return aarr.release();}
- virtual JsonArray* arrayAppend(JsonArray* arr, JsonValue* val) { std::auto_ptr<JsonValue> aval(val);std::auto_ptr<JsonArray> aarr(arr); aarr->push_back(aval); return aarr.release();}
+ virtual JsonArray* arrayCreate(JsonValue* val) { SMART_OWNED_PTR<JsonValue> aval(val);SMART_OWNED_PTR<JsonArray> aarr(new JsonArray());aarr->push_back(aval.release()); return aarr.release();}
+ virtual JsonArray* arrayAppend(JsonArray* arr, JsonValue* val) { SMART_OWNED_PTR<JsonValue> aval(val);SMART_OWNED_PTR<JsonArray> aarr(arr); aarr->push_back(aval.release()); return aarr.release();}
virtual JsonArray* arrayNote(JsonArray* arr) { return arr;}
- virtual JsonValue* arrayCreateElement(JsonValue* val) { std::auto_ptr<JsonValue> aval(val); return aval.release();}
+ virtual JsonValue* arrayCreateElement(JsonValue* val) { SMART_OWNED_PTR<JsonValue> aval(val); return aval.release();}
- virtual JsonValue* valueParseMap(JsonMap* map) { std::auto_ptr<JsonMap> amap(map); return new JsonMapItem(amap);}
- virtual JsonValue* valueParseArray(JsonArray* arr) { std::auto_ptr<JsonArray> aarr(arr); return new JsonArrayItem(aarr);}
- virtual JsonValue* valueParseString(std::string* str) { std::auto_ptr<std::string> astr(str); return new JsonStringItem(astr);}
- virtual JsonValue* valueParseNumber(std::string* num) { std::auto_ptr<std::string> anum(num); return new JsonNumberItem(anum);}
+ virtual JsonValue* valueParseMap(JsonMap* map) { SMART_OWNED_PTR<JsonMap> amap(map); return new JsonMapItem(amap);}
+ virtual JsonValue* valueParseArray(JsonArray* arr) { SMART_OWNED_PTR<JsonArray> aarr(arr); return new JsonArrayItem(aarr);}
+ virtual JsonValue* valueParseString(std::string* str) { SMART_OWNED_PTR<std::string> astr(str); return new JsonStringItem(astr);}
+ virtual JsonValue* valueParseNumber(std::string* num) { SMART_OWNED_PTR<std::string> anum(num); return new JsonNumberItem(anum);}
virtual JsonValue* valueParseBool(bool value) { return new JsonBoolItem(value);}
virtual JsonValue* valueParseNULL() { return new JsonNULLItem();}
View
28 Json/ParserRecursive.cpp
@@ -10,12 +10,12 @@ int ParserRecursive::error(int /*val*/, std::string const& msg)
throw ThorsAnvil::Json::ParsingError(msg);
}
-int ParserRecursive::JsonValueParse(int val, std::auto_ptr<JsonValue>& value)
+int ParserRecursive::JsonValueParse(int val, SMART_OWNED_PTR<JsonValue>& value)
{
switch(val)
{
case '{': {
- std::auto_ptr<JsonMap> map;
+ SMART_OWNED_PTR<JsonMap> map;
int result = JsonMapParse(yylex(), map);
if (result == 0)
{ value.reset(pi.valueParseMap(map.release()));
@@ -23,7 +23,7 @@ int ParserRecursive::JsonValueParse(int val, std::auto_ptr<JsonValue>& value)
return result;
}
case '[': {
- std::auto_ptr<JsonArray> array;
+ SMART_OWNED_PTR<JsonArray> array;
int result = JsonArrayParse(yylex(), array);
if (result == 0)
{ value.reset(pi.valueParseArray(array.release()));
@@ -39,18 +39,18 @@ int ParserRecursive::JsonValueParse(int val, std::auto_ptr<JsonValue>& value)
}
return error(val, "syntax error");
}
-int ParserRecursive::JsonMapValueListParse(int val, std::auto_ptr<JsonMap>& map)
+int ParserRecursive::JsonMapValueListParse(int val, SMART_OWNED_PTR<JsonMap>& map)
{
if (val == yy::ParserShiftReduce::token::JSON_STRING)
{
- std::auto_ptr<std::string> key(pi.getStringLexer(lexer));
+ SMART_OWNED_PTR<std::string> key(pi.getStringLexer(lexer));
if ((val = yylex()) == ':')
{
key.reset(pi.mapKeyNote(key.release()));
- std::auto_ptr<JsonValue> value;
+ SMART_OWNED_PTR<JsonValue> value;
if ((val = JsonValueParse(yylex(), value)) == 0)
{
- std::auto_ptr<JsonMapValue> mapValue(pi.mapCreateElement(key.release(), value.release()));
+ SMART_OWNED_PTR<JsonMapValue> mapValue(pi.mapCreateElement(key.release(), value.release()));
if (map.get() == NULL)
{
map.reset(pi.mapCreate(mapValue.release()));
@@ -72,9 +72,9 @@ int ParserRecursive::JsonMapValueListParse(int val, std::auto_ptr<JsonMap>& map)
return error(val, "syntax error");
}
-int ParserRecursive::JsonArrayValueListParse(int val, std::auto_ptr<JsonArray>& array)
+int ParserRecursive::JsonArrayValueListParse(int val, SMART_OWNED_PTR<JsonArray>& array)
{
- std::auto_ptr<JsonValue> value;
+ SMART_OWNED_PTR<JsonValue> value;
if ((val = JsonValueParse(val, value)) == 0)
{
value.reset(pi.arrayCreateElement(value.release()));
@@ -96,7 +96,7 @@ int ParserRecursive::JsonArrayValueListParse(int val, std::auto_ptr<JsonArray>&
}
return error(val, "syntax error");
}
-int ParserRecursive::JsonMapParse(int val, std::auto_ptr<JsonMap>& map)
+int ParserRecursive::JsonMapParse(int val, SMART_OWNED_PTR<JsonMap>& map)
{
pi.mapOpen();
int result;
@@ -112,7 +112,7 @@ int ParserRecursive::JsonMapParse(int val, std::auto_ptr<JsonMap>& map)
pi.mapClose();
return result;
}
-int ParserRecursive::JsonArrayParse(int val, std::auto_ptr<JsonArray>& array)
+int ParserRecursive::JsonArrayParse(int val, SMART_OWNED_PTR<JsonArray>& array)
{
pi.arrayOpen();
int result;
@@ -130,9 +130,9 @@ int ParserRecursive::JsonArrayParse(int val, std::auto_ptr<JsonArray>& array)
}
int ParserRecursive::parseJosnObject(int val)
{
- int result;
- std::auto_ptr<JsonMap> map;
- std::auto_ptr<JsonArray> array;
+ int result;
+ SMART_OWNED_PTR<JsonMap> map;
+ SMART_OWNED_PTR<JsonArray> array;
switch(val)
{
case '{': result = JsonMapParse(yylex(), map); pi.doneMap(map.release()); return result;
View
10 Json/ParserRecursive.h
@@ -18,11 +18,11 @@ class ParserRecursive
LexerJson& lexer;
ParserInterface& pi;
- int JsonValueParse(int val, std::auto_ptr<JsonValue>& value);
- int JsonMapValueListParse(int val, std::auto_ptr<JsonMap>& ma);
- int JsonArrayValueListParse(int val, std::auto_ptr<JsonArray>& array);
- int JsonMapParse(int val, std::auto_ptr<JsonMap>& map);
- int JsonArrayParse(int val, std::auto_ptr<JsonArray>& array);
+ int JsonValueParse(int val, SMART_OWNED_PTR<JsonValue>& value);
+ int JsonMapValueListParse(int val, SMART_OWNED_PTR<JsonMap>& ma);
+ int JsonArrayValueListParse(int val, SMART_OWNED_PTR<JsonArray>& array);
+ int JsonMapParse(int val, SMART_OWNED_PTR<JsonMap>& map);
+ int JsonArrayParse(int val, SMART_OWNED_PTR<JsonArray>& array);
int parseJosnObject(int val);
int yylex() { return lexer.yylex(pi);}
View
8 Json/ScannerDom.cpp
@@ -8,11 +8,11 @@ using namespace ThorsAnvil::Json;
class ScannerDomInterface: public ParserDomInterface
{
- JsonObjectType& objectTypeRef;
- std::auto_ptr<JsonMap>& mapRef;
- std::auto_ptr<JsonArray>& arrayRef;
+ JsonObjectType& objectTypeRef;
+ SMART_OWNED_PTR<JsonMap>& mapRef;
+ SMART_OWNED_PTR<JsonArray>& arrayRef;
public:
- ScannerDomInterface(JsonObjectType& objectType, std::auto_ptr<JsonMap>& map, std::auto_ptr<JsonArray>& array)
+ ScannerDomInterface(JsonObjectType& objectType, SMART_OWNED_PTR<JsonMap>& map, SMART_OWNED_PTR<JsonArray>& array)
: objectTypeRef(objectType)
, mapRef(map)
, arrayRef(array)
View
10 Json/ScannerDom.h
@@ -12,15 +12,15 @@ namespace ThorsAnvil
class ScannerDom
{
- std::auto_ptr<JsonMap> map;
- std::auto_ptr<JsonArray> array;
- JsonObjectType objectType;
+ SMART_OWNED_PTR<JsonMap> map;
+ SMART_OWNED_PTR<JsonArray> array;
+ JsonObjectType objectType;
public:
template<typename Parser>
JsonObjectType parse(std::istream& stream);
- std::auto_ptr<JsonMap>& getMap() { return map;}
- std::auto_ptr<JsonArray>& getArray() { return array;}
+ SMART_OWNED_PTR<JsonMap>& getMap() { return map;}
+ SMART_OWNED_PTR<JsonArray>& getArray() { return array;}
};
}
}
View
40 Json/ScannerSax.cpp
@@ -21,18 +21,18 @@ class ScannerSaxInterface: public ParserCleanInterface
ScannerSaxInterface(ScannerSax& p): parent(p) {}
virtual void mapOpen() { parent.push_mapAction();}
virtual void mapClose() { parent.pop_mapAction();}
- virtual std::string* mapKeyNote(std::string* k) { std::auto_ptr<std::string> ak(k); parent.preActivate(*ak); return ak.release();}
- virtual JsonMapValue* mapCreateElement(std::string* k,JsonValue* val) { std::auto_ptr<std::string> ak(k); std::auto_ptr<JsonValue> aval(val); parent.activate(*ak, *aval); return NULL;}
+ virtual std::string* mapKeyNote(std::string* k) { SMART_OWNED_PTR<std::string> ak(k); parent.preActivate(*ak); return ak.release();}
+ virtual JsonMapValue* mapCreateElement(std::string* k,JsonValue* val) { SMART_OWNED_PTR<std::string> ak(k); SMART_OWNED_PTR<JsonValue> aval(val); parent.activate(*ak, *aval); return NULL;}
virtual void arrayOpen() { currentArrayIndex.push_front(0); parent.push_arrAction(); parent.preActivate(currentArrayIndex.front());}
virtual void arrayClose() { currentArrayIndex.pop_front(); parent.pop_arrAction();}
- virtual JsonArray* arrayNote(JsonArray* arr) { std::auto_ptr<JsonArray> aarr(arr); parent.preActivate(currentArrayIndex.front());return NULL;}
- virtual JsonValue* arrayCreateElement(JsonValue* val) { std::auto_ptr<JsonValue> aval(val); parent.activate(currentArrayIndex.front()++, *aval);return NULL;}
- virtual JsonValue* valueParseString(std::string* str) { std::auto_ptr<std::string> astr(str); return new JsonStringItem(astr);}
- virtual JsonValue* valueParseNumber(std::string* num) { std::auto_ptr<std::string> anum(num); return new JsonNumberItem(anum);}
- virtual JsonValue* valueParseBool(bool val) { return new JsonBoolItem(val);}
- virtual JsonValue* valueParseNULL() { return new JsonNULLItem();}
- virtual std::string* getStringLexer(LexerJson& lexer) { return new std::string(getString(lexer));}
- virtual std::string* getNumberLexer(LexerJson& lexer) { return new std::string(getNumber(lexer));}
+ virtual JsonArray* arrayNote(JsonArray* arr) { SMART_OWNED_PTR<JsonArray> aarr(arr); parent.preActivate(currentArrayIndex.front());return NULL;}
+ virtual JsonValue* arrayCreateElement(JsonValue* val) { SMART_OWNED_PTR<JsonValue> aval(val); parent.activate(currentArrayIndex.front()++, *aval);return NULL;}
+ virtual JsonValue* valueParseString(std::string* str) { SMART_OWNED_PTR<std::string> astr(str); return new JsonStringItem(astr);}
+ virtual JsonValue* valueParseNumber(std::string* num) { SMART_OWNED_PTR<std::string> anum(num); return new JsonNumberItem(anum);}
+ virtual JsonValue* valueParseBool(bool val) { return new JsonBoolItem(val);}
+ virtual JsonValue* valueParseNULL() { return new JsonNULLItem();}
+ virtual std::string* getStringLexer(LexerJson& lexer) { return new std::string(getString(lexer));}
+ virtual std::string* getNumberLexer(LexerJson& lexer) { return new std::string(getNumber(lexer));}
};
}
}
@@ -63,40 +63,40 @@ void ScannerSax::parse(std::istream& src)
parser.parse();
}
-ActionRefNote ScannerSax::registerActionOnAllMapItems(std::auto_ptr<SaxAction> action)
+ActionRefNote ScannerSax::registerActionOnAllMapItems(SMART_OWNED_PTR<SaxAction> action)
{
// \xFF is an invalid UTF-8 character
// The parser will never generate mapItem of this string
- return registerAction("\xFF", action);
+ return registerAction("\xFF", SMART_OWNED_MOVE(action));
}
-ActionRefNote ScannerSax::registerAction(std::string const& mapItem, std::auto_ptr<SaxAction> action)
+ActionRefNote ScannerSax::registerAction(std::string const& mapItem, SMART_OWNED_PTR<SaxAction> action)
{
SaxAction*& location = mapActions.front()[mapItem];
- std::auto_ptr<SaxAction> oldLocation(location);
+ SMART_OWNED_PTR<SaxAction> oldLocation(location);
location = action.release();
return &location;
}
-ActionRefNote ScannerSax::registerActionOnAllArrItems(std::auto_ptr<SaxAction> action)
+ActionRefNote ScannerSax::registerActionOnAllArrItems(SMART_OWNED_PTR<SaxAction> action)
{
SaxAction*& location = arrActions.front().map[-1];
- std::auto_ptr<SaxAction> oldLocation(location);
+ SMART_OWNED_PTR<SaxAction> oldLocation(location);
location = action.release();
return &location;
}
-ActionRefNote ScannerSax::registerActionNext(std::auto_ptr<SaxAction> action)
+ActionRefNote ScannerSax::registerActionNext(SMART_OWNED_PTR<SaxAction> action)
{
int index = arrActions.front().max++;
SaxAction*& location = arrActions.front().map[index];
- std::auto_ptr<SaxAction> oldLocation(location);
+ SMART_OWNED_PTR<SaxAction> oldLocation(location);
location = action.release();
return &location;
}
-void ScannerSax::replaceAction(ActionRefNote oldActionRef, std::auto_ptr<SaxAction> action)
+void ScannerSax::replaceAction(ActionRefNote oldActionRef, SMART_OWNED_PTR<SaxAction> action)
{
SaxAction*& location = *reinterpret_cast<SaxAction**>(oldActionRef);
- std::auto_ptr<SaxAction> oldLocation(location);
+ SMART_OWNED_PTR<SaxAction> oldLocation(location);
location = action.release();
}
View
10 Json/ScannerSax.h
@@ -86,11 +86,11 @@ class ScannerSax
ScannerSax();
template<typename Parser>
void parse(std::istream& src);
- ActionRefNote registerAction(std::string const& mapItem, std::auto_ptr<SaxAction> action);
- ActionRefNote registerActionNext(std::auto_ptr<SaxAction> action);
- ActionRefNote registerActionOnAllMapItems(std::auto_ptr<SaxAction> action);
- ActionRefNote registerActionOnAllArrItems(std::auto_ptr<SaxAction> action);
- void replaceAction(ActionRefNote oldActionRef, std::auto_ptr<SaxAction> action);
+ ActionRefNote registerAction(std::string const& mapItem, SMART_OWNED_PTR<SaxAction> action);
+ ActionRefNote registerActionNext(SMART_OWNED_PTR<SaxAction> action);
+ ActionRefNote registerActionOnAllMapItems(SMART_OWNED_PTR<SaxAction> action);
+ ActionRefNote registerActionOnAllArrItems(SMART_OWNED_PTR<SaxAction> action);
+ void replaceAction(ActionRefNote oldActionRef, SMART_OWNED_PTR<SaxAction> action);
private:
friend class ScannerSaxInterface;
View
28 Json/test/JsonUtilTest.cpp
@@ -14,11 +14,11 @@ TEST(JsonUtil, MergeArrays)
std::stringstream data1("[1, 2, 3, 4]");
scanner.parse<yy::ParserShiftReduce>(data1);
- std::auto_ptr<JsonArray> array1 = scanner.getArray();
+ SMART_OWNED_PTR<JsonArray> array1 = SMART_OWNED_MOVE(scanner.getArray());
std::stringstream data2("[1, 2, 3, 4]");
scanner.parse<yy::ParserShiftReduce>(data2);
- std::auto_ptr<JsonArray> array2 = scanner.getArray();
+ SMART_OWNED_PTR<JsonArray> array2 = SMART_OWNED_MOVE(scanner.getArray());
mergeJsonDom(*array1, *array2, "Test");
EXPECT_EQ(8, array1->size());
@@ -31,11 +31,11 @@ TEST(JsonUtil, MergeMaps)
std::stringstream data1("{ \"item1\": 1, \"item2\": 2, \"item3\": 3, \"item4\": 4}");
scanner.parse<yy::ParserShiftReduce>(data1);
- std::auto_ptr<JsonMap> map1 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map1 = SMART_OWNED_MOVE(scanner.getMap());
std::stringstream data2("{ \"item5\": 1, \"item6\": 2, \"item7\": 3, \"item8\": 4}");
scanner.parse<yy::ParserShiftReduce>(data2);
- std::auto_ptr<JsonMap> map2 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map2 = SMART_OWNED_MOVE(scanner.getMap());
mergeJsonDom(*map1, *map2, "Test");
EXPECT_EQ(8, map1->size());
@@ -48,11 +48,11 @@ TEST(JsonUtil, OverwiteMapPODElement)
std::stringstream data1("{ \"item1\": 4}");
scanner.parse<yy::ParserShiftReduce>(data1);
- std::auto_ptr<JsonMap> map1 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map1 = SMART_OWNED_MOVE(scanner.getMap());
std::stringstream data2("{ \"item1\": 5}");
scanner.parse<yy::ParserShiftReduce>(data2);
- std::auto_ptr<JsonMap> map2 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map2 = SMART_OWNED_MOVE(scanner.getMap());
mergeJsonDom(*map1, *map2, "Test");
EXPECT_EQ(1, map1->size());
@@ -66,11 +66,11 @@ TEST(JsonUtil, OverwiteMapElement)
std::stringstream data1("{ \"item1\": {\"t1\": 9}}");
scanner.parse<yy::ParserShiftReduce>(data1);
- std::auto_ptr<JsonMap> map1 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map1 = SMART_OWNED_MOVE(scanner.getMap());
std::stringstream data2("{ \"item1\": {\"t2\": 15}}");
scanner.parse<yy::ParserShiftReduce>(data2);
- std::auto_ptr<JsonMap> map2 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map2 = SMART_OWNED_MOVE(scanner.getMap());
mergeJsonDom(*map1, *map2, "Test");
EXPECT_EQ(1, map1->size());
@@ -87,11 +87,11 @@ TEST(JsonUtil, AddElementsToArrayInMap)
std::stringstream data1("{ \"item1\": [ 1, 2, 3 ]}");
scanner.parse<yy::ParserShiftReduce>(data1);
- std::auto_ptr<JsonMap> map1 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map1 = SMART_OWNED_MOVE(scanner.getMap());
std::stringstream data2("{ \"item1\": {\"item5\": 34}}");
scanner.parse<yy::ParserShiftReduce>(data2);
- std::auto_ptr<JsonMap> map2 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map2 = SMART_OWNED_MOVE(scanner.getMap());
mergeJsonDom(*map1, *map2, "Test");
EXPECT_EQ(1, map1->size());
@@ -107,11 +107,11 @@ TEST(JsonUtil, AddArrayToArrayInMap)
std::stringstream data1("{ \"item1\": [ 1, 2, 3 ]}");
scanner.parse<yy::ParserShiftReduce>(data1);
- std::auto_ptr<JsonMap> map1 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map1 = SMART_OWNED_MOVE(scanner.getMap());
std::stringstream data2("{ \"item1\": [ 4, 5, {\"plop\": 8}]}");
scanner.parse<yy::ParserShiftReduce>(data2);
- std::auto_ptr<JsonMap> map2 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map2 = SMART_OWNED_MOVE(scanner.getMap());
mergeJsonDom(*map1, *map2, "Test");
EXPECT_EQ(1, map1->size());
@@ -127,11 +127,11 @@ TEST(JsonUtil, MergeNonMapIntoMap)
std::stringstream data1("{ \"item1\": {\"plop\": 1}}");
scanner.parse<yy::ParserShiftReduce>(data1);
- std::auto_ptr<JsonMap> map1 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map1 = SMART_OWNED_MOVE(scanner.getMap());
std::stringstream data2("{ \"item1\": 12}");
scanner.parse<yy::ParserShiftReduce>(data2);
- std::auto_ptr<JsonMap> map2 = scanner.getMap();
+ SMART_OWNED_PTR<JsonMap> map2 = SMART_OWNED_MOVE(scanner.getMap());
ASSERT_THROW(mergeJsonDom(*map1, *map2, "Test"), std::runtime_error);
}
View
16 Json/test/ScannerDomTest.cpp
@@ -13,7 +13,7 @@ TEST(ScannerDom, ShiftReduceScanMapEmpty)
ASSERT_TRUE(scanner.parse<yy::ParserShiftReduce>(json) == ThorsAnvil::Json::JsonMapObject);
- std::auto_ptr<ThorsAnvil::Json::JsonMap>& map = scanner.getMap();
+ SMART_OWNED_PTR<ThorsAnvil::Json::JsonMap>& map = scanner.getMap();
ASSERT_TRUE(map.get() != NULL);
}
@@ -24,7 +24,7 @@ TEST(ScannerDom, ShiftReduceScanArrayEmpty)
ASSERT_TRUE(scanner.parse<yy::ParserShiftReduce>(json) == ThorsAnvil::Json::JsonArrayObject);
- std::auto_ptr<ThorsAnvil::Json::JsonArray>& array = scanner.getArray();
+ SMART_OWNED_PTR<ThorsAnvil::Json::JsonArray>& array = scanner.getArray();
ASSERT_TRUE(array.get() != NULL);
}
@@ -35,7 +35,7 @@ TEST(ScannerDom, RecursiveScanMapEmpty)
ASSERT_TRUE(scanner.parse<ThorsAnvil::Json::ParserRecursive>(json) == ThorsAnvil::Json::JsonMapObject);
- std::auto_ptr<ThorsAnvil::Json::JsonMap>& map = scanner.getMap();
+ SMART_OWNED_PTR<ThorsAnvil::Json::JsonMap>& map = scanner.getMap();
ASSERT_TRUE(map.get() != NULL);
}
@@ -46,7 +46,7 @@ TEST(ScannerDom, RecursiveScanArrayEmpty)
ASSERT_TRUE(scanner.parse<ThorsAnvil::Json::ParserRecursive>(json) == ThorsAnvil::Json::JsonArrayObject);
- std::auto_ptr<ThorsAnvil::Json::JsonArray>& array = scanner.getArray();
+ SMART_OWNED_PTR<ThorsAnvil::Json::JsonArray>& array = scanner.getArray();
ASSERT_TRUE(array.get() != NULL);
}
@@ -58,7 +58,7 @@ TEST(ScannerDom, ShiftReduceScanMap)
ASSERT_TRUE(scanner.parse<yy::ParserShiftReduce>(json) == ThorsAnvil::Json::JsonMapObject);
- std::auto_ptr<ThorsAnvil::Json::JsonMap>& map = scanner.getMap();
+ SMART_OWNED_PTR<ThorsAnvil::Json::JsonMap>& map = scanner.getMap();
ASSERT_TRUE(map.get() != NULL);
}
@@ -69,7 +69,7 @@ TEST(ScannerDom, ShiftReduceScanArray)
ASSERT_TRUE(scanner.parse<yy::ParserShiftReduce>(json) == ThorsAnvil::Json::JsonArrayObject);
- std::auto_ptr<ThorsAnvil::Json::JsonArray>& array = scanner.getArray();
+ SMART_OWNED_PTR<ThorsAnvil::Json::JsonArray>& array = scanner.getArray();
ASSERT_TRUE(array.get() != NULL);
}
@@ -80,7 +80,7 @@ TEST(ScannerDom, RecursiveScanMap)
ASSERT_TRUE(scanner.parse<ThorsAnvil::Json::ParserRecursive>(json) == ThorsAnvil::Json::JsonMapObject);
- std::auto_ptr<ThorsAnvil::Json::JsonMap>& map = scanner.getMap();
+ SMART_OWNED_PTR<ThorsAnvil::Json::JsonMap>& map = scanner.getMap();
ASSERT_TRUE(map.get() != NULL);
}
@@ -91,7 +91,7 @@ TEST(ScannerDom, RecursiveScanArray)
ASSERT_TRUE(scanner.parse<ThorsAnvil::Json::ParserRecursive>(json) == ThorsAnvil::Json::JsonArrayObject);
- std::auto_ptr<ThorsAnvil::Json::JsonArray>& array = scanner.getArray();
+ SMART_OWNED_PTR<ThorsAnvil::Json::JsonArray>& array = scanner.getArray();
ASSERT_TRUE(array.get() != NULL);
}
View
92 Json/test/ScannerSaxTest.cpp
@@ -39,11 +39,11 @@ TEST(ScannerSax, ShiftReduceScanMapEmpty)
bool preAction;
bool action;
int value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
std::stringstream json("{}");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerAction("I1", saxAction);
+ scanner.registerAction("I1", SMART_OWNED_MOVE(saxAction));
scanner.parse<yy::ParserShiftReduce>(json);
ASSERT_TRUE(count == 0);
@@ -57,11 +57,11 @@ TEST(ScannerSax, ShiftReduceScanMapMiss)
bool preAction;
bool action;
int value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
std::stringstream json("{ \"I2\" : 1}");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerAction("I1", saxAction);
+ scanner.registerAction("I1", SMART_OWNED_MOVE(saxAction));
scanner.parse<yy::ParserShiftReduce>(json);
ASSERT_TRUE(count == 0);
@@ -75,11 +75,11 @@ TEST(ScannerSax, ShiftReduceScanMapHit)
bool preAction;
bool action;
int value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
std::stringstream json("{ \"I1\" : 123}");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerAction("I1", saxAction);
+ scanner.registerAction("I1", SMART_OWNED_MOVE(saxAction));
scanner.parse<yy::ParserShiftReduce>(json);
ASSERT_TRUE(count == 1);
@@ -94,11 +94,11 @@ TEST(ScannerSax, ShiftReduceScanArrayEmpty)
bool preAction;
bool action;
bool value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
std::stringstream json("[]");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerAction("I1", saxAction);
+ scanner.registerAction("I1", SMART_OWNED_MOVE(saxAction));
scanner.parse<yy::ParserShiftReduce>(json);
ASSERT_TRUE(count == 0);
@@ -112,14 +112,14 @@ TEST(ScannerSax, ShiftReduceScanArrayMiss)
bool preAction;
bool action;
bool value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> emptyAction;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> emptyAction;
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
std::stringstream json("[ true ]");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerActionNext(emptyAction);
- scanner.registerActionNext(emptyAction);
- scanner.registerActionNext(saxAction);
+ scanner.registerActionNext(SMART_OWNED_MOVE(emptyAction));
+ scanner.registerActionNext(SMART_OWNED_MOVE(emptyAction));
+ scanner.registerActionNext(SMART_OWNED_MOVE(saxAction));
scanner.parse<yy::ParserShiftReduce>(json);
ASSERT_TRUE(preAction == false);
@@ -132,13 +132,13 @@ TEST(ScannerSax, ShiftReduceScanArrayHit)
bool preAction;
bool action;
bool value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> emptyAction;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> emptyAction;
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
std::stringstream json("[ 512, true ]");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerActionNext(emptyAction);
- scanner.registerActionNext(saxAction);
+ scanner.registerActionNext(SMART_OWNED_MOVE(emptyAction));
+ scanner.registerActionNext(SMART_OWNED_MOVE(saxAction));
scanner.parse<yy::ParserShiftReduce>(json);
ASSERT_TRUE(count == 1);
@@ -154,11 +154,11 @@ TEST(ScannerSax, RecursiveScanMapEmpty)
bool preAction;
bool action;
std::string value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<std::string>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<std::string>(count, preAction, action, value));
std::stringstream json("{}");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerAction("I1", saxAction);
+ scanner.registerAction("I1", SMART_OWNED_MOVE(saxAction));
scanner.parse<ThorsAnvil::Json::ParserRecursive>(json);
ASSERT_TRUE(count == 0);
@@ -172,11 +172,11 @@ TEST(ScannerSax, RecursiveScanMapMiss)
bool preAction;
bool action;
std::string value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<std::string>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<std::string>(count, preAction, action, value));
std::stringstream json("{ \"I2\" : \"S1\"}");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerAction("I1", saxAction);
+ scanner.registerAction("I1", SMART_OWNED_MOVE(saxAction));
scanner.parse<ThorsAnvil::Json::ParserRecursive>(json);
ASSERT_TRUE(count == 0);
@@ -190,11 +190,11 @@ TEST(ScannerSax, RecursiveScanMapHit)
bool preAction;
bool action;
std::string value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<std::string>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<std::string>(count, preAction, action, value));
std::stringstream json("{ \"I1\" : \"123SS\"}");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerAction("I1", saxAction);
+ scanner.registerAction("I1", SMART_OWNED_MOVE(saxAction));
scanner.parse<ThorsAnvil::Json::ParserRecursive>(json);
ASSERT_TRUE(count == 1);
@@ -209,11 +209,11 @@ TEST(ScannerSax, RecursiveScanArrayEmpty)
bool preAction;
bool action;
bool value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
std::stringstream json("[]");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerAction("I1", saxAction);
+ scanner.registerAction("I1", SMART_OWNED_MOVE(saxAction));
scanner.parse<ThorsAnvil::Json::ParserRecursive>(json);
ASSERT_TRUE(count == 0);
@@ -227,14 +227,14 @@ TEST(ScannerSax, RecursiveScanArrayMiss)
bool preAction;
bool action;
bool value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> emptyAction;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> emptyAction;
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
std::stringstream json("[ false ]");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerActionNext(emptyAction);
- scanner.registerActionNext(emptyAction);
- scanner.registerActionNext(saxAction);
+ scanner.registerActionNext(SMART_OWNED_MOVE(emptyAction));
+ scanner.registerActionNext(SMART_OWNED_MOVE(emptyAction));
+ scanner.registerActionNext(SMART_OWNED_MOVE(saxAction));
scanner.parse<ThorsAnvil::Json::ParserRecursive>(json);
ASSERT_TRUE(count == 0);
@@ -248,13 +248,13 @@ TEST(ScannerSax, RecursiveScanArrayHit)
bool preAction;
bool action;
bool value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> emptyAction;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> emptyAction;
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
std::stringstream json("[ 512, false ]");
ThorsAnvil::Json::ScannerSax scanner;
- scanner.registerActionNext(emptyAction);
- scanner.registerActionNext(saxAction);
+ scanner.registerActionNext(SMART_OWNED_MOVE(emptyAction));
+ scanner.registerActionNext(SMART_OWNED_MOVE(saxAction));
scanner.parse<ThorsAnvil::Json::ParserRecursive>(json);
ASSERT_TRUE(count == 1);
@@ -269,22 +269,22 @@ TEST(ScannerSax, ReplaceAction)
bool preAction;
bool action;
int value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
int count2;
bool preAction2;
bool action2;
int value2;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction2(new TestAction<int>(count2, preAction2, action2, value2));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction2(new TestAction<int>(count2, preAction2, action2, value2));
ThorsAnvil::Json::ScannerSax scanner;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> emptyAction;
- scanner.registerActionNext(emptyAction);
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> emptyAction;
+ scanner.registerActionNext(SMART_OWNED_MOVE(emptyAction));
- ThorsAnvil::Json::ActionRefNote actNote = scanner.registerActionNext(saxAction);
- scanner.replaceAction(actNote, saxAction2);
+ ThorsAnvil::Json::ActionRefNote actNote = scanner.registerActionNext(SMART_OWNED_MOVE(saxAction));
+ scanner.replaceAction(actNote, SMART_OWNED_MOVE(saxAction2));
std::stringstream json("[ 512, 567 ]");
scanner.parse<ThorsAnvil::Json::ParserRecursive>(json);
@@ -304,12 +304,12 @@ TEST(ScannerSax, DefaultArrayAction)
bool preAction;
bool action;
int value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
ThorsAnvil::Json::ScannerSax scanner;
- ThorsAnvil::Json::ActionRefNote actNote = scanner.registerActionOnAllArrItems(saxAction);
+ ThorsAnvil::Json::ActionRefNote actNote = scanner.registerActionOnAllArrItems(SMART_OWNED_MOVE(saxAction));
std::stringstream json("[ 512, 567 ]");
scanner.parse<ThorsAnvil::Json::ParserRecursive>(json);
@@ -326,12 +326,12 @@ TEST(ScannerSax, DefaultMapAction)
bool preAction;
bool action;
int value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<int>(count, preAction, action, value));
ThorsAnvil::Json::ScannerSax scanner;
- ThorsAnvil::Json::ActionRefNote actNote = scanner.registerAction("\xFF", saxAction);
+ ThorsAnvil::Json::ActionRefNote actNote = scanner.registerAction("\xFF", SMART_OWNED_MOVE(saxAction));
std::stringstream json("{ \"I1\": 512, \"I2\": 567 }");
scanner.parse<ThorsAnvil::Json::ParserRecursive>(json);
@@ -348,12 +348,12 @@ TEST(ScannerSax, GetNullValue)
bool preAction;
bool action;
bool value;
- std::auto_ptr<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> saxAction(new TestAction<bool>(count, preAction, action, value));
ThorsAnvil::Json::ScannerSax scanner;
- ThorsAnvil::Json::ActionRefNote actNote = scanner.registerAction("I1", saxAction);
+ ThorsAnvil::Json::ActionRefNote actNote = scanner.registerAction("I1", SMART_OWNED_MOVE(saxAction));
std::stringstream json("{ \"I1\": null}");
scanner.parse<ThorsAnvil::Json::ParserRecursive>(json);
View
20 Serialize/JsonSerializer.h
@@ -211,8 +211,8 @@ class MPLForEachActivateItem
template<typename SerializeItem>
void operator()(SerializeItem const& item) const
{
- typedef typename boost::mpl::at_c<typename SerializeItem::SerializeType, Traits::SerializeActionIndex>::type SerializeAction;
- SerializeAction::activate(item, pump, object);
+ typedef typename boost::mpl::at_c<typename SerializeItem::SerializeType, Traits::SerializeActionIndex>::type SerializAction;
+ SerializAction::activate(item, pump, object);
}
};
@@ -266,8 +266,8 @@ struct JsonDeSerialize<T, A, RegisterKey, Map>
{
static void activate(JsonSerializeItem<T, A, RegisterKey> const& item, ThorsAnvil::Json::ScannerSax& parser, T& dst)
{
- std::auto_ptr<ThorsAnvil::Json::SaxAction> action(item.accessor.action(dst));
- parser.registerAction(item.memberName, action);
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> action(item.accessor.action(dst));
+ parser.registerAction(item.memberName, SMART_OWNED_MOVE(action));
}
};
template<typename T, typename A>
@@ -275,8 +275,8 @@ struct JsonDeSerialize<T, A, int, Array>
{
static void activate(JsonSerializeItem<T, A, int> const& item, ThorsAnvil::Json::ScannerSax& parser, T& dst)
{
- std::auto_ptr<ThorsAnvil::Json::SaxAction> action(item.accessor.action(dst));
- parser.registerActionOnAllArrItems(action);
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> action(item.accessor.action(dst));
+ parser.registerActionOnAllArrItems(SMART_OWNED_MOVE(action));
}
};
@@ -285,8 +285,8 @@ struct JsonDeSerialize<T, A, std::string, Array>
{
static void activate(JsonSerializeItem<T, A, std::string> const& item, ThorsAnvil::Json::ScannerSax& parser, T& dst)
{
- std::auto_ptr<ThorsAnvil::Json::SaxAction> action(item.accessor.action(dst));
- parser.registerActionNext(action);
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> action(item.accessor.action(dst));
+ parser.registerActionNext(SMART_OWNED_MOVE(action));
}
};
@@ -563,9 +563,9 @@ class JsonSerialElementAccessor
{
stream << jsonInternalExport(src.*memberPtr);
}
- std::auto_ptr<ThorsAnvil::Json::SaxAction> action(T& dst) const
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> action(T& dst) const
{
- std::auto_ptr<ThorsAnvil::Json::SaxAction> action(new_JsonImportAction<typename SerTraits::SerializeInfo>(dst, memberPtr));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> action(new_JsonImportAction<typename SerTraits::SerializeInfo>(dst, memberPtr));
return action;
}
};
View
6 Serialize/JsonSerializerContainer.h
@@ -87,7 +87,7 @@ class JsonContainerImportAction<SerializeInfo, C, false, false>: public ThorsAnv
: destination(dst)
{}
- virtual void doPreAction(ThorsAnvil::Json::ScannerSax& parser, ThorsAnvil::Json::Key const& key)
+ virtual void doPreAction(ThorsAnvil::Json::ScannerSax& parser, ThorsAnvil::Json::Key const& /*key*/)
{
destination.push_back(DataType());
boost::mpl::for_each<typename JsonSerializeTraits<DataType>::SerializeInfo>(MPLForEachActivateItem<DataType, ThorsAnvil::Json::ScannerSax>(parser, destination.back()));
@@ -143,9 +143,9 @@ class JsonContainerAttributeAccessor
}
}
}
- std::auto_ptr<ThorsAnvil::Json::SaxAction> action(C& dst) const
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> action(C& dst) const
{
- std::auto_ptr<ThorsAnvil::Json::SaxAction> action(new_JsonImportAction<typename JsonSerializeTraits<typename ContainerTraits<C>::DataType>::SerializeInfo>(dst));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> action(new_JsonImportAction<typename JsonSerializeTraits<typename ContainerTraits<C>::DataType>::SerializeInfo>(dst));
return action;
}
};
View
4 Serialize/JsonSerializerMap.h
@@ -75,9 +75,9 @@ class JsonContainerAttributeAccessor<std::map<std::string, V> >
}
}
}
- std::auto_ptr<ThorsAnvil::Json::SaxAction> action(std::map<std::string,V>& dst) const
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> action(std::map<std::string,V>& dst) const
{
- std::auto_ptr<ThorsAnvil::Json::SaxAction> action(new_JsonImportAction<typename JsonSerializeTraits<V>::SerializeInfo>(dst));
+ SMART_OWNED_PTR<ThorsAnvil::Json::SaxAction> action(new_JsonImportAction<typename JsonSerializeTraits<V>::SerializeInfo>(dst));
return action;
}
};
View
33 build/tools/Makefile
@@ -60,6 +60,7 @@ INSTALL_HEADER = $(if $(filter %.slib, $(TARGET)), $(patsubst %, install_head
#
# Set to On to see debug output
+CXXSTDVER ?= 03
VERBOSE ?= Off
TARGET_MODE ?= debug
@@ -107,9 +108,11 @@ OPTIMIZER_FLAGS_debug = -g
OPTIMIZER_FLAGS_release = -O3
OPTIMIZER_FLAGS_coverage = -g -fprofile-arcs -ftest-coverage
+CXXSTDVER_FLAGS_03 =
+CXXSTDVER_FLAGS_11 = -std=c++0x
CC = $(CXX)
-CXXFLAGS += -fPIC $(WARNING_FLAGS) $(THORSANVIL_FLAGS) $(BOOST_FLAGS) $(TEST_FLAGS) $(OPTIMIZER_FLAGS) $(ENVIRONMENT_FLAGS)
+CXXFLAGS += -fPIC $(WARNING_FLAGS) $(THORSANVIL_FLAGS) $(BOOST_FLAGS) $(TEST_FLAGS) $(OPTIMIZER_FLAGS) $(ENVIRONMENT_FLAGS) $(CXXSTDVER_FLAGS_$(CXXSTDVER))
ALL_LDLIBS += $(THORSANVIL_LIBS) $(BOOST_LIBS) $(TEST_LIBS) $(OPTIMIZER_LIBS)
@@ -119,9 +122,11 @@ PREFIX_BIN ?= $(PREFIX)/bin
PREFIX_LIB ?= $(PREFIX)/lib
PREFIX_INC ?= $(PREFIX)/include
PREFIX_INC3RD ?= $(PREFIX)/include3rd
-BUILD_EXTENSION = $(BUILD_EXTENSION_$(TARGET_MODE))
-BUILD_EXTENSION_debug = D
-BUILD_EXTENSION_coverage = D
+BUILD_EXTENSION = $(BUILD_EXTENSION_CXXSTDVER_$(CXXSTDVER))$(BUILD_EXTENSION_TYPE_$(TARGET_MODE))
+BUILD_EXTENSION_CXXSTDVER_03 = 03
+BUILD_EXTENSION_CXXSTDVER_11 = 11
+BUILD_EXTENSION_TYPE_debug = D
+BUILD_EXTENSION_TYPE_coverage = D
#
@@ -139,9 +144,9 @@ install_debug: test try_install_head install_Dodebug
install_release:test try_install_head install_Dorelease
install_Dodebug:
- $(MAKE) PREFIX=$(PREFIX) TARGET_MODE=debug all doInstall
+ $(MAKE) PREFIX=$(PREFIX) CXXSTDVER=$(CXXSTDVER) TARGET_MODE=debug all doInstall
install_Dorelease:
- $(MAKE) PREFIX=$(PREFIX) TARGET_MODE=release all doInstall
+ $(MAKE) PREFIX=$(PREFIX) CXXSTDVER=$(CXXSTDVER) TARGET_MODE=release all doInstall
doInstall: try_install_app try_install_lib
@@ -170,19 +175,19 @@ veryclean: clean test_veryclean
test:
@-$(RM) -rf coverage/libobject.a coverage/*.gcov coverage/*.gcda test/coverage/unittest.app
@echo $(call section_title,Building Objects for Testing and Coverage)
- @$(MAKE) PREFIX=$(PREFIX) TARGET_MODE=coverage objectarch
+ @$(MAKE) PREFIX=$(PREFIX) CXXSTDVER=$(CXXSTDVER) TARGET_MODE=coverage objectarch
@echo $(call section_title,Building Unit Tests)
@touch test/unittest.cpp
- @$(MAKE) PREFIX=$(PREFIX) TARGET_MODE=coverage -C test -f ../Makefile THORSANVIL_ROOT=$(THORSANVIL_ROOT) TEST_STATE=on TARGET=unittest.app LINK_LIBS="$(UNITTEST_LINK_LIBS)"
+ @$(MAKE) PREFIX=$(PREFIX) CXXSTDVER=$(CXXSTDVER) TARGET_MODE=coverage -C test -f ../Makefile THORSANVIL_ROOT=$(THORSANVIL_ROOT) TEST_STATE=on TARGET=unittest.app LINK_LIBS="$(UNITTEST_LINK_LIBS)"
@rm test/unittest.cpp
@echo $(call section_title,Running Unit Tests)
@$(RUNTIME_SHARED_PATH_SET)=$(PREFIX_LIB) test/coverage/unittest.app
@echo
@echo
- @echo $(call colour_text, GRAY, $(MAKE) PREFIX=$(PREFIX) TARGET_MODE=coverage report_coverage COVERAGE=$(COVERAGE))
+ @echo $(call colour_text, GRAY, $(MAKE) PREFIX=$(PREFIX) CXXSTDVER=$(CXXSTDVER) TARGET_MODE=coverage report_coverage COVERAGE=$(COVERAGE))
@echo
@echo
- @$(MAKE) PREFIX=$(PREFIX) TARGET_MODE=coverage coverage COVERAGE=$(COVERAGE)
+ @$(MAKE) PREFIX=$(PREFIX) CXXSTDVER=$(CXXSTDVER) TARGET_MODE=coverage coverage COVERAGE=$(COVERAGE)
install_app_%:
@$(CP) $(TARGET_MODE)/$*.app $(PREFIX_BIN)/$*$(BUILD_EXTENSION)
@@ -197,7 +202,7 @@ install_head_%: $(PREFIX_INC)/$(basename $(filter %.slib, $(TARGET))).Dir
@echo $(call subsection_title, Install Header $*)
test_%:
- @if [ -d test ]; then $(MAKE) -C test -f ../Makefile THORSANVIL_ROOT=$(THORSANVIL_ROOT) PREFIX=$(PREFIX) TEST_STATE=on TARGET=unittest.app $*; fi
+ @if [ -d test ]; then $(MAKE) -C test -f ../Makefile THORSANVIL_ROOT=$(THORSANVIL_ROOT) PREFIX=$(PREFIX) CXXSTDVER=$(CXXSTDVER) TEST_STATE=on TARGET=unittest.app $*; fi
coverage: $(GCOV_REPORT) $(patsubst coverage/%.gcov, report_coverage_%, $(GCOV_REPORT))
@left=`cat $(GCOV_ACTUAL) | grep '####' | wc -l`; \
@@ -205,7 +210,7 @@ coverage: $(GCOV_REPORT) $(patsubst coverage/%.gcov, report_coverage_%, $(GCOV_R
res=`echo "$${left} > ($${right} * 0.2)" | bc`; \
if [ $${res} -ne 0 ]; then \
echo $(RED_ERROR) $(call colour_text, PURPLE, Code Coverage does not exceed 80% of total); \
- echo "Use: '$(MAKE) test PREFIX=$(PREFIX) COVERAGE=On' to get details about coverage"; \
+ echo "Use: '$(MAKE) test PREFIX=$(PREFIX) CXXSTDVER=$(CXXSTDVER) COVERAGE=On' to get details about coverage"; \
exit 1; \
else \
echo $(GREEN_OK) Code Coverage Passed; \
@@ -229,9 +234,9 @@ report_coverage_%.tpp:
@if [ "$(COVERAGE)" = "$*.cpp" ]; then cat coverage/$*.tpp.gcov ; fi
debug:
- @$(MAKE) PREFIX=$(PREFIX) TARGET_MODE=debug all
+ @$(MAKE) PREFIX=$(PREFIX) CXXSTDVER=$(CXXSTDVER) TARGET_MODE=debug all
release:
- @$(MAKE) PREFIX=$(PREFIX) TARGET_MODE=release all
+ @$(MAKE) PREFIX=$(PREFIX) CXXSTDVER=$(CXXSTDVER) TARGET_MODE=release all
buildDir: $(TARGET_MODE).Dir
View
59 third/portability.h
@@ -0,0 +1,59 @@
+
+
+#ifndef THORSANVIL_PORTABILITY_H
+#define THORSANVIL_PORTABILITY_H
+
+
+
+
+#if (__GNUG__ == 4) && (__GNUC_PATCHLEVEL__ == 3) && (__GNUC_MINOR__ == 6)
+
+#define PORTABILITY_TESTED
+
+#if (__GXX_EXPERIMENTAL_CXX0X__ > 0)
+
+#define SMART_OWNED_PTR_TYPE_STD_UNIQUE_PTR 1
+
+#else
+
+#define SMART_OWNED_PTR_TYPE_STD_AUTO_PTR 1
+#error "PLOP"
+
+#endif
+
+#endif
+
+
+
+
+#ifndef PORTABILITY_TESTED
+#error "UNTESTED VERSION: Need to check portability file"
+#endif
+
+#if ((SMART_OWNED_PTR_TYPE_STD_AUTO_PTR + SMART_OWNED_PTR_TYPE_STD_UNIQUE_PTR) == 1)
+#if (SMART_OWNED_PTR_TYPE_STD_AUTO_PTR)
+
+#define SMART_OWNED_PTR std::auto_ptr
+#define SMART_OWNED_MOVE(A) A
+
+#elif (SMART_OWNED_PTR_TYPE_STD_UNIQUE_PTR)
+
+#define SMART_OWNED_PTR std::unique_ptr
+#define SMART_OWNED_MOVE(A) std::move(A)
+
+#endif // SMART_OWNED_PTR_TYPE_STD_AUTO_PTR
+
+#ifndef SMART_OWNED_PTR
+
+#error "Need to define SMART_OWNED_PTR"
+#error "Between C++03 and C++11 std::auto_ptr was deprecated."
+#error "To make code portable use SMART_OWNED_PTR in place of std::auto_ptr"
+
+#endif // SMART_OWNED_PTR
+#endif // ((SMART_OWNED_PTR_TYPE_STD_AUTO_PTR + SMART_OWNED_PTR_TYPE_STD_UNIQUE_PTR) == 1)
+
+
+
+
+#endif // THORSANVIL_PORTABILITY_H
+
View
1  third/setup
@@ -5,6 +5,7 @@ ROOT=`pwd`
cd ../build
mkdir lib bin include include3rd
cd ${ROOT}
+cp portabillity.h ../build/include
# Need this to unpack some of the packages.
# sudo apt-get install unzip
Please sign in to comment.
Something went wrong with that request. Please try again.