summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/util.h
diff options
context:
space:
mode:
authorcalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 07:29:48 +0000
committercalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-27 07:29:48 +0000
commit15f08dde26dbb02c8e4441492ab967cb48fcd4e4 (patch)
tree28f8e2f7e038575d9ac47873829e4792fc1ebb38 /tools/json_schema_compiler/util.h
parent195a0a026bc7a3916705fdf9a2a8c029d1cce9f2 (diff)
downloadchromium_src-15f08dde26dbb02c8e4441492ab967cb48fcd4e4.zip
chromium_src-15f08dde26dbb02c8e4441492ab967cb48fcd4e4.tar.gz
chromium_src-15f08dde26dbb02c8e4441492ab967cb48fcd4e4.tar.bz2
Code generation for extensions api
This is a preliminary code review for a code generator. The tool's purpose is to generate the tedious serialization code that needs to be written when defining a new extensions api. It generates from the json files in chrome/common/extensions/api. As an example usage, chrome/browser/extensions/extension_permissions_api.cc has been changed to use a class generated from permissions.json. The tool has been integrated into the build system and generates compiling and working code (for permissions.json at least) BUG= TEST= Review URL: http://codereview.chromium.org/9114036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@119405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler/util.h')
-rw-r--r--tools/json_schema_compiler/util.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/json_schema_compiler/util.h b/tools/json_schema_compiler/util.h
new file mode 100644
index 0000000..e94b518
--- /dev/null
+++ b/tools/json_schema_compiler/util.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__
+#define TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__
+#pragma once
+
+#include <string>
+#include <vector>
+
+#include "base/memory/scoped_ptr.h"
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace json_schema_compiler {
+namespace util {
+
+// Creates a new vector containing the strings |from|.|name| at |out|. Returns
+// false if there is no list at the specified key or if the list has anything
+// other than strings.
+bool GetStrings(
+ const base::DictionaryValue& from,
+ const std::string& name,
+ std::vector<std::string>* out);
+
+// Creates a new vector containing the strings |from|.|name| at |out|. Returns
+// true on success or if there is nothing at the specified key. Returns false
+// if anything other than a list of strings is at the specified key.
+bool GetOptionalStrings(
+ const base::DictionaryValue& from,
+ const std::string& name,
+ scoped_ptr<std::vector<std::string> >* out);
+
+// Puts the each string in |from| into a new ListValue at |out|.|name|.
+void SetStrings(
+ const std::vector<std::string>& from,
+ const std::string& name,
+ base::DictionaryValue* out);
+
+// If from is non-NULL, puts each string in |from| into a new ListValue at
+// |out|.|name|.
+void SetOptionalStrings(
+ const scoped_ptr<std::vector<std::string> >& from,
+ const std::string& name,
+ base::DictionaryValue* out);
+
+} // namespace api_util
+} // namespace extensions
+
+#endif // TOOLS_JSON_SCHEMA_COMPILER_UTIL_H__