blob: bd69e94cadd5a692aee9ad28f82a66071f848c0b [file] [log] [blame]
Vitaly Buka4615e0d2015-10-14 15:35:12 -07001// Copyright 2015 The Weave Authors. All rights reserved.
Alex Vakulenkob04936f2014-09-19 14:53:58 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Vitaly Buka912b6982015-07-06 11:13:03 -07005#ifndef LIBWEAVE_SRC_UTILS_H_
6#define LIBWEAVE_SRC_UTILS_H_
Alex Vakulenkob04936f2014-09-19 14:53:58 -07007
8#include <memory>
Alex Vakulenko9e2f8cd2015-04-07 16:28:09 -07009#include <string>
Alex Vakulenkob04936f2014-09-19 14:53:58 -070010
11#include <base/values.h>
Vitaly Buka0801a1f2015-08-14 10:03:46 -070012#include <weave/error.h>
Alex Vakulenkob04936f2014-09-19 14:53:58 -070013
Vitaly Bukab6f015a2015-07-09 14:59:23 -070014namespace weave {
Alex Vakulenkob04936f2014-09-19 14:53:58 -070015
Vitaly Bukae2810e02015-08-16 23:31:55 -070016namespace errors {
Vitaly Buka0fa51e52015-07-10 00:12:25 -070017extern const char kErrorDomain[];
Vitaly Bukae2810e02015-08-16 23:31:55 -070018extern const char kSchemaError[];
Alex Vakulenko07216fe2014-09-19 15:31:09 -070019extern const char kInvalidCategoryError[];
20extern const char kInvalidPackageError[];
Vitaly Bukae2810e02015-08-16 23:31:55 -070021} // namespace errors
Alex Vakulenko07216fe2014-09-19 15:31:09 -070022
23// kDefaultCategory represents a default state property category for standard
24// properties from "base" package which are provided by buffet and not any of
25// the daemons running on the device.
26const char kDefaultCategory[] = "";
Alex Vakulenkob04936f2014-09-19 14:53:58 -070027
Alex Vakulenko9e2f8cd2015-04-07 16:28:09 -070028// Helper function to load a JSON dictionary from a string.
Vitaly Buka207c1cb2015-05-14 17:06:18 -070029std::unique_ptr<base::DictionaryValue> LoadJsonDict(
30 const std::string& json_string,
Vitaly Buka0801a1f2015-08-14 10:03:46 -070031 ErrorPtr* error);
Alex Vakulenko9e2f8cd2015-04-07 16:28:09 -070032
Vitaly Buka70f77d92015-10-07 15:42:40 -070033std::unique_ptr<base::DictionaryValue> ErrorInfoToJson(const Error& error);
34
Vitaly Bukab6f015a2015-07-09 14:59:23 -070035} // namespace weave
Alex Vakulenkob04936f2014-09-19 14:53:58 -070036
Vitaly Buka912b6982015-07-06 11:13:03 -070037#endif // LIBWEAVE_SRC_UTILS_H_