本文整理汇总了Python中skrutil.string_utils.indent函数的典型用法代码示例。如果您正苦于以下问题:Python indent函数的具体用法?Python indent怎么用?Python indent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了indent函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __native_constructor_with_variable
def __native_constructor_with_variable(self):
space_str = ''
native_constructor = indent(4) + 'private native long nativeCreate{0}('.format(self.__class_name)
for space_index in range(0, len(indent(4) + 'private native long nativeCreate{0}('.format(self.__class_name))):
space_str += ' '
for index in range(0, len(self.__java_var_list)):
java_var = self.__java_var_list[index]
java_var_type = java_var.var_type
if index == 0:
if java_var_type == VarType.cpp_enum:
native_constructor += 'int {0},\n'.format(java_var.name_str)
elif java_var_type == VarType.cpp_string_array:
native_constructor += 'String[] {0},\n'.format(java_var.name_str)
else:
native_constructor += '{0} {1},\n'.format(java_var.var_type.to_java_getter_setter_string(), java_var.name_str)
else:
if java_var_type == VarType.cpp_enum:
native_constructor += space_str + 'int {0},\n'.format(java_var.name_str)
elif java_var_type == VarType.cpp_string_array:
native_constructor += space_str + 'String[] {0},\n'.format(java_var.name_str)
else:
native_constructor += space_str + '{0} {1},\n'.format(java_var.var_type.to_java_getter_setter_string(), java_var.name_str)
native_constructor = native_constructor[:-2]
native_constructor += ');' + _JAVA_BR
return native_constructor
开发者ID:DaYeSquad,项目名称:worktilerwdemo,代码行数:25,代码来源:java_class.py
示例2: __constructor_with_variable
def __constructor_with_variable(self):
constructor = indent(4) + 'public {0}('.format(self.__class_name)
space = len(indent(4) + 'public {0}('.format(self.__class_name))
space_str = ''
for space_index in range(0, space):
space_str += ' '
for index in range(0, len(self.__java_var_list)):
java_var = self.__java_var_list[index]
java_var_type = java_var.var_type
if index == 0:
if java_var_type == VarType.cpp_enum:
constructor += '{0} {1},\n'.format(java_var.java_enum, java_var.name_str)
elif java_var_type == VarType.cpp_string_array:
constructor += 'String[] {0},\n'.format(java_var.name_str)
else:
constructor += '{0} {1},\n'.format(java_var.var_type.to_java_getter_setter_string(), java_var.name_str)
else:
if java_var_type == VarType.cpp_enum:
constructor += space_str + '{0} {1},\n'.format(java_var.java_enum, java_var.name_str)
elif java_var_type == VarType.cpp_string_array:
constructor += space_str + 'String[] {0},\n'.format(java_var.name_str)
else:
constructor += space_str + '{0} {1},\n'.format(java_var.var_type.to_java_getter_setter_string(), java_var.name_str)
constructor = constructor[:-2]
constructor += '){\n'
constructor += indent(2) + 'mNativeHandler = nativeCreate{0}('.format(self.__class_name)
for java_var in self.__java_var_list:
if java_var.var_type == VarType.cpp_enum:
constructor += java_var.name_str + '.getValue(), '
else:
constructor += java_var.name_str + ', '
constructor = constructor[:-2]
constructor += ');\n'
constructor += indent(4) + '}' + _JAVA_BR
return constructor
开发者ID:DaYeSquad,项目名称:worktilerwdemo,代码行数:35,代码来源:java_class.py
示例3: __http_function
def __http_function(self, api):
http_function = indent(4) + 'public void ' + string_utils.first_char_to_lower(api.function_name)
input_variable = self.__input_variable_declarations(api.input_var_list)
http_function += '({0}{1}response){{\n'\
.format(input_variable, self.__variable_type_from_var_list(api.output_var_list))
http_function += indent(8) + 'm{0}Response'.format(api.function_name) + ' = response;\n'
for variable in api.input_var_list:
if variable.var_type == VarType.cpp_enum:
http_function += indent(8) + 'int {0} = {1}.getValue();\n'\
.format(variable.name_str + "_int", variable.name_str)
if variable.var_type == VarType.cpp_object:
http_function += indent(8) + 'long {0} = {1}.getNativeHandler();\n'\
.format(variable.name_str + '_handler', variable.name_str)
if variable.var_type == VarType.cpp_object_array:
http_function += indent(8) + 'long[] {0} = new long[{1}.size()];\n'\
.format(variable.name_str + '_handler', variable.name_str)
http_function += indent(8) + 'for (int i = 0; i < {0}.size(); i++){{\n'.format(variable.name_str)
http_function += indent(12) + '{0}[i] = {1}.get(i).getNativeHandler();\n'\
.format(variable.name_str + '_handler', variable.name_str)
http_function += indent(8) + '}'
input_variable_call = self.__input_variable_call(api.input_var_list)
http_function += indent(8) + 'native{0}(mNativeHandler{1});\n'\
.format(api.function_name, input_variable_call)
http_function += indent(4) + "}"
return http_function
开发者ID:zhangsiqigithub,项目名称:cpp-core-model-builder,代码行数:25,代码来源:java_manager.py
示例4: generate_fetch_native
def generate_fetch_native(self):
"""Gets fetch method JNI part implementation code. Paris with <generate_fetch>.
Returns:
Implementation of JNI part of fetch methods.
"""
fetch_function = ''
for fetch_command in self.__fetch_commands:
by_list = []
if fetch_command.where != '':
by_list = re.split(',', fetch_command.where)
if fetch_command.alias != '':
fetch_fun_name_native = fetch_command.alias
elif not fetch_command.is_plural:
fetch_fun_name_native = 'Fetch{0}FromCache'.format(self.__object_name)
else:
fetch_fun_name_native = 'Fetch{0}FromCache'.format(self.__plural_object_name)
if not fetch_command.is_plural:
if len(by_list) == 0:
skr_log_warning('Singular often comes with at least one by parameter')
fetch_function += indent(4) + 'private native long native' + fetch_fun_name_native
fetch_function += self.__convert_bys_to_string(by_list, True, False) + ';' + _JAVA_BR
else:
fetch_function += indent(4) + 'private native long[] native' + fetch_fun_name_native
fetch_function += self.__convert_bys_to_string(by_list, True, False) + ';' + _JAVA_BR
return fetch_function
开发者ID:zhangsiqigithub,项目名称:cpp-core-model-builder,代码行数:28,代码来源:java_manager.py
示例5: __manager_http_implementation
def __manager_http_implementation(self, api_description):
capture_parameters = ''
input_parameters = ''
for input_var in api_description.input_var_list:
input_parameters += input_var.name + ', '
if input_var.capture:
capture_parameters += input_var.name + ', '
output_callback_parameters = ''
output_parameters = '(bool success, const std::string &error'
if len(api_description.output_var_list) > 0:
for output_var in api_description.output_var_list:
output_parameters += ', '
output_parameters += output_var.to_set_description_string()
output_callback_parameters += ', '
output_callback_parameters += output_var.to_move_string()
output_parameters += ')'
impl = string_utils.indent(2) + 'WebApi::Api()->{0}({1}[{3}this, callback]{2} {{\n'.format(api_description.name, input_parameters, output_parameters, capture_parameters)
impl += string_utils.indent(4) + 'if (success) {\n'
for output_var in api_description.output_var_list:
impl += self.__cpp_cache_by_cache_description_name(output_var.cache_desc, output_var.name)
for extra in api_description.extra_list:
impl += self.__cpp_cache_by_cache_description_name(extra)
impl += string_utils.indent(4) + '}\n'
impl += string_utils.indent(4) + 'callback(success, error{0});\n'.format(output_callback_parameters)
impl += string_utils.indent(2) + '});'
return impl
开发者ID:daydayup9,项目名称:cpp-core-model-builder,代码行数:34,代码来源:cpp_manager.py
示例6: getter
def getter(self):
"""Getter method using JNI.
New development should use <getter_v2>.
Returns:
Java getter method using JNI. For example:
public int getPosition() {
return nativeGetPosition(mNativeHandler);
}
"""
function_str = ''
if self.__var_type == VarType.cpp_bool:
function_str += indent(1) + 'public {0} is{1}() {{\n'\
.format(self.__var_type.to_java_getter_setter_string(), self.__title_style_name)
function_str += indent(2) + 'return nativeIs{0}(mNativeHandler);\n'.format(self.__title_style_name)
function_str += indent(1) + '}'
elif self.__var_type == VarType.cpp_string_array:
function_str += self.__to_get_list_of_string_implementation()
elif self.__var_type == VarType.cpp_enum:
function_str += indent(1) + 'public {0} get{1}() {{\n'.format(self.__java_enum, self.__title_style_name)
function_str += indent(2) + 'return {0}.get{0}ByValue(nativeGet{1}(mNativeHandler));\n'\
.format(self.__java_enum, self.__title_style_name)
function_str += indent(1) + '}'
else:
function_str += indent(1) + 'public {0} get{1}() {{\n'.\
format(self.__var_type.to_java_getter_setter_string(), self.__title_style_name)
function_str += indent(2) + 'return nativeGet{0}(mNativeHandler);\n'.format(self.__title_style_name)
function_str += indent(1) + '}'
return function_str
开发者ID:DaYeSquad,项目名称:worktilerwdemo,代码行数:31,代码来源:java_variable.py
示例7: generate_constructor_implementation
def generate_constructor_implementation(self):
impl = '- (instancetype)init {\n'
impl += string_utils.indent(2)
impl += 'if (self = [super init]) {\n'
impl += string_utils.indent(4)
impl += '_coreManagerHandler = lesschat::{0}Manager::DefaultManager();\n'.format(self.object_name)
impl += string_utils.indent(2)
impl += '}\n'
impl += string_utils.indent(2)
impl += 'return self;\n'
impl += '}'
return impl
开发者ID:daydayup9,项目名称:cpp-core-model-builder,代码行数:12,代码来源:objc_manager.py
示例8: generate_java
def generate_java(self):
"""Gets Java with JNI implementation. The class inherits from |CoreObject| which means invoker should release
the object himself/herself by calling |CoreObject.dispose()|.
New development should use <generate_java_v2> instead.
Returns:
A string which is the class implementation.
"""
file_name = self.__class_name + '.java'
file_path = 'build/com/lesschat/core/' + self.__group_name + '/' + file_name
output_java = open(file_path, 'w')
java_package = 'package com.lesschat.core.' + self.__group_name + ';'
output_java.write(java_package + _JAVA_BR)
java_import = 'import android.os.Parcel;\n'
java_import += 'import android.os.Parcelable;' + _JAVA_BR
java_import += 'import com.lesschat.core.jni.CoreObject;' + _JAVA_BR
java_import += 'import java.util.ArrayList;\n'
java_import += 'import java.util.Arrays;\n'
if self.__class_name != 'List':
java_import += 'import java.util.List;'
java_class_start = 'public class ' + self.__class_name + ' extends CoreObject implements Parcelable {'
java_class_end = '}'
output_java.write(java_import + _JAVA_BR)
output_java.write(java_class_start + _JAVA_BR)
output_java.write(self.__constructors())
output_java.write(indent(4) + '@Override\n')
output_java.write(indent(4) + 'public void dispose() {\n')
output_java.write(indent(2) + 'nativeRelease{0}(mNativeHandler);\n'.format(self.__class_name))
output_java.write(indent(4) + '}' + _JAVA_BR)
for java_enum in self.__java_enum_list:
output_java.write(java_enum.generate_java_enum(_JAVA_SPACE) + '\n')
for java_var in self.__java_var_list:
output_java.write(java_var.getter() + _JAVA_BR)
output_java.write(_JAVA_BR)
output_java.write(self.__native_constructors())
output_java.write(indent(4) + 'private native void nativeRelease{0}(long handler);'.format(self.__class_name) + _JAVA_BR)
for java_var in self.__java_var_list:
output_java.write(java_var.native_getter() + _JAVA_BR)
output_java.write(self.__parcelable())
output_java.write(java_class_end)
开发者ID:DaYeSquad,项目名称:worktilerwdemo,代码行数:52,代码来源:java_class.py
示例9: __http_function_response_v2
def __http_function_response_v2(self, api):
http_function_response = indent(4) + 'public void on{0}(boolean success, String error{1}){{\n' \
.format(api.function_name, self.__output_variable_declaration_v2(api.output_var_list))
http_function_response += indent(8) + 'if (m{0}Response == null){{\n'.format(api.function_name)
http_function_response += indent(12) + 'return;\n'
http_function_response += indent(8) + '}\n'
http_function_response += indent(8) + 'if (success){\n'
http_function_response += indent(12) + 'm{0}Response.onSuccess({1});\n' \
.format(api.function_name, self.__output_variable_call(api.output_var_list))
http_function_response += indent(8) + '} else {\n'
http_function_response += indent(12) + 'm{0}Response.onFailure(error);\n'.format(api.function_name)
http_function_response += indent(8) + '}\n'
http_function_response += indent(4) + '}'
return http_function_response
开发者ID:DaYeSquad,项目名称:worktilerwdemo,代码行数:14,代码来源:java_manager.py
示例10: objc_form_cpp_parameter
def objc_form_cpp_parameter(self, indent):
objc_code = ''
if self.var_type == VarType.cpp_object_array:
objc_code += string_utils.indent(indent)
objc_code += 'NSMutableArray *{0} = [NSMutableArray array];\n'.format(self.__objc_name())
objc_code += string_utils.indent(indent)
objc_code += 'for (auto it = core{0}.begin(); it != core{0}.end(); ++it) {{\n'.format(self.to_title_style_name())
objc_code += string_utils.indent(2 + indent)
objc_code += '[{0} addObject:[LCC{1} {2}WithCore{1}:**it]];\n'.format(self.__objc_name(), self.var_type.object_class_name, string_utils.first_char_to_lower(self.var_type.object_class_name))
objc_code += string_utils.indent(indent)
objc_code += '}'
elif self.var_type == VarType.cpp_object:
objc_code += string_utils.indent(indent)
objc_code += 'LCC{0} *{1} = [LCC{0} {1}WithCore{0}:*core{0}];'.format(self.var_type.object_class_name, self.__objc_name())
return objc_code
开发者ID:daydayup9,项目名称:cpp-core-model-builder,代码行数:15,代码来源:objc_variable.py
示例11: __constructors
def __constructors(self):
"""Java class constructor with native handler as parameter.
Returns:
A string which is the implementation of the constructor. For example:
public Task(long nativeHandler) {
mNativeHandler = nativeHandler;
}
"""
constructor = indent(4) + 'public {0}() {{ \n mNativeHandler = nativeCreate{0}(); \n }}'\
.format(self.__class_name) + _JAVA_BR
constructor += indent(4) + 'public {0}(long nativeHandler) {{\n'.format(self.__class_name)
constructor += indent(2) + 'mNativeHandler = nativeHandler;\n'
constructor += indent(4) + '}\n\n'
return constructor
开发者ID:DaYeSquad,项目名称:worktilerwdemo,代码行数:16,代码来源:java_class.py
示例12: generate_web_api_implementations
def generate_web_api_implementations(self, config):
"""Generates Objective-C++ web api implementations.
Args:
config: A <Config> object represents user-defined info.
Returns:
A string which is Objective-C++ web api implementations.
"""
impl = ''
for api in self.apis:
impl += self.__web_api_declaration(api, config)
impl += ' {\n'
impl += string_utils.indent(2)
impl += '_coreManagerHandler->\n'
impl += string_utils.indent(2)
impl += api.alias + '('
for input_var in api.input_var_list:
impl += input_var.cast_to_cpp_parameter()
impl += ', '
impl += '[successBlock, failureBlock](bool success, const std::string& errorUTF8String'
for output_var in api.output_var_list:
impl += ', {0}'.format(output_var.objc_wrapper_from_cpp_parameter(config))
impl += ') {\n'
impl += string_utils.indent(4)
impl += 'if (success) {\n'
for output_var in api.output_var_list:
impl += output_var.objc_form_cpp_parameter(6, config)
impl += _OBJC_BR
impl += string_utils.indent(6)
impl += 'successBlock('
for i, output_var in enumerate(api.output_var_list):
if i != 0:
impl += ', '
impl += string_utils.to_objc_property_name(output_var.name)
impl += ');\n'
impl += string_utils.indent(4)
impl += '} else {\n'
impl += string_utils.indent(6)
impl += 'NSString *error = [NSString stringWithUTF8String:errorUTF8String.c_str()];\n'
impl += string_utils.indent(6)
impl += 'failureBlock({0}(error));\n'.format(config.objc_error_method)
impl += string_utils.indent(4)
impl += '}\n'
impl += string_utils.indent(2)
impl += '});\n}'
impl += _OBJC_BR
return impl
开发者ID:DaYeSquad,项目名称:worktilerwdemo,代码行数:51,代码来源:objc_manager.py
示例13: __to_get_list_of_string_implementation
def __to_get_list_of_string_implementation(self):
function = indent(1) + 'public List<String> get{0}() {{\n'.format(self.__title_style_name)
function += indent(2) + 'String[] strs = nativeGet{0}(mNativeHandler);\n'.format(self.__title_style_name)
function += indent(2) + 'if (strs == null) {\n'
function += indent(3) + 'return new ArrayList<String>();\n'
function += indent(2) + '}\n'
function += indent(2) + 'List<String> list = new ArrayList<String>(Arrays.asList(strs));\n'
function += indent(2) + 'return list;\n'
function += indent(1) + "}"
return function
开发者ID:DaYeSquad,项目名称:worktilerwdemo,代码行数:10,代码来源:java_variable.py
示例14: native_getter
def native_getter(self):
"""Gets Java native getter.
Returns:
Java native getter. For example:
private native String nativeGetTaskId(long handler);
"""
if self.__var_type == VarType.cpp_bool:
return indent(1) + 'private native {0} nativeIs{1}(long handler);'.format(
self.__var_type.to_java_getter_setter_string(), self.__title_style_name)
elif self.__var_type == VarType.cpp_string_array:
return indent(1) + 'private native String[] nativeGet{0}(long handler);'.format(self.__title_style_name)
elif self.__var_type == VarType.cpp_enum:
return indent(1) + 'private native int nativeGet{0}(long handler);'.format(self.__title_style_name)
else:
return indent(1) + 'private native {0} nativeGet{1}(long handler);'.format(
self.__var_type.to_java_getter_setter_string(),self.__title_style_name)
开发者ID:DaYeSquad,项目名称:worktilerwdemo,代码行数:18,代码来源:java_variable.py
示例15: __constructors_v2
def __constructors_v2(self):
"""Java class constructor with all fields as parameters.
Returns:
A string which is the implementation of the constructor. For example:
/*package*/ File(String fileId,
@File.Type int type,
@File.Visibility int visibility,
@File.Belong int belong,
@File.FolderPermissionSetting int folderPermissionSetting,
String createdBy,
long createdAt,
String updatedBy,
long updatedAt) {
mFileId = fileId;
... Remainder omitted...
}
"""
package_class = indent(4) + '/*package*/ {0}'.format(self.__class_name)
num_line_indent = len(package_class) + 1
if len(self.__java_var_list) > 1:
first_var = self.__java_var_list[0].input_parameter_name()
constructor = '{0}({1},\n'.format(package_class, first_var)
for var in self.__java_var_list:
if first_var == var.input_parameter_name():
continue
constructor += indent(num_line_indent) + '{0},'.format(var.input_parameter_name()) + '\n'
constructor = constructor[:-2] # remove break line and last comma
elif len(self.__java_var_list) == 1:
first_var = self.__java_var_list[0].input_parameter_name()
constructor = '{0}({1})'.format(package_class, first_var)
else:
constructor = '{0}()'.format(package_class)
constructor += ') {\n'
for var in self.__java_var_list:
constructor += indent(8) + var.assignment() + '\n'
constructor += indent(4) + '}'
return constructor
开发者ID:DaYeSquad,项目名称:worktilerwdemo,代码行数:43,代码来源:java_class.py
示例16: generate_http_function_native
def generate_http_function_native(self):
"""Gets HTTP request native code.
Returns:
HTTP request native code.
"""
http_native_function = ''
for api in self.__apis:
http_native_function += indent(4) + 'private native void native{0}(long handler{1});\n\n' \
.format(api.function_name, self.__input_variable_declarations_native(api.input_var_list))
return http_native_function
开发者ID:zhangsiqigithub,项目名称:cpp-core-model-builder,代码行数:11,代码来源:java_manager.py
示例17: generate_constructor_implementation
def generate_constructor_implementation(self, config):
"""Generates Objective-C++ init method.
Args:
config: A <Config> object represents user-defined info.
Returns:
Objective-C++ init method.
"""
impl = '- (instancetype)init {\n'
impl += string_utils.indent(2)
impl += 'if (self = [super init]) {\n'
impl += string_utils.indent(4)
impl += '_coreManagerHandler = {1}::{0}Manager::DefaultManager();\n'.format(self.object_name,
config.cpp_namespace)
impl += string_utils.indent(2)
impl += '}\n'
impl += string_utils.indent(2)
impl += 'return self;\n'
impl += '}'
return impl
开发者ID:DaYeSquad,项目名称:worktilerwdemo,代码行数:21,代码来源:objc_manager.py
示例18: __generate_post_or_put_body
def __generate_post_or_put_body(self, api_description):
if api_description.method == 'POST' or api_description.method == 'PUT':
valid_var_list = []
for input_var in api_description.input_var_list:
if input_var.json_path is not None and input_var.json_path != '':
valid_var_list.append(input_var)
if len(valid_var_list) == 0:
return ''
body = string_utils.indent(2) + 'json11::Json put_or_post_json = json11::Json::object {\n'
for var in valid_var_list:
json_paths = re.split('/', var.json_path)
if len(json_paths) > 2:
print 'We do not support ugly json which has more than 2 levels'
assert False
elif len(json_paths) == 1:
body += string_utils.indent(4) + '{{ "{0}", {1} }},\n'.format(var.json_path, var.to_json11_type())
elif len(json_paths) == 2:
body += string_utils.indent(4) + '{{ "{0}", json11::Json::object {{{{ "{1}", {2} }}}} }},\n'.format(json_paths[0], json_paths[1], var.to_json11_type())
body += string_utils.indent(2) + '};\n'
body += string_utils.indent(2) + 'string put_or_post_json_str = put_or_post_json.dump();' + _CPP_BR
body += string_utils.indent(2) + 'request->set_request_data(put_or_post_json_str);' + _CPP_BR
return body
else:
print 'Only PUT or POST method can have request_body'
return ''
开发者ID:daydayup9,项目名称:cpp-core-model-builder,代码行数:27,代码来源:cpp_manager.py
示例19: parse_json
def parse_json(self, indent=0):
if self.json_path == '':
return ''
json_paths = re.split('/', self.json_path)
cpp_json_paths = ''
for json_path in json_paths:
cpp_json_paths += '["{0}"]'.format(json_path)
if self.var_type == VarType.cpp_enum: # need cast
return '{0}_ = static_cast<{3}>(json_obj{1}.{2});'.format(self.name,
cpp_json_paths,
self.var_type.to_json_value_type(),
self.var_type.cpp_enum_type_string())
elif self.var_type == VarType.cpp_string_array: # array_items use another parse style
parse = '{0}_.clear();\n'.format(self.name)
parse += ' vector<json11::Json> {0}_json = json_obj{1}.array_items();\n'.format(self.name, cpp_json_paths)
parse += ' for (auto it = {0}_json.begin(); it != {0}_json.end(); ++it) {{\n'.format(self.name)
parse += ' {0}_.push_back((*it){1}.string_value());\n'.format(self.name, self.var_type.cpp_json11_array_it_search_string())
parse += ' }\n'
return parse
elif self.var_type == VarType.cpp_bool: # bool value should compact with int_value == 1
parse = 'json11::Json {0}_json = json_obj{1};\n'.format(self.name, cpp_json_paths)
parse += ' if ({0}_json.type() == json11::Json::Type::BOOL) {{\n'.format(self.name)
parse += ' {0}_ = {0}_json.bool_value();\n'.format(self.name)
parse += ' } else {\n'
parse += ' {0}_ = ({0}_json.int_value() == 1);\n'.format(self.name)
parse += ' }\n'
return parse
elif self.var_type == VarType.cpp_object: # C++ object
parse = string_utils.indent(indent) + 'unique_ptr<{0}> {1}(new {0}());\n'.format(self.var_type.object_class_name, self.name)
parse += string_utils.indent(indent) + '{0}->InitWithJsonOrDie(json_obj{1}.dump());\n'.format(self.name, cpp_json_paths)
return parse
elif self.var_type == VarType.cpp_object_array: # C++ objects
parse = string_utils.indent(indent) + 'vector<unique_ptr<{0}>> {1};\n'.format(self.var_type.object_class_name, self.name)
parse += string_utils.indent(indent) + 'vector<json11::Json> {0}_jsons = json_obj{1}.array_items();\n'.format(self.name, cpp_json_paths)
parse += string_utils.indent(indent) + 'for (auto json : {0}_jsons) {{\n'.format(self.name)
parse += string_utils.indent(indent + 2) + 'unique_ptr<{0}> obj(new {0}());\n'.format(self.var_type.object_class_name)
parse += string_utils.indent(indent + 2) + 'obj->InitWithJsonOrDie(json.dump());\n'
parse += string_utils.indent(indent + 2) + '{0}.push_back(std::move(obj));\n'.format(self.name)
parse += string_utils.indent(indent) + '}\n'
return parse
else:
return '{0}_ = json_obj{1}.{2};'.format(self.name, cpp_json_paths, self.var_type.to_json_value_type())
开发者ID:daydayup9,项目名称:cpp-core-model-builder,代码行数:44,代码来源:cpp_variable.py
示例20: generate_web_api_implementations
def generate_web_api_implementations(self):
impl = ''
for api in self.apis:
impl += self.__web_api_declaration(api)
impl += ' {\n'
impl += string_utils.indent(2)
impl += '_coreManagerHandler->\n'
impl += string_utils.indent(2)
impl += api.alias + '('
for input_var in api.input_var_list:
impl += input_var.cast_to_cpp_parameter()
impl += ', '
impl += '[successBlock, failureBlock](bool success, const std::string& errorUTF8String'
for output_var in api.output_var_list:
impl += ', {0}'.format(output_var.objc_wrapper_from_cpp_parameter())
impl += ') {\n'
impl += string_utils.indent(4)
impl += 'if (success) {\n'
for output_var in api.output_var_list:
impl += output_var.objc_form_cpp_parameter(6)
impl += _OBJC_BR
impl += string_utils.indent(6)
impl += 'successBlock('
for i, output_var in enumerate(api.output_var_list):
if i != 0:
impl += ', '
impl += string_utils.to_objc_property_name(output_var.name)
impl += ');\n'
impl += string_utils.indent(4)
impl += '} else {\n'
impl += string_utils.indent(6)
impl += 'NSString *error = [NSString stringWithUTF8String:errorUTF8String.c_str()];\n'
impl += string_utils.indent(6)
impl += 'failureBlock(LCCErrorWithNSString(error));\n'
impl += string_utils.indent(4)
impl += '}\n'
impl += string_utils.indent(2)
impl += '});\n}'
impl += _OBJC_BR
return impl
开发者ID:daydayup9,项目名称:cpp-core-model-builder,代码行数:43,代码来源:objc_manager.py
注:本文中的skrutil.string_utils.indent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论