blob: 08f11c190fbff926fd27f334dde10370b4cff665 [file] [log] [blame]
commit-bot@chromium.org37c772a2014-05-29 17:10:24 +00001/*
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
commit-bot@chromium.org37c772a2014-05-29 17:10:24 +000012Json::Value* SkFindNamedNode(Json::Value* root, const char name[]) {
13 Json::Value* search_results = NULL;
14 for(Json::Value::iterator iter = root->begin();
15 iter!= root->end(); ++iter) {
16 if(SkString(name).equals((*iter)["name"].asCString())) {
17 search_results = &(*iter);
18 break;
19 }
20 }
21
22 if(search_results != NULL) {
23 return search_results;
24 } else {
25 Json::Value* new_val = &(root->append(Json::Value()));
26 (*new_val)["name"] = name;
27 return new_val;
28 }
29}
30