OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 * |
| 7 * Helper functions for result writing operations. |
| 8 */ |
| 9 |
| 10 #include "ResultsWriter.h" |
| 11 |
| 12 #ifdef SK_BUILD_JSON_WRITER |
| 13 |
| 14 Json::Value* SkFindNamedNode(Json::Value* root, const char name[]) { |
| 15 Json::Value* search_results = NULL; |
| 16 for(Json::Value::iterator iter = root->begin(); |
| 17 iter!= root->end(); ++iter) { |
| 18 if(SkString(name).equals((*iter)["name"].asCString())) { |
| 19 search_results = &(*iter); |
| 20 break; |
| 21 } |
| 22 } |
| 23 |
| 24 if(search_results != NULL) { |
| 25 return search_results; |
| 26 } else { |
| 27 Json::Value* new_val = &(root->append(Json::Value())); |
| 28 (*new_val)["name"] = name; |
| 29 return new_val; |
| 30 } |
| 31 } |
| 32 |
| 33 #endif // SK_BUILD_JSON_WRITER |
OLD | NEW |