Reputation: 10236
I'm using JsonCPP 0.6.0 which doesn't support BOOST_FOREACH
. Robert A. has made a patch to use BOOST_FOREACH
. Here are diff.
Index: value.h
===================================================================
--- value.h (revision 54283)
+++ value.h (working copy)
@@ -919,6 +919,7 @@
class ValueIteratorBase
{
public:
+ typedef std::bidirectional_iterator_tag iterator_category;
typedef unsigned int size_t;
typedef int difference_type;
typedef ValueIteratorBase SelfType;
@@ -990,6 +991,7 @@
{
friend class Value;
public:
+ typedef const Value value_type;
typedef unsigned int size_t;
typedef int difference_type;
typedef const Value &reference;
@@ -1048,6 +1050,7 @@
{
friend class Value;
public:
+ typedef Value value_type;
typedef unsigned int size_t;
typedef int difference_type;
typedef Value &reference;
So I need to add 3 lines in json/include/value.h
, But I don't want to edit original header file but want to add 3 lines in my own source code. something like this:
typedef std::bidirectional_iterator_tag Json::ValueIteratorBase::iterator_category;
Of course I got an error error: typedef name may not be a nested-name-specifier
.
Can I do this?
ps. JsonCPP 0.7.0 supports BOOST_FOREACH
. but in my case, I can't upgrade JsonCPP right now.
Upvotes: 0
Views: 305
Reputation: 753675
Namespaces are open, but class definitions are closed. Once the close brace at the end of the class definition is encountered, the class is complete and you cannot add extra definitions (e.g. extra typedefs) to that class. By contrast, you can add extra information to a namespace after the first time the namespace is closed.
If you can't upgrade to JsonCPP 0.7.0, you must either patch the 0.6.0 header or wait to use the Boost feature until you can upgrade to a version that supports it.
Upvotes: 1