<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> import re <EOL> import gflags as flags <EOL> from googleapis . codegen import api <EOL> from googleapis . codegen import api_library_generator <EOL> from googleapis . codegen import cpp_import_manager <EOL> from googleapis . codegen import data_types <EOL> from googleapis . codegen import language_model <EOL> from googleapis . codegen import utilities <EOL> from googleapis . codegen . import_definition import ImportDefinition <EOL> FLAGS = flags . FLAGS <EOL> flags . DEFINE_boolean ( <EOL> '<STR_LIT>' , <EOL> True , <EOL> '<STR_LIT>' ) <EOL> DT_DD_PATTERN_RE = re . compile ( <EOL> r"""<STR_LIT>""" , <EOL> re . VERBOSE ) <EOL> MAX_DD_LEN = <NUM_LIT> <EOL> _DL_PATTERN = r"""<STR_LIT>""" % MAX_DD_LEN <EOL> DL_PATTERN_RE = re . compile ( _DL_PATTERN , re . VERBOSE ) <EOL> class CppGenerator ( api_library_generator . ApiLibraryGenerator ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , discovery , language = '<STR_LIT>' , language_model = None , <EOL> options = None ) : <EOL> if not language_model : <EOL> language_model = CppLanguageModel ( options ) <EOL> super ( CppGenerator , self ) . __init__ ( CppApi , discovery , language , <EOL> language_model , options = options ) <EOL> def _InnerModelClassesSupported ( self ) : <EOL> """<STR_LIT>""" <EOL> return True <EOL> def _HeaderFileName ( self , path , filename ) : <EOL> if not path : <EOL> return '<STR_LIT>' % filename <EOL> return '<STR_LIT>' % ( path , filename ) <EOL> def _DLifyDescription ( self , text ) : <EOL> """<STR_LIT>""" <EOL> sentinel = '<STR_LIT:\n>' <EOL> dl_partitions = DL_PATTERN_RE . split ( sentinel + text ) <EOL> dl_partitions [ <NUM_LIT:0> ] = dl_partitions [ <NUM_LIT:0> ] [ len ( sentinel ) : ] <EOL> if len ( dl_partitions ) == <NUM_LIT:1> : <EOL> return text <EOL> result = [ ] <EOL> for partition in dl_partitions : <EOL> dl = DT_DD_PATTERN_RE . split ( partition ) <EOL> if len ( dl ) == <NUM_LIT:1> : <EOL> if dl [ <NUM_LIT:0> ] : <EOL> result . append ( dl [ <NUM_LIT:0> ] ) <EOL> continue <EOL> else : <EOL> if result : <EOL> result . append ( '<STR_LIT:\n>' ) <EOL> num_triples = len ( dl ) / <NUM_LIT:3> <EOL> if num_triples == <NUM_LIT:1> : <EOL> result . append ( partition ) <EOL> continue <EOL> runoff = '<STR_LIT>' <EOL> result . append ( '<STR_LIT>' ) <EOL> for i in range ( num_triples ) : <EOL> dt_value = dl [ <NUM_LIT:3> * i + <NUM_LIT:1> ] . strip ( ) <EOL> dd_value = dl [ <NUM_LIT:3> * i + <NUM_LIT:2> ] . strip ( ) <EOL> result . append ( '<STR_LIT>' % dt_value ) <EOL> if i < ( num_triples - <NUM_LIT:1> ) or len ( dd_value ) < MAX_DD_LEN : <EOL> if not dd_value . endswith ( '<STR_LIT:.>' ) : <EOL> dd_value += '<STR_LIT:.>' <EOL> result . append ( '<STR_LIT>' % dd_value ) <EOL> else : <EOL> period = dd_value . find ( '<STR_LIT:.>' ) <EOL> if period < <NUM_LIT:0> : <EOL> period = len ( dd_value ) - <NUM_LIT:1> <EOL> result . append ( '<STR_LIT>' % dd_value [ <NUM_LIT:0> : period + <NUM_LIT:1> ] ) <EOL> runoff = dd_value [ period + <NUM_LIT:1> : ] <EOL> result . append ( '<STR_LIT>' ) <EOL> result . append ( runoff ) <EOL> return '<STR_LIT>' . join ( result ) <EOL> def AnnotateDocumentation ( self , code_obj ) : <EOL> """<STR_LIT>""" <EOL> description = code_obj . values . get ( '<STR_LIT:description>' ) <EOL> if not description : <EOL> return <EOL> if description . endswith ( '<STR_LIT:\n>' ) : <EOL> description = description [ <NUM_LIT:0> : len ( description ) - <NUM_LIT:1> ] <EOL> if not description . endswith ( '<STR_LIT:.>' ) : <EOL> description += '<STR_LIT:.>' <EOL> if re . match ( r'<STR_LIT>' , description , re . IGNORECASE ) : <EOL> code_obj . SetTemplateValue ( '<STR_LIT>' , True ) <EOL> description = self . _DLifyDescription ( description ) <EOL> code_obj . SetTemplateValue ( '<STR_LIT:description>' , description ) <EOL> def AnnotateApiForLanguage ( self , the_api ) : <EOL> super ( CppGenerator , self ) . AnnotateApiForLanguage ( the_api ) <EOL> unsorted_list = the_api . TopLevelModelClasses ( ) <EOL> have = set ( ) <EOL> sorted_list = [ ] <EOL> for m in unsorted_list : <EOL> self . _AddDependencies ( the_api , m , have , sorted_list ) <EOL> the_api . SetTemplateValue ( '<STR_LIT>' , sorted_list ) <EOL> def AnnotateApi ( self , the_api ) : <EOL> """<STR_LIT>""" <EOL> super ( CppGenerator , self ) . AnnotateApi ( the_api ) <EOL> for schema in the_api . TopLevelModelClasses ( ) : <EOL> filename = utilities . UnCamelCase ( schema . class_name ) <EOL> schema . SetTemplateValue ( '<STR_LIT:filename>' , filename ) <EOL> schema . SetTemplateValue ( <EOL> '<STR_LIT>' , <EOL> self . _HeaderFileName ( schema . module . path , schema . values [ '<STR_LIT:filename>' ] ) ) <EOL> include_guard = '<STR_LIT>' % ( the_api . module . name . upper ( ) , <EOL> filename . upper ( ) ) <EOL> schema . SetTemplateValue ( '<STR_LIT>' , include_guard ) <EOL> the_api . SetTemplateValue ( '<STR_LIT:filename>' , <EOL> utilities . UnCamelCase ( the_api . class_name ) ) <EOL> the_api . SetTemplateValue ( <EOL> '<STR_LIT>' , <EOL> self . _HeaderFileName ( the_api . module . path , the_api . values [ '<STR_LIT:filename>' ] ) ) <EOL> monolithic_source_name = the_api . GetTemplateValue ( '<STR_LIT>' ) <EOL> if monolithic_source_name : <EOL> the_api . SetTemplateValue ( '<STR_LIT>' , monolithic_source_name ) <EOL> else : <EOL> plain_api_filename = utilities . UnCamelCase ( the_api . values [ '<STR_LIT:name>' ] ) <EOL> the_api . SetTemplateValue ( '<STR_LIT>' , '<STR_LIT>' % plain_api_filename ) <EOL> authscopes = the_api . values . get ( '<STR_LIT>' ) <EOL> if authscopes : <EOL> for scope in authscopes : <EOL> self . AnnotateDocumentation ( scope ) <EOL> self . AnnotateDocumentation ( the_api ) <EOL> def _AddDependencies ( self , the_api , model , have , dep_list ) : <EOL> if model not in have : <EOL> have . add ( model ) <EOL> import_manager = cpp_import_manager . CppImportManager . ForElement ( model ) <EOL> for dependent in import_manager . type_dependencies : <EOL> schema = the_api . SchemaByName ( dependent . values [ '<STR_LIT>' ] ) <EOL> self . _AddDependencies ( the_api , schema , have , dep_list ) <EOL> dep_list . append ( model ) <EOL> def AnnotateMethod ( self , the_api , method , unused_rsrc ) : <EOL> """<STR_LIT>""" <EOL> super ( CppGenerator , self ) . AnnotateMethod ( the_api , method , unused_rsrc ) <EOL> import_manager = cpp_import_manager . CppImportManager . ForElement ( the_api ) <EOL> request_type = method . values . get ( '<STR_LIT>' ) <EOL> response_type = method . values . get ( '<STR_LIT>' ) <EOL> if request_type : <EOL> self . _HandleImports ( request_type , import_manager ) <EOL> if method . values . get ( '<STR_LIT>' ) : <EOL> media_upload_h = '<STR_LIT>' <EOL> import_manager . AddImport ( media_upload_h ) <EOL> if response_type != the_api . void_type : <EOL> request_pager_h = '<STR_LIT>' <EOL> self . _HandleImports ( method . values [ '<STR_LIT>' ] , import_manager ) <EOL> if method . values . get ( '<STR_LIT>' ) : <EOL> import_manager . AddImport ( request_pager_h ) <EOL> method . SetTemplateValue ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' % utilities . CamelCase ( method . values [ '<STR_LIT>' ] ) ) <EOL> self . AnnotateDocumentation ( method ) <EOL> def AnnotateParameter ( self , unused_method , parameter ) : <EOL> """<STR_LIT>""" <EOL> super ( CppGenerator , self ) . AnnotateParameter ( unused_method , parameter ) <EOL> parameter . SetTemplateValue ( '<STR_LIT>' , <EOL> self . _IsPrimitiveType ( parameter . data_type ) ) <EOL> if parameter . data_type . code_type == '<STR_LIT:string>' : <EOL> parameter . SetTemplateValue ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> else : <EOL> parameter . SetTemplateValue ( '<STR_LIT>' , <EOL> parameter . data_type . code_type ) <EOL> self . _HandleImports ( parameter ) <EOL> self . AnnotateDocumentation ( parameter ) <EOL> def AnnotateProperty ( self , unused_api , prop , unused_schema ) : <EOL> """<STR_LIT>""" <EOL> super ( CppGenerator , self ) . AnnotateProperty ( unused_api , prop , unused_schema ) <EOL> prop . SetTemplateValue ( '<STR_LIT>' , self . _IsPrimitiveType ( prop . data_type ) ) <EOL> base_type = prop . data_type <EOL> if base_type . GetTemplateValue ( '<STR_LIT>' ) : <EOL> base_type = base_type . GetTemplateValue ( '<STR_LIT>' ) <EOL> try : <EOL> has_parent = base_type . parent <EOL> except AttributeError : <EOL> has_parent = False <EOL> if not base_type . GetTemplateValue ( '<STR_LIT>' ) and not has_parent : <EOL> prop . SetTemplateValue ( '<STR_LIT>' , True ) <EOL> self . _HandleImports ( prop ) <EOL> self . AnnotateDocumentation ( prop ) <EOL> def AnnotateSchema ( self , the_api , schema ) : <EOL> """<STR_LIT>""" <EOL> super ( CppGenerator , self ) . AnnotateSchema ( the_api , schema ) <EOL> self . AnnotateDocumentation ( schema ) <EOL> def _IsPrimitiveType ( self , data_type ) : <EOL> """<STR_LIT>""" <EOL> return ( data_type . json_type == '<STR_LIT>' <EOL> or data_type . json_type == '<STR_LIT>' <EOL> or data_type . json_type == '<STR_LIT>' <EOL> or ( hasattr ( data_type , '<STR_LIT>' ) and ( <EOL> data_type . json_format == '<STR_LIT>' <EOL> or data_type . json_format == '<STR_LIT>' <EOL> or data_type . json_format == '<STR_LIT:date>' <EOL> or data_type . json_format == '<STR_LIT>' ) ) ) <EOL> def _HandleImports ( self , element , import_manager = None ) : <EOL> """<STR_LIT>""" <EOL> element = getattr ( element , '<STR_LIT>' , element ) <EOL> if isinstance ( element , data_types . ComplexDataType ) : <EOL> parent = element <EOL> data_type = element <EOL> else : <EOL> parent = element . schema <EOL> data_type = element . data_type <EOL> data_type = getattr ( data_type , '<STR_LIT>' , data_type ) <EOL> if not import_manager : <EOL> if self . _InnerModelClassesSupported ( ) : <EOL> while parent . parent : <EOL> parent = parent . parent <EOL> import_manager = cpp_import_manager . CppImportManager . ForElement ( parent ) <EOL> while isinstance ( data_type , ( data_types . ArrayDataType , <EOL> data_types . MapDataType ) ) : <EOL> data_type = data_type . _base_type <EOL> data_type = getattr ( data_type , '<STR_LIT>' , data_type ) <EOL> if not data_type : <EOL> return <EOL> json_type = data_type . json_type <EOL> json_format = data_type . values . get ( '<STR_LIT>' ) <EOL> if json_type == '<STR_LIT:object>' : <EOL> if not data_type . parent : <EOL> import_manager . AddDataType ( data_type ) <EOL> return <EOL> datatype_and_imports = ( <EOL> self . language_model . type_map . get ( ( json_type , json_format ) ) ) <EOL> if datatype_and_imports : <EOL> import_definition = datatype_and_imports [ <NUM_LIT:1> ] <EOL> for required_import in import_definition . imports : <EOL> if required_import : <EOL> import_manager . AddImport ( required_import ) <EOL> for template_value in import_definition . template_values : <EOL> element . SetTemplateValue ( template_value , True ) <EOL> elif data_type : <EOL> if not data_type . parent : <EOL> import_manager . AddDataType ( data_type ) <EOL> return <EOL> class CppLanguageModel ( language_model . LanguageModel ) : <EOL> """<STR_LIT>""" <EOL> language = '<STR_LIT>' <EOL> member_policy = language_model . NamingPolicy ( <EOL> language_model . LOWER_UNCAMEL_CASE , '<STR_LIT>' , '<STR_LIT:_>' ) <EOL> getter_policy = language_model . NamingPolicy ( <EOL> language_model . LOWER_UNCAMEL_CASE , '<STR_LIT>' , '<STR_LIT:_>' ) <EOL> setter_policy = language_model . NamingPolicy ( <EOL> language_model . LOWER_UNCAMEL_CASE , '<STR_LIT>' , '<STR_LIT:_>' ) <EOL> has_policy = language_model . NamingPolicy ( <EOL> language_model . LOWER_UNCAMEL_CASE , '<STR_LIT>' , '<STR_LIT:_>' ) <EOL> unset_policy = language_model . NamingPolicy ( <EOL> language_model . LOWER_UNCAMEL_CASE , '<STR_LIT>' , '<STR_LIT:_>' ) <EOL> parameter_name_policy = language_model . NamingPolicy ( <EOL> language_model . LOWER_UNCAMEL_CASE , '<STR_LIT>' , '<STR_LIT:_>' , <EOL> conflict_policy = language_model . NamingPolicy ( <EOL> language_model . LOWER_UNCAMEL_CASE , '<STR_LIT>' , '<STR_LIT:_>' ) ) <EOL> _CPP_KEYWORDS = [ <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT:bool>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT:class>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:default>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:false>' , '<STR_LIT:float>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:int>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT:true>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' <EOL> ] <EOL> _SPECIAL_CLASS_NAMES = [ <EOL> '<STR_LIT>' , '<STR_LIT>' <EOL> ] <EOL> RESERVED_CLASS_NAMES = _SPECIAL_CLASS_NAMES <EOL> reserved_words = RESERVED_CLASS_NAMES + _CPP_KEYWORDS <EOL> def __init__ ( self , options = None ) : <EOL> super ( CppLanguageModel , self ) . __init__ ( class_name_delimiter = '<STR_LIT>' , <EOL> module_name_delimiter = '<STR_LIT:_>' ) <EOL> self . type_map = self . _BuildTypeMap ( options ) <EOL> self . _SUPPORTED_TYPES [ '<STR_LIT>' ] = self . _Boolean <EOL> self . _SUPPORTED_TYPES [ '<STR_LIT>' ] = self . _Int <EOL> def _BuildTypeMap ( self , options = None ) : <EOL> """<STR_LIT>""" <EOL> self . global_namespace_ = '<STR_LIT>' <EOL> self . client_namespace_ = '<STR_LIT>' <EOL> builtin_type_h = None <EOL> integral_type_h = '<STR_LIT>' <EOL> json_type_h = '<STR_LIT>' <EOL> date_time_h = '<STR_LIT>' <EOL> date_h = date_time_h <EOL> self . date_namespace_ = self . client_namespace_ <EOL> return { <EOL> ( '<STR_LIT>' , None ) : ( '<STR_LIT:bool>' , ImportDefinition ( [ builtin_type_h ] ) ) , <EOL> ( '<STR_LIT>' , None ) : ( self . client_namespace_ + '<STR_LIT>' , <EOL> ImportDefinition ( [ json_type_h ] ) ) , <EOL> ( '<STR_LIT>' , None ) : ( '<STR_LIT>' , ImportDefinition ( [ integral_type_h ] ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : ( '<STR_LIT>' , ImportDefinition ( [ integral_type_h ] ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : ( '<STR_LIT>' , ImportDefinition ( [ integral_type_h ] ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : ( '<STR_LIT>' , ImportDefinition ( [ integral_type_h ] ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : ( '<STR_LIT>' , ImportDefinition ( [ integral_type_h ] ) ) , <EOL> ( '<STR_LIT>' , None ) : ( '<STR_LIT>' , ImportDefinition ( [ builtin_type_h ] ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) : ( '<STR_LIT>' , ImportDefinition ( [ builtin_type_h ] ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:float>' ) : ( '<STR_LIT:float>' , ImportDefinition ( [ builtin_type_h ] ) ) , <EOL> ( '<STR_LIT:object>' , None ) : ( self . client_namespace_ + '<STR_LIT>' , <EOL> ImportDefinition ( [ json_type_h ] ) ) , <EOL> ( '<STR_LIT:string>' , None ) : ( '<STR_LIT:string>' , ImportDefinition ( [ '<STR_LIT>' ] ) ) , <EOL> ( '<STR_LIT:string>' , '<STR_LIT>' ) : ( '<STR_LIT:string>' , ImportDefinition ( [ '<STR_LIT>' ] ) ) , <EOL> ( '<STR_LIT:string>' , '<STR_LIT:date>' ) : ( self . date_namespace_ + '<STR_LIT>' , <EOL> ImportDefinition ( [ date_h ] ) ) , <EOL> ( '<STR_LIT:string>' , '<STR_LIT>' ) : ( self . client_namespace_ + '<STR_LIT>' , <EOL> ImportDefinition ( [ date_time_h ] ) ) , <EOL> ( '<STR_LIT:string>' , '<STR_LIT>' ) : ( '<STR_LIT:string>' , <EOL> ImportDefinition ( [ '<STR_LIT>' ] ) ) , <EOL> ( '<STR_LIT:string>' , '<STR_LIT>' ) : ( '<STR_LIT:string>' , <EOL> ImportDefinition ( [ '<STR_LIT>' ] ) ) , <EOL> ( '<STR_LIT:string>' , '<STR_LIT>' ) : ( '<STR_LIT>' , ImportDefinition ( [ integral_type_h ] ) ) , <EOL> ( '<STR_LIT:string>' , '<STR_LIT>' ) : ( '<STR_LIT>' , ImportDefinition ( [ integral_type_h ] ) ) , <EOL> } <EOL> def _Boolean ( self , data_value ) : <EOL> """<STR_LIT>""" <EOL> return unicode ( bool ( data_value . value ) ) . lower ( ) <EOL> def _Int ( self , data_value ) : <EOL> """<STR_LIT>""" <EOL> code_types = { <EOL> '<STR_LIT>' : '<STR_LIT:%s>' , <EOL> '<STR_LIT>' : '<STR_LIT:%s>' , <EOL> '<STR_LIT>' : '<STR_LIT:%s>' , <EOL> '<STR_LIT>' : '<STR_LIT:%s>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> try : <EOL> return code_types [ data_value . code_type ] % long ( data_value . value ) <EOL> except KeyError : <EOL> raise ValueError ( <EOL> ( '<STR_LIT>' <EOL> '<STR_LIT>' ) % <EOL> ( data_value . value , data_value . code_type ) ) <EOL> def GetCodeTypeFromDictionary ( self , def_dict ) : <EOL> """<STR_LIT>""" <EOL> json_type = def_dict . get ( '<STR_LIT:type>' , '<STR_LIT:string>' ) <EOL> json_format = def_dict . get ( '<STR_LIT>' ) <EOL> datatype_and_imports = self . type_map . get ( ( json_type , json_format ) ) <EOL> if datatype_and_imports : <EOL> native_format = datatype_and_imports [ <NUM_LIT:0> ] <EOL> else : <EOL> native_format = utilities . CamelCase ( json_type ) <EOL> return native_format <EOL> def ArrayOf ( self , unused_variable , type_name ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' % ( self . client_namespace_ , type_name ) <EOL> def MapOf ( self , unused_variable , type_name ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' % ( <EOL> self . client_namespace_ , type_name ) <EOL> def ToMemberName ( self , s , the_api ) : <EOL> """<STR_LIT>""" <EOL> camel_s = utilities . CamelCase ( s ) <EOL> if s . lower ( ) in CppLanguageModel . RESERVED_CLASS_NAMES : <EOL> return '<STR_LIT>' % ( the_api . values [ '<STR_LIT:name>' ] , camel_s ) <EOL> return camel_s [ <NUM_LIT:0> ] . lower ( ) + camel_s [ <NUM_LIT:1> : ] <EOL> def ToSafeClassName ( self , s , the_api , parent = None ) : <EOL> """<STR_LIT>""" <EOL> safe_class_name = utilities . CamelCase ( s ) <EOL> if parent : <EOL> for ancestor in parent . full_path : <EOL> if ancestor . class_name == safe_class_name : <EOL> safe_class_name = '<STR_LIT>' % ( parent . class_name , safe_class_name ) <EOL> if safe_class_name . lower ( ) in CppLanguageModel . RESERVED_CLASS_NAMES : <EOL> safe_class_name = '<STR_LIT>' % ( utilities . CamelCase ( the_api . values [ '<STR_LIT:name>' ] ) , <EOL> utilities . CamelCase ( s ) ) <EOL> return safe_class_name <EOL> def DefaultContainerPathForOwner ( self , module ) : <EOL> """<STR_LIT>""" <EOL> result = '<STR_LIT>' <EOL> if FLAGS . cpp_generator_add_owner_dir : <EOL> result = module . owner_name . lower ( ) . replace ( '<STR_LIT:U+0020>' , '<STR_LIT:_>' ) <EOL> return result <EOL> class CppApi ( api . Api ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , discovery_doc , ** unused_kwargs ) : <EOL> super ( CppApi , self ) . __init__ ( discovery_doc ) <EOL> base = self . values [ '<STR_LIT:name>' ] <EOL> self . module . SetPath ( base . lower ( ) + '<STR_LIT>' ) <EOL> self . SetTemplateValue ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . SetTemplateValue ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . SetTemplateValue ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . SetTemplateValue ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . SetTemplateValue ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . SetTemplateValue ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def TopLevelModelClasses ( self ) : <EOL> """<STR_LIT>""" <EOL> return [ m for m in self . ModelClasses ( ) <EOL> if not m . parent and not isinstance ( m , data_types . ArrayDataType ) ] <EOL> def ToClassName ( self , s , element , element_type = None ) : <EOL> """<STR_LIT>""" <EOL> s = utilities . CamelCase ( s ) <EOL> if s in CppLanguageModel . RESERVED_CLASS_NAMES : <EOL> s = '<STR_LIT>' % ( utilities . CamelCase ( self . values [ '<STR_LIT:name>' ] ) , s ) <EOL> decorator = '<STR_LIT>' <EOL> if isinstance ( element , api . Method ) : <EOL> resource = element . parent <EOL> while isinstance ( resource , api . Resource ) : <EOL> s = '<STR_LIT>' % ( resource . values [ '<STR_LIT>' ] , s ) <EOL> resource = resource . parent <EOL> decorator = '<STR_LIT>' <EOL> elif isinstance ( element , api . Resource ) : <EOL> decorator = '<STR_LIT>' <EOL> elif isinstance ( element , api . Api ) : <EOL> if not s . endswith ( '<STR_LIT>' ) : <EOL> decorator = '<STR_LIT>' <EOL> else : <EOL> return s <EOL> return '<STR_LIT>' % ( s , decorator ) </s>
