[email protected] | cc7a544c | 2013-01-02 08:31:51 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors. All rights reserved. |
[email protected] | 447a5b6 | 2012-07-12 18:15:45 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef SYNCABLE_PROTOCOL_PROTO_UTIL_H_ |
| 6 | #define SYNCABLE_PROTOCOL_PROTO_UTIL_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
[email protected] | cc7a544c | 2013-01-02 08:31:51 | [diff] [blame] | 10 | #include "sync/base/sync_export.h" |
[email protected] | 447a5b6 | 2012-07-12 18:15:45 | [diff] [blame] | 11 | #include "sync/syncable/syncable_id.h" |
| 12 | |
| 13 | namespace sync_pb { |
| 14 | class SyncEntity; |
| 15 | } |
| 16 | |
| 17 | namespace syncer { |
| 18 | |
| 19 | // Converts from a specially formatted string field to a syncable::Id. Used |
| 20 | // when interpreting the fields of protocol buffers received from the server. |
| 21 | syncable::Id SyncableIdFromProto(const std::string& proto_string); |
| 22 | |
| 23 | // Converts from a syncable::Id to a formatted std::string. This is useful for |
| 24 | // populating the fields of a protobuf which will be sent to the server. |
[email protected] | cc7a544c | 2013-01-02 08:31:51 | [diff] [blame] | 25 | SYNC_EXPORT_PRIVATE std::string SyncableIdToProto( |
| 26 | const syncable::Id& syncable_id); |
[email protected] | 447a5b6 | 2012-07-12 18:15:45 | [diff] [blame] | 27 | |
| 28 | // Helper function to determine if this SyncEntity's properties indicate that it |
| 29 | // is a folder. |
| 30 | bool IsFolder(const sync_pb::SyncEntity& entity); |
| 31 | |
| 32 | // Helper function to determine if this SyncEntity's properties indicate that it |
| 33 | // is the root node. |
| 34 | bool IsRoot(const sync_pb::SyncEntity& entity); |
| 35 | |
| 36 | } // namespace syncer |
| 37 | |
| 38 | #endif // SYNCABLE_PROTOCOL_PROTO_UTIL_H_ |