summaryrefslogtreecommitdiffstats
path: root/chromecast/base/serializers.h
blob: 06c79b760672add766c76e99ed337b10d28a16b5 (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
// Copyright 2015 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 CHROMECAST_BASE_SERIALIZERS_H_
#define CHROMECAST_BASE_SERIALIZERS_H_

#include <string>

#include "base/memory/scoped_ptr.h"

namespace base {
class Value;
class FilePath;
}

namespace chromecast {

// Helper function which deserializes JSON |text| into a base::Value. If |text|
// is empty, is not valid JSON, or if some other deserialization error occurs,
// the return value will hold the NULL pointer.
scoped_ptr<base::Value> DeserializeFromJson(const std::string& text);

// Helper function which serializes |value| into a JSON string. If a
// serialization error occurs,the return value will hold the NULL pointer.
scoped_ptr<std::string> SerializeToJson(const base::Value& value);

// Helper function which deserializes JSON file at |path| into a base::Value.
// If file in |path| is empty, is not valid JSON, or if some other
// deserialization error occurs, the return value will hold the NULL pointer.
scoped_ptr<base::Value> DeserializeJsonFromFile(const base::FilePath& path);

// Helper function which serializes |value| into the file at |path|. The
// function returns true on success, false otherwise.
bool SerializeJsonToFile(const base::FilePath& path, const base::Value& value);

}  // namespace chromecast

#endif  // CHROMECAST_BASE_SERIALIZERS_H_