OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 class Field; | 57 class Field; |
58 class Type; | 58 class Type; |
59 class Enum; | 59 class Enum; |
60 class EnumValue; | 60 class EnumValue; |
61 } // namespace protobuf | 61 } // namespace protobuf |
62 | 62 |
63 | 63 |
64 namespace protobuf { | 64 namespace protobuf { |
65 namespace util { | 65 namespace util { |
66 namespace converter { | 66 namespace converter { |
67 | |
68 // Size of "type.googleapis.com" | |
69 static const int64 kTypeUrlSize = 19; | |
70 | |
71 // Finds the tech option identified by option_name. Parses the boolean value and | 67 // Finds the tech option identified by option_name. Parses the boolean value and |
72 // returns it. | 68 // returns it. |
73 // When the option with the given name is not found, default_value is returned. | 69 // When the option with the given name is not found, default_value is returned. |
74 LIBPROTOBUF_EXPORT bool GetBoolOptionOrDefault( | 70 LIBPROTOBUF_EXPORT bool GetBoolOptionOrDefault( |
75 const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options, | 71 const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options, |
76 const string& option_name, bool default_value); | 72 const string& option_name, bool default_value); |
77 | 73 |
78 // Returns int64 option value. If the option isn't found, returns the | 74 // Returns int64 option value. If the option isn't found, returns the |
79 // default_value. | 75 // default_value. |
80 LIBPROTOBUF_EXPORT int64 GetInt64OptionOrDefault( | 76 LIBPROTOBUF_EXPORT int64 GetInt64OptionOrDefault( |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // Finds and returns the field identified by field_name in the passed tech Type | 125 // Finds and returns the field identified by field_name in the passed tech Type |
130 // object. Returns NULL if none found. | 126 // object. Returns NULL if none found. |
131 const google::protobuf::Field* FindFieldInTypeOrNull( | 127 const google::protobuf::Field* FindFieldInTypeOrNull( |
132 const google::protobuf::Type* type, StringPiece field_name); | 128 const google::protobuf::Type* type, StringPiece field_name); |
133 | 129 |
134 // Similar to FindFieldInTypeOrNull, but this looks up fields with given | 130 // Similar to FindFieldInTypeOrNull, but this looks up fields with given |
135 // json_name. | 131 // json_name. |
136 const google::protobuf::Field* FindJsonFieldInTypeOrNull( | 132 const google::protobuf::Field* FindJsonFieldInTypeOrNull( |
137 const google::protobuf::Type* type, StringPiece json_name); | 133 const google::protobuf::Type* type, StringPiece json_name); |
138 | 134 |
139 // Similar to FindFieldInTypeOrNull, but this looks up fields by number. | |
140 const google::protobuf::Field* FindFieldInTypeByNumberOrNull( | |
141 const google::protobuf::Type* type, int32 number); | |
142 | |
143 // Finds and returns the EnumValue identified by enum_name in the passed tech | 135 // Finds and returns the EnumValue identified by enum_name in the passed tech |
144 // Enum object. Returns NULL if none found. | 136 // Enum object. Returns NULL if none found. |
145 const google::protobuf::EnumValue* FindEnumValueByNameOrNull( | 137 const google::protobuf::EnumValue* FindEnumValueByNameOrNull( |
146 const google::protobuf::Enum* enum_type, StringPiece enum_name); | 138 const google::protobuf::Enum* enum_type, StringPiece enum_name); |
147 | 139 |
148 // Finds and returns the EnumValue identified by value in the passed tech | 140 // Finds and returns the EnumValue identified by value in the passed tech |
149 // Enum object. Returns NULL if none found. | 141 // Enum object. Returns NULL if none found. |
150 const google::protobuf::EnumValue* FindEnumValueByNumberOrNull( | 142 const google::protobuf::EnumValue* FindEnumValueByNumberOrNull( |
151 const google::protobuf::Enum* enum_type, int32 value); | 143 const google::protobuf::Enum* enum_type, int32 value); |
152 | 144 |
153 // Finds and returns the EnumValue identified by enum_name without underscore in | |
154 // the passed tech Enum object. Returns NULL if none found. | |
155 // For Ex. if enum_name is ACTIONANDADVENTURE it can get accepted if | |
156 // EnumValue's name is action_and_adventure or ACTION_AND_ADVENTURE. | |
157 const google::protobuf::EnumValue* FindEnumValueByNameWithoutUnderscoreOrNull( | |
158 const google::protobuf::Enum* enum_type, StringPiece enum_name); | |
159 | |
160 // Converts input to camel-case and returns it. | 145 // Converts input to camel-case and returns it. |
161 LIBPROTOBUF_EXPORT string ToCamelCase(const StringPiece input); | 146 LIBPROTOBUF_EXPORT string ToCamelCase(const StringPiece input); |
162 | 147 |
163 // Converts input to snake_case and returns it. | 148 // Converts input to snake_case and returns it. |
164 LIBPROTOBUF_EXPORT string ToSnakeCase(StringPiece input); | 149 LIBPROTOBUF_EXPORT string ToSnakeCase(StringPiece input); |
165 | 150 |
166 // Returns true if type_name represents a well-known type. | 151 // Returns true if type_name represents a well-known type. |
167 LIBPROTOBUF_EXPORT bool IsWellKnownType(const string& type_name); | 152 LIBPROTOBUF_EXPORT bool IsWellKnownType(const string& type_name); |
168 | 153 |
169 // Returns true if 'bool_string' represents a valid boolean value. Only "true", | 154 // Returns true if 'bool_string' represents a valid boolean value. Only "true", |
(...skipping 29 matching lines...) Expand all Loading... |
199 | 184 |
200 // Converts a string to float. Unlike safe_strtof, conversion will fail if the | 185 // Converts a string to float. Unlike safe_strtof, conversion will fail if the |
201 // value fits into double but not float (e.g., DBL_MAX). | 186 // value fits into double but not float (e.g., DBL_MAX). |
202 LIBPROTOBUF_EXPORT bool SafeStrToFloat(StringPiece str, float* value); | 187 LIBPROTOBUF_EXPORT bool SafeStrToFloat(StringPiece str, float* value); |
203 } // namespace converter | 188 } // namespace converter |
204 } // namespace util | 189 } // namespace util |
205 } // namespace protobuf | 190 } // namespace protobuf |
206 | 191 |
207 } // namespace google | 192 } // namespace google |
208 #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__ | 193 #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__ |
OLD | NEW |