aboutsummaryrefslogtreecommitdiff
path: root/src/utils.h
blob: 40c76b43a230a6069150ec0d4d34a66195c17bd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2015 The Weave 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 LIBWEAVE_SRC_UTILS_H_
#define LIBWEAVE_SRC_UTILS_H_

#include <memory>
#include <string>

#include <base/time/time.h>
#include <base/values.h>
#include <weave/error.h>

namespace weave {

namespace errors {
extern const char kSchemaError[];
extern const char kInvalidCategoryError[];
extern const char kInvalidPackageError[];
}  // namespace errors

// kDefaultCategory represents a default state property category for standard
// properties from "base" package which are provided by buffet and not any of
// the daemons running on the device.
const char kDefaultCategory[] = "";

// Helper function to load a JSON dictionary from a string.
std::unique_ptr<base::DictionaryValue> LoadJsonDict(
    const std::string& json_string,
    ErrorPtr* error);

std::unique_ptr<base::DictionaryValue> ErrorInfoToJson(const Error& error);

uint32_t ToJ2000Time(const base::Time& time);
base::Time FromJ2000Time(uint32_t time);

}  // namespace weave

#endif  // LIBWEAVE_SRC_UTILS_H_