51 class TypeInfoForTypeResolver :
public TypeInfo {
56 virtual ~TypeInfoForTypeResolver() {
61 util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl(
62 StringPiece
type_url)
const override {
63 std::map<StringPiece, StatusOrType>::iterator
it =
76 status.ok() ? StatusOrType(
type.release()) : StatusOrType(status);
82 StringPiece
type_url)
const override {
83 StatusOrType result = ResolveTypeUrl(
type_url);
84 return result.ok() ? result.ValueOrDie() :
NULL;
88 StringPiece
type_url)
const override {
89 std::map<StringPiece, StatusOrEnum>::iterator
it =
92 return it->second.ok() ?
it->second.ValueOrDie() :
NULL;
98 std::unique_ptr<google::protobuf::Enum>
enum_type(
102 StatusOrEnum result =
103 status.ok() ? StatusOrEnum(
enum_type.release()) : StatusOrEnum(status);
105 return result.ok() ? result.ValueOrDie() :
NULL;
110 StringPiece camel_case_name)
const override {
111 std::map<const google::protobuf::Type*, CamelCaseNameTable>::const_iterator
113 const CamelCaseNameTable& camel_case_name_table =
118 camel_case_name_table, camel_case_name, StringPiece());
121 name = camel_case_name;
127 typedef util::StatusOr<const google::protobuf::Type*> StatusOrType;
128 typedef util::StatusOr<const google::protobuf::Enum*> StatusOrEnum;
129 typedef std::map<StringPiece, StringPiece> CamelCaseNameTable;
131 template <
typename T>
132 static void DeleteCachedTypes(std::map<StringPiece, T>* cached_types) {
133 for (
typename std::map<StringPiece, T>::iterator
it =
134 cached_types->begin();
135 it != cached_types->end(); ++
it) {
136 if (
it->second.ok()) {
137 delete it->second.ValueOrDie();
142 const CamelCaseNameTable& PopulateNameLookupTable(
144 CamelCaseNameTable* camel_case_name_table)
const {
145 for (
int i = 0;
i <
type->fields_size(); ++
i) {
148 StringPiece camel_case_name =
field.json_name();
150 camel_case_name_table, camel_case_name,
name);
151 if (existing && *existing !=
name) {
153 <<
"' map to the same camel case name '" << camel_case_name
157 return *camel_case_name_table;
169 mutable std::map<const google::protobuf::Type*, CamelCaseNameTable>