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 |
67 // Finds the tech option identified by option_name. Parses the boolean value and | 71 // Finds the tech option identified by option_name. Parses the boolean value and |
68 // returns it. | 72 // returns it. |
69 // When the option with the given name is not found, default_value is returned. | 73 // When the option with the given name is not found, default_value is returned. |
70 LIBPROTOBUF_EXPORT bool GetBoolOptionOrDefault( | 74 LIBPROTOBUF_EXPORT bool GetBoolOptionOrDefault( |
71 const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options, | 75 const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options, |
72 const string& option_name, bool default_value); | 76 const string& option_name, bool default_value); |
73 | 77 |
74 // Returns int64 option value. If the option isn't found, returns the | 78 // Returns int64 option value. If the option isn't found, returns the |
75 // default_value. | 79 // default_value. |
76 LIBPROTOBUF_EXPORT int64 GetInt64OptionOrDefault( | 80 LIBPROTOBUF_EXPORT int64 GetInt64OptionOrDefault( |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // Finds and returns the field identified by field_name in the passed tech Type | 129 // Finds and returns the field identified by field_name in the passed tech Type |
126 // object. Returns NULL if none found. | 130 // object. Returns NULL if none found. |
127 const google::protobuf::Field* FindFieldInTypeOrNull( | 131 const google::protobuf::Field* FindFieldInTypeOrNull( |
128 const google::protobuf::Type* type, StringPiece field_name); | 132 const google::protobuf::Type* type, StringPiece field_name); |
129 | 133 |
130 // Similar to FindFieldInTypeOrNull, but this looks up fields with given | 134 // Similar to FindFieldInTypeOrNull, but this looks up fields with given |
131 // json_name. | 135 // json_name. |
132 const google::protobuf::Field* FindJsonFieldInTypeOrNull( | 136 const google::protobuf::Field* FindJsonFieldInTypeOrNull( |
133 const google::protobuf::Type* type, StringPiece json_name); | 137 const google::protobuf::Type* type, StringPiece json_name); |
134 | 138 |
| 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 |
135 // Finds and returns the EnumValue identified by enum_name in the passed tech | 143 // Finds and returns the EnumValue identified by enum_name in the passed tech |
136 // Enum object. Returns NULL if none found. | 144 // Enum object. Returns NULL if none found. |
137 const google::protobuf::EnumValue* FindEnumValueByNameOrNull( | 145 const google::protobuf::EnumValue* FindEnumValueByNameOrNull( |
138 const google::protobuf::Enum* enum_type, StringPiece enum_name); | 146 const google::protobuf::Enum* enum_type, StringPiece enum_name); |
139 | 147 |
140 // Finds and returns the EnumValue identified by value in the passed tech | 148 // Finds and returns the EnumValue identified by value in the passed tech |
141 // Enum object. Returns NULL if none found. | 149 // Enum object. Returns NULL if none found. |
142 const google::protobuf::EnumValue* FindEnumValueByNumberOrNull( | 150 const google::protobuf::EnumValue* FindEnumValueByNumberOrNull( |
143 const google::protobuf::Enum* enum_type, int32 value); | 151 const google::protobuf::Enum* enum_type, int32 value); |
144 | 152 |
| 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 |
145 // Converts input to camel-case and returns it. | 160 // Converts input to camel-case and returns it. |
146 LIBPROTOBUF_EXPORT string ToCamelCase(const StringPiece input); | 161 LIBPROTOBUF_EXPORT string ToCamelCase(const StringPiece input); |
147 | 162 |
148 // Converts input to snake_case and returns it. | 163 // Converts input to snake_case and returns it. |
149 LIBPROTOBUF_EXPORT string ToSnakeCase(StringPiece input); | 164 LIBPROTOBUF_EXPORT string ToSnakeCase(StringPiece input); |
150 | 165 |
151 // Returns true if type_name represents a well-known type. | 166 // Returns true if type_name represents a well-known type. |
152 LIBPROTOBUF_EXPORT bool IsWellKnownType(const string& type_name); | 167 LIBPROTOBUF_EXPORT bool IsWellKnownType(const string& type_name); |
153 | 168 |
154 // Returns true if 'bool_string' represents a valid boolean value. Only "true", | 169 // Returns true if 'bool_string' represents a valid boolean value. Only "true", |
(...skipping 29 matching lines...) Expand all Loading... |
184 | 199 |
185 // Converts a string to float. Unlike safe_strtof, conversion will fail if the | 200 // Converts a string to float. Unlike safe_strtof, conversion will fail if the |
186 // value fits into double but not float (e.g., DBL_MAX). | 201 // value fits into double but not float (e.g., DBL_MAX). |
187 LIBPROTOBUF_EXPORT bool SafeStrToFloat(StringPiece str, float* value); | 202 LIBPROTOBUF_EXPORT bool SafeStrToFloat(StringPiece str, float* value); |
188 } // namespace converter | 203 } // namespace converter |
189 } // namespace util | 204 } // namespace util |
190 } // namespace protobuf | 205 } // namespace protobuf |
191 | 206 |
192 } // namespace google | 207 } // namespace google |
193 #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__ | 208 #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__ |
OLD | NEW |