Skip to content

Commit 4fb2256

Browse files
Fix up regression failures.
1 parent d10bdde commit 4fb2256

34 files changed

Lines changed: 569 additions & 307 deletions

classdesc_epilogue.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,8 @@ namespace
6262
#include "RESTProcess_epilogue.h"
6363
#endif
6464

65+
#ifdef CLASSDESC_STRINGKEYMAP_H
66+
#include "stringKeyMap_epilogue.h"
67+
#endif
68+
6569
#endif

createCDs.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ cat >$descriptor-allCDs.h <<EOF
55
#ifndef CLASSDESC_${descriptor}_allCDS_H
66
#define CLASSDESC_${descriptor}_allCDS_H
77
EOF
8+
if [ $descriptor = "json_pack" ]; then
9+
echo "#if defined(__cplusplus) && __cplusplus>=201103L" >>$descriptor-allCDs.h
10+
fi
811
for cdHeader in $*; do
9-
guard=CLASSDESC_`echo $cdHeader|tr [a-z] [A-Z]`_H
12+
guard=CLASSDESC_`echo $cdHeader|tr [a-z] [A-Z]`_H
1013
cat >>$descriptor-allCDs.h <<EOF
1114
#ifdef $guard
1215
#include "$cdHeader-$descriptor.cd"
1316
#endif
1417
EOF
1518
done
19+
if [ $descriptor = "json_pack" ]; then
20+
echo "#endif" >>$descriptor-allCDs.h
21+
fi
1622
echo "#endif" >>$descriptor-allCDs.h

json_pack-allCDs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#ifndef CLASSDESC_json_pack_allCDS_H
22
#define CLASSDESC_json_pack_allCDS_H
3+
#if defined(__cplusplus) && __cplusplus>=201103L
34
#ifdef CLASSDESC_MULTIARRAY_H
45
#include "multiArray-json_pack.cd"
56
#endif
@@ -40,3 +41,4 @@
4041
#include "xml_common-json_pack.cd"
4142
#endif
4243
#endif
44+
#endif

stringKeyMap.h

Lines changed: 2 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#include <map>
1212
#include <string>
1313
#include "classdesc.h"
14+
#if defined(__cplusplus) && __cplusplus>=201103L
1415
#include "json_pack_base.h"
16+
#endif
1517
#include "xml_pack_base.h"
1618
#include "xml_unpack_base.h"
1719
#include "xsd_generate_base.h"
@@ -30,147 +32,6 @@ namespace classdesc
3032

3133
}
3234

33-
namespace classdesc
34-
{
35-
template <class T>
36-
void convert(StringKeyMap<T>& map, const json_pack_t& j)
37-
{if (j.type()!=RESTProcessType::null) j>>map;}
38-
39-
template <class T>
40-
void json_pack_stringKeyMap(json_pack_t& j,const string& d, const StringKeyMap<T>& a)
41-
{
42-
try
43-
{
44-
json5_parser::mValue& parent=json_find(j,head(d));
45-
if (parent.type()!=json5_parser::obj_type)
46-
throw json_pack_error("attempt to pack an array member into a non-object");
47-
else
48-
{
49-
typename StringKeyMap<T>::const_iterator i=a.begin();
50-
for (; i!=a.end(); ++i)
51-
json_pack(j,d+"."+i->first, i->second);
52-
}
53-
}
54-
catch (json_pack_error&)
55-
{
56-
if (j.throw_on_error) throw;
57-
}
58-
}
59-
60-
template <class T>
61-
void json_unpack_stringKeyMap(json_pack_t& j,const string& d, StringKeyMap<T>& a)
62-
{
63-
try
64-
{
65-
const json5_parser::mValue& val=json_find(j,d);
66-
switch (val.type())
67-
{
68-
case json5_parser::obj_type:
69-
{
70-
const json5_parser::mObject& arr=val.get_obj();
71-
a.clear();
72-
for (json5_parser::mObject::const_iterator i=arr.begin(); i!=arr.end(); ++i)
73-
json_unpack(j,d+"."+i->first,a[i->first]);
74-
}
75-
break;
76-
case json5_parser::null_type:
77-
a.clear();
78-
break;
79-
default:
80-
throw json_pack_error("%s is not an array",d.c_str());
81-
}
82-
}
83-
catch (json_pack_error&)
84-
{
85-
if (j.throw_on_error) throw;
86-
}
87-
}
88-
89-
template <class T>
90-
void xsd_generate(xsd_generate_t& g, const string& d, const StringKeyMap<T>& a)
91-
{
92-
std::ostringstream os;
93-
// element name is given by the type name
94-
string eName=typeName<T>().c_str();
95-
eName=eName.substr(0,eName.find('<')); //trim off any template args
96-
// strip leading namespace and qualifiers
97-
const char *el=eName.c_str()+eName.length();
98-
while (el!=eName.c_str() && *(el-1)!=' ' && *(el-1)!=':') el--;
99-
100-
string type=transformTypeName(typeName<StringKeyMap<T> >());
101-
os << " <xs:complexType name=\"" << type << "\">\n";
102-
os << " <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\n";
103-
// There doesn't seem to be any way of specifying the element type
104-
// here without also constraining the element name!
105-
// os << " <xs:element name=\".*\" type=\""<<xsd_typeName<T>()<<"\"/>\n";
106-
os << " <xs:any processContents=\"lax\"/>\n";
107-
os << " </xs:sequence>\n";
108-
os << " </xs:complexType>\n";
109-
g.addMember(tail(d), xsd_typeName<StringKeyMap<T> >());
110-
g.defineType(type, os.str());
111-
g.addDependency(type, xsd_typeName<T>());
112-
// ensure that the value type as a definition also
113-
xsd_generate(g,"",T());
114-
115-
}
116-
}
117-
118-
using classdesc::xsd_generate;
119-
120-
namespace classdesc_access
121-
{
122-
namespace cd=classdesc;
123-
124-
template <class T>
125-
struct access_json_pack<classdesc::StringKeyMap<T> >
126-
{
127-
template <class U>
128-
void operator()(cd::json_pack_t& j,const cd::string& d,U& x)
129-
{json_pack_stringKeyMap(j,d,x);}
130-
};
131-
132-
template <class T>
133-
struct access_json_unpack<classdesc::StringKeyMap<T> >
134-
{
135-
void operator()(cd::json_unpack_t& j,const cd::string& d,cd::StringKeyMap<T>& x)
136-
{json_unpack_stringKeyMap(j,d,x);}
137-
void operator()(cd::json_unpack_t& j,const cd::string& d,const cd::StringKeyMap<T>& x)
138-
{}
139-
};
140-
141-
template <class T>
142-
struct access_xml_pack<classdesc::StringKeyMap<T> >
143-
{
144-
template <class U>
145-
void operator()(cd::xml_pack_t& x,const cd::string& d,U& arg)
146-
{
147-
cd::xml_pack_t::Tag tag(x,d);
148-
for (typename cd::StringKeyMap<T>::const_iterator i=arg.begin();
149-
i!=arg.end(); ++i)
150-
::xml_pack(x,d+"."+i->first,i->second);
151-
}
152-
};
153-
154-
template <class T>
155-
struct access_xml_unpack<classdesc::StringKeyMap<T> >
156-
{
157-
template <class U>
158-
void operator()(cd::xml_unpack_t& x,const cd::string& d,U& arg)
159-
{
160-
for (cd::xml_unpack_t::ContentMap::const_iterator i=x.firstToken(d);
161-
i!=x.endToken(d); ++i)
162-
{
163-
std::string key=i->first;
164-
size_t p=i->first.rfind('.');
165-
if (p!=std::string::npos) key=key.substr(p);
166-
::xml_unpack(x,i->first,arg[key]);
167-
}
168-
}
169-
};
170-
171-
}
172-
173-
17435
#ifdef _CLASSDESC
17536
#pragma omit json_pack classdesc::StringKeyMap
17637
#pragma omit json_unpack classdesc::StringKeyMap

stringKeyMap_epilogue.h

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
namespace classdesc
2+
{
3+
#ifdef CLASSDESC_JSON_PACK_BASE_H
4+
#if defined(__cplusplus) && __cplusplus>=201103L
5+
template <class T>
6+
void convert(StringKeyMap<T>& map, const json_pack_t& j)
7+
{if (j.type()!=RESTProcessType::null) j>>map;}
8+
9+
template <class T>
10+
void json_pack_stringKeyMap(json_pack_t& j,const string& d, const StringKeyMap<T>& a)
11+
{
12+
try
13+
{
14+
json5_parser::mValue& parent=json_find(j,head(d));
15+
if (parent.type()!=json5_parser::obj_type)
16+
throw json_pack_error("attempt to pack an array member into a non-object");
17+
else
18+
{
19+
typename StringKeyMap<T>::const_iterator i=a.begin();
20+
for (; i!=a.end(); ++i)
21+
json_pack(j,d+"."+i->first, i->second);
22+
}
23+
}
24+
catch (json_pack_error&)
25+
{
26+
if (j.throw_on_error) throw;
27+
}
28+
}
29+
30+
template <class T>
31+
void json_unpack_stringKeyMap(json_pack_t& j,const string& d, StringKeyMap<T>& a)
32+
{
33+
try
34+
{
35+
const json5_parser::mValue& val=json_find(j,d);
36+
switch (val.type())
37+
{
38+
case json5_parser::obj_type:
39+
{
40+
const json5_parser::mObject& arr=val.get_obj();
41+
a.clear();
42+
for (json5_parser::mObject::const_iterator i=arr.begin(); i!=arr.end(); ++i)
43+
json_unpack(j,d+"."+i->first,a[i->first]);
44+
}
45+
break;
46+
case json5_parser::null_type:
47+
a.clear();
48+
break;
49+
default:
50+
throw json_pack_error("%s is not an array",d.c_str());
51+
}
52+
}
53+
catch (json_pack_error&)
54+
{
55+
if (j.throw_on_error) throw;
56+
}
57+
}
58+
#endif
59+
#endif
60+
61+
#ifdef CLASSDESC_XSD_GENERATE_BASE_H
62+
template <class T>
63+
void xsd_generate(xsd_generate_t& g, const string& d, const StringKeyMap<T>& a)
64+
{
65+
std::ostringstream os;
66+
// element name is given by the type name
67+
string eName=typeName<T>().c_str();
68+
eName=eName.substr(0,eName.find('<')); //trim off any template args
69+
// strip leading namespace and qualifiers
70+
const char *el=eName.c_str()+eName.length();
71+
while (el!=eName.c_str() && *(el-1)!=' ' && *(el-1)!=':') el--;
72+
73+
string type=transformTypeName(typeName<StringKeyMap<T> >());
74+
os << " <xs:complexType name=\"" << type << "\">\n";
75+
os << " <xs:sequence minOccurs=\"0\" maxOccurs=\"unbounded\">\n";
76+
// There doesn't seem to be any way of specifying the element type
77+
// here without also constraining the element name!
78+
// os << " <xs:element name=\".*\" type=\""<<xsd_typeName<T>()<<"\"/>\n";
79+
os << " <xs:any processContents=\"lax\"/>\n";
80+
os << " </xs:sequence>\n";
81+
os << " </xs:complexType>\n";
82+
g.addMember(tail(d), xsd_typeName<StringKeyMap<T> >());
83+
g.defineType(type, os.str());
84+
g.addDependency(type, xsd_typeName<T>());
85+
// ensure that the value type as a definition also
86+
xsd_generate(g,"",T());
87+
88+
}
89+
#endif
90+
}
91+
92+
namespace classdesc_access
93+
{
94+
namespace cd=classdesc;
95+
96+
#ifdef CLASSDESC_JSON_PACK_BASE_H
97+
#if defined(__cplusplus) && __cplusplus>=201103L
98+
template <class T>
99+
struct access_json_pack<classdesc::StringKeyMap<T> >
100+
{
101+
template <class U>
102+
void operator()(cd::json_pack_t& j,const cd::string& d,U& x)
103+
{json_pack_stringKeyMap(j,d,x);}
104+
};
105+
106+
template <class T>
107+
struct access_json_unpack<classdesc::StringKeyMap<T> >
108+
{
109+
void operator()(cd::json_unpack_t& j,const cd::string& d,cd::StringKeyMap<T>& x)
110+
{json_unpack_stringKeyMap(j,d,x);}
111+
void operator()(cd::json_unpack_t& j,const cd::string& d,const cd::StringKeyMap<T>& x)
112+
{}
113+
};
114+
#endif
115+
#endif
116+
117+
#ifdef CLASSDESC_XML_COMMON_H
118+
template <class T>
119+
struct access_xml_pack<classdesc::StringKeyMap<T> >
120+
{
121+
template <class U>
122+
void operator()(cd::xml_pack_t& x,const cd::string& d,U& arg)
123+
{
124+
cd::xml_pack_t::Tag tag(x,d);
125+
for (typename cd::StringKeyMap<T>::const_iterator i=arg.begin();
126+
i!=arg.end(); ++i)
127+
::xml_pack(x,d+"."+i->first,i->second);
128+
}
129+
};
130+
131+
template <class T>
132+
struct access_xml_unpack<classdesc::StringKeyMap<T> >
133+
{
134+
template <class U>
135+
void operator()(cd::xml_unpack_t& x,const cd::string& d,U& arg)
136+
{
137+
for (cd::xml_unpack_t::ContentMap::const_iterator i=x.firstToken(d);
138+
i!=x.endToken(d); ++i)
139+
{
140+
std::string key=i->first;
141+
size_t p=i->first.rfind('.');
142+
if (p!=std::string::npos) key=key.substr(p);
143+
::xml_unpack(x,i->first,arg[key]);
144+
}
145+
}
146+
};
147+
#endif
148+
}

test/00/t0048a.sh

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)