OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ |
6 #define COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // the internal representation. If |schema| is invalid then an invalid Schema | 50 // the internal representation. If |schema| is invalid then an invalid Schema |
51 // is returned and |error| contains a reason for the failure. | 51 // is returned and |error| contains a reason for the failure. |
52 static Schema Parse(const std::string& schema, std::string* error); | 52 static Schema Parse(const std::string& schema, std::string* error); |
53 | 53 |
54 // Returns true if this Schema is valid. Schemas returned by the methods below | 54 // Returns true if this Schema is valid. Schemas returned by the methods below |
55 // may be invalid, and in those cases the other methods must not be used. | 55 // may be invalid, and in those cases the other methods must not be used. |
56 bool valid() const { return node_ != NULL; } | 56 bool valid() const { return node_ != NULL; } |
57 | 57 |
58 base::Value::Type type() const; | 58 base::Value::Type type() const; |
59 | 59 |
| 60 // Returns true if |value| conforms to this Schema. |
| 61 bool Validate(const base::Value& value) const; |
| 62 |
60 // Used to iterate over the known properties of TYPE_DICTIONARY schemas. | 63 // Used to iterate over the known properties of TYPE_DICTIONARY schemas. |
61 class POLICY_EXPORT Iterator { | 64 class POLICY_EXPORT Iterator { |
62 public: | 65 public: |
63 Iterator(const scoped_refptr<const InternalStorage>& storage, | 66 Iterator(const scoped_refptr<const InternalStorage>& storage, |
64 const internal::PropertiesNode* node); | 67 const internal::PropertiesNode* node); |
65 Iterator(const Iterator& iterator); | 68 Iterator(const Iterator& iterator); |
66 ~Iterator(); | 69 ~Iterator(); |
67 | 70 |
68 Iterator& operator=(const Iterator& iterator); | 71 Iterator& operator=(const Iterator& iterator); |
69 | 72 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 Schema(const scoped_refptr<const InternalStorage>& storage, | 118 Schema(const scoped_refptr<const InternalStorage>& storage, |
116 const internal::SchemaNode* node); | 119 const internal::SchemaNode* node); |
117 | 120 |
118 scoped_refptr<const InternalStorage> storage_; | 121 scoped_refptr<const InternalStorage> storage_; |
119 const internal::SchemaNode* node_; | 122 const internal::SchemaNode* node_; |
120 }; | 123 }; |
121 | 124 |
122 } // namespace policy | 125 } // namespace policy |
123 | 126 |
124 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ | 127 #endif // COMPONENTS_POLICY_CORE_COMMON_SCHEMA_H_ |
OLD | NEW |