~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

Viewing changes to src/common_cpp/JsonCppProcessors/ArrayProcessors-inl.hh

  • Committer: Durga Rajaram
  • Date: 2014-07-16 15:13:05 UTC
  • mfrom: (659.1.92 cand)
  • Revision ID: durga@fnal.gov-20140716151305-q27rv1y9p03v9lks
Tags: MAUS-v0.9, MAUS-v0.9.0
MAUS-v0.9.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
    for (size_t i = 0; i < json_array.size(); ++i) {
54
54
        try {
55
55
            // allocate the vector
56
 
            if (json_array[i].type() == Json::nullValue) {
 
56
            if (json_array[Json::Value::ArrayIndex(i)].type() == Json::nullValue) {
57
57
                (*vec)[i] = NULL;
58
58
            } else {
59
 
                ArrayContents* data = _proc->JsonToCpp(json_array[i]);
 
59
                ArrayContents* data = _proc->JsonToCpp(
 
60
                                      json_array[Json::Value::ArrayIndex(i)]);
60
61
                (*vec)[i] = data;
61
62
                using ReferenceResolver::JsonToCpp::RefManager;
62
 
                std::string path = JsonWrapper::Path::GetPath(json_array[i]);
 
63
                std::string path = JsonWrapper::Path::GetPath(
 
64
                                        json_array[Json::Value::ArrayIndex(i)]);
63
65
                if (RefManager::HasInstance())
64
66
                    RefManager::GetInstance().SetPointerAsValue(path, (*vec)[i]);
65
67
            }
99
101
            } else {
100
102
                data = _proc->CppToJson(*cpp_array[i], GetPath(path, i));
101
103
            }
102
 
            (*json_array)[i] = *data; // json copies memory here but not path
103
 
            JsonWrapper::Path::SetPath((*json_array)[i], GetPath(path, i));
 
104
            // json copies memory here but not path
 
105
            (*json_array)[Json::Value::ArrayIndex(i)] = *data;
 
106
            JsonWrapper::Path::SetPath((*json_array)[Json::Value::ArrayIndex(i)],
 
107
                                       GetPath(path, i));
104
108
            delete data; // so we need to clean up here
105
109
            using ReferenceResolver::CppToJson::RefManager;
106
110
            if (RefManager::HasInstance())
155
159
    for (size_t i = 0; i < json_array.size(); ++i) {
156
160
        try {
157
161
            // allocate the vector
158
 
            ArrayContents* data = _proc->JsonToCpp(json_array[i]);
 
162
            ArrayContents* data = _proc->JsonToCpp(json_array[
 
163
                                      Json::Value::ArrayIndex(i)]);
159
164
            (*vec)[i] = *data;
160
165
            delete data;
161
166
        } catch (Exception exc) {
186
191
        try {
187
192
            Json::Value* data = _proc->CppToJson(cpp_array[i],
188
193
                                                              GetPath(path, i));
189
 
            (*json_array)[i] = *data; // json copies memory but not path
190
 
            JsonWrapper::Path::SetPath((*json_array)[i], GetPath(path, i));
 
194
            (*json_array)[Json::Value::ArrayIndex(i)] = *data; // json copies memory but not path
 
195
            JsonWrapper::Path::SetPath((*json_array)[Json::Value::ArrayIndex(i)],
 
196
                                       GetPath(path, i));
191
197
            delete data; // so we need to clean up here
192
198
        } catch (Exception exc) {
193
199
            // if there's a problem, clean up before rethrowing the exception
225
231
    for (size_t i = 0; i < json_array.size(); ++i) {
226
232
        try {
227
233
            (*vec)[i] = NULL;
228
 
            if (json_array[i].type() != Json::nullValue) {
 
234
            if (json_array[Json::Value::ArrayIndex(i)].type() != Json::nullValue) {
229
235
                std::string data_path = JsonWrapper::GetProperty
230
 
                   (json_array[i], "$ref", JsonWrapper::stringValue).asString();
 
236
                   (json_array[Json::Value::ArrayIndex(i)],
 
237
                    "$ref",
 
238
                    JsonWrapper::stringValue).asString();
231
239
                // allocate the vector
232
240
                if (RefManager::HasInstance()) {
233
241
                    VectorResolver<ArrayContents>* res =
254
262
    JsonWrapper::Path::SetPath(*array, path);
255
263
    array->resize(cpp_array.size());
256
264
    for (size_t i = 0; i < cpp_array.size(); ++i) {
257
 
        (*array)[i] = Json::Value();
258
 
        if (cpp_array[i] != NULL) {
259
 
            JsonWrapper::Path::SetPath((*array)[i], path);
260
 
            JsonWrapper::Path::AppendPath((*array)[i], i);
 
265
        (*array)[Json::Value::ArrayIndex(i)] = Json::Value();
 
266
        if (cpp_array[Json::Value::ArrayIndex(i)] != NULL) {
 
267
            JsonWrapper::Path::SetPath((*array)[Json::Value::ArrayIndex(i)], path);
 
268
            JsonWrapper::Path::AppendPath((*array)[Json::Value::ArrayIndex(i)], i);
261
269
            if (RefManager::HasInstance()) {
262
 
                std::string arr_path = JsonWrapper::Path::GetPath((*array)[i]);
 
270
                std::string arr_path = JsonWrapper::Path::GetPath(
 
271
                                          (*array)[Json::Value::ArrayIndex(i)]);
263
272
                TypedResolver<ArrayContents>* res = new TypedResolver
264
273
                                        <ArrayContents>(cpp_array[i], arr_path);
265
274
                RefManager::GetInstance().AddReference(res);