diff --git a/MultiLang/English.cpp b/MultiLang/English.cpp index bd7785af..b4b07976 100644 --- a/MultiLang/English.cpp +++ b/MultiLang/English.cpp @@ -2,225 +2,225 @@ using namespace MultiLang; -static string bb_err = "Blitz Error"; -static string init_err = "Error when creating BlitzIDE process. Please make sure ide.exe is inside the \"bin\" folder."; -static string array_bounds_ex = "Blitz array index out of bounds."; -static string null_obj_ex = "Object does not exist!"; -static string bad_data_type = "Bad data type! Type is not a float, string or an integer."; -static string out_of_data = "Out of data!"; -static string stats_strings = "Active strings : {0}"; -static string stats_objects = "Active objects : {0}"; -static string stats_unreleased = "Unreleased objs: {0}"; -static string sound_not_exist = "Sound does not exist"; -static string bank_not_exist = "bbBank does not exist"; -static string offset_out_of_range = "Offset out of range"; -static string graphics_not_set = "3D Graphics mode not set."; -static string texture_not_exist = "Texture does not exist!"; -static string brush_not_exist = "Brush does not exist!"; -static string entity_not_exist = "Entity does not exist!"; -static string parent_entity_not_exist = "Parent entity does not exist."; -static string entity_not_mesh = "Entity is not a mesh!"; -static string entity_not_object = "Entity is not an object!"; -static string collision_out_of_range = "Collision index out of range."; -static string entity_not_camera = "Entity is not a camera!"; -static string entity_not_light = "Entity is not a light!"; -static string entity_not_model = "Entity is not a model!"; -static string entity_not_sprite = "Entity is not a sprite!"; -static string entity_not_md2_model = "Entity is not an MD2 Model!"; -static string entity_not_bsp_model = "Entity is not a BSP Model!"; -static string entity_not_terrain = "Entity is not a terrain!"; -static string illegal_number_segments = "Illegal number of segments!"; -static string vertex_out_of_range = "Vertex index out of range."; -static string texture_coordinate_out_of_range = "Texture coordinate set out of range."; -static string illegal_texture_frames = "Illegal number of texture frames!"; -static string mesh_cannot_add_to_self = "A mesh cannot be added to itself!"; -static string surface_out_of_range = "Surface Index out of range."; -static string illegal_terrain_size = "Illegal terrain size!"; -static string unable_load_heightmap = "Unable to load heightmap image."; -static string terrain_must_be_square = "Terrain must be square!"; -static string listener_already_created = "Listener already created!"; -static string no_listener_created = "No Listener created."; -static string entity_cannot_parented_itself = "Entity cannot be parented to itself!"; -static string entity_no_animations = "Entity has no animations."; -static string entity_not_model_or_camera = "Entity is not a model or camera!"; -static string entitytype_id_range = "EntityType ID must be a number from 0 to 999."; -static string unable_create_gxscene_instance = "Unable to create gxScene instance!"; -static string file_not_exist = "File does not exist"; -static string directory_not_exist = "Directory does not exist"; -static string image_not_exist = "Image doesn't exist."; -static string image_frame_out_of_range = "Image frame out of range!"; -static string font_not_exist = "Font doesn't exist."; -static string buffer_not_exist = "Buffer doesn't exist."; -static string illegal_graphics_driver_index = "Illegal graphics driver index."; -static string illegal_graphics_mode_index = "Illegal graphics mode index."; -static string unable_create_gxgraphics_instance = "Unable to create a gxGraphics instance."; -static string illegal_graphics_mode = "Illegal Graphics mode. Graphics modes are 0, 1, 2, 3, 4, 6 and 7."; -static string illegal_graphics3d_mode = "Illegal Graphics3D mode. Graphics modes are 0, 1, 2, 3, 4, 6 and 7."; -static string unable_close_gxgraphics_instance = "Unable to close gxGraphics instance."; -static wstring opencc_configure_not_found = L"OpenCC configure not found!"; -static wstring runtime_error = L"Catactrophic Error!"; -static string illegal_frame_count = "Illegal frame count!"; -static string illegal_first_frame = "Illegal first frame!"; -static string not_enough_frames_bitmap = "Not enough frames in bitmap."; -static string udp_stream_not_exist = "UDP Stream does not exist"; -static string tcp_stream_not_exist = "TCP Stream does not exist"; -static string tcp_server_not_exist = "TCP Server does not exist"; -static string host_out_of_range = "Host index out of range"; -static string stream_not_exist = "Stream does not exist"; -static string readbyte_invalid_byte = "ReadByte couldn't read a valid byte.\nMake sure the file you attempted to read isn't corrupted."; -static string readshort_invalid_short = "ReadShort couldn't read a valid short.\nMake sure the file you attempted to read isn't corrupted."; -static string readint_invalid_int = "ReadInt couldn't read a valid integer.\nMake sure the file you attempted to read isn't corrupted."; -static string readfloat_invalid_float = "ReadFloat couldn't read a valid float.\nMake sure the file you attempted to read isn't corrupted."; -static string readstring_invalid_string = "ReadString couldn't read a valid string.\nMake sure the file you attempted to read isn't corrupted."; -static string illegal_buffer_size = "Illegal buffer size"; -static string string_parameter_positive = "{0}: parameter must be positive"; -static string string_parameter_greater = "{0}: parameter must be greater than 0"; -static string userlib_not_found = "User lib not found"; -static string userlib_function_not_found = "User lib function not found"; -static string integer_divide_zero = "Integer divide by zero."; -static string memory_access_violation = "Memory Access Violation!\nThe program attempted to read or write to a protected memory address."; -static string illegal_instruction = "Illegal instruction.\nProcess tried to execute an invalid CPU instruction."; -static string stack_overflow = "Stack overflow.\nMake sure there is no recursion without a base case."; -static string integer_overflow = "Integer overflow!\nMake sure the integer doesnt exceed a value of 2147483647."; -static string float_overflow = "Float overflow!\nMake sure the float doesn't exceed a value of 3.40282347e+38F."; -static string float_divide_zero = "Float divide by zero."; -static string unknown_runtime_exception = "Unknown runtime exception."; -static string unable_run_module = "Unable to run Blitz Basic module."; -static string cant_find_symbol = "Can't find symbol: {0}"; -static string blitz3d_message = "Blitz3D Message"; -static string created_with_beta = "Created with Blitz3D Beta V{0}.{1}"; -static string expect_identifier = "expecting identifier after '.'"; -static string expect_string_afrer_directive = "expecting string after lib directive"; -static string unknown_decl_directive = "unknown decl directive"; -static string function_decl_without_directive = "function decl without lib directive"; -static string duplicate_identifier = "duplicate identifier"; -static string expect_left_bracket_after_function_identifier = "expecting '(' after function identifier"; -static string expect_right_bracket_after_function_identifier = "expecting ')' after function decl"; -static string expect_identifier_or_string_after_alias = "expecting identifier or string after alias"; -static string unable_open_linker_dll = "Unable to open linker.dll"; -static string error_in_linker_dll = "Error in linker.dll"; -static string unable_open_runtime_dll = "Unable to open runtime.dll"; -static string error_in_runtime_dll = "Error in runtime.dll"; -static string library_version_error = "Library version error"; -static string immediate_value_cannot_by_label = "immediate value cannot by a label"; -static string operand_must_be_immediate = "operand must be immediate"; -static string unrecognized_instruction = "unrecognized instruction"; -static string illegal_addressing_mode = "illegal addressing mode"; -static string operand_error = "operand error"; -static string duplicate_label = "duplicate label"; -static string missing_close_quote = "missing close quote"; -static string expect_comma = "expecting ','"; -static string too_many_operands = "Too many operands"; -static string expression_must_be_constant = "Expression must be constant"; -static string constants_must_initialized = "Constants must be initialized"; -static string duplicate_variable_name = "Duplicate variable name"; -static string undefined_label = "Undefined label"; -static string data_expression_must_be_constant = "Data expression must be constant"; -static string blitz_array_sizes_must_be_constant = "Blitz array sizes must be constant"; -static string blitz_array_sizes_must_not_negative = "Blitz array sizes must not be negative"; -static string illegal_type_conversion = "Illegal type conversion ({0} -> {1})"; -static string too_many_parameters = "Too many parameters"; -static string not_enough_parameters = "Not enough parameters"; -static string function_not_found = "Function '{0}' not found"; -static string incorrect_function_return_type = "incorrect function return type"; -static string cant_convert_null_to_int = "Can't convert null to int"; -static string cant_convert_null_to_float = "Can't convert null to float"; -static string cant_convert_null_to_string = "Can't convert null to string"; -static string illegal_operator_for_type = "Illegal operator for type"; -static string arithmetic_operator_custom_type = "Arithmetic operator cannot be applied to custom type objects"; -static string operator_cannot_applied_to_strings = "Operator cannot be applied to strings"; -static string division_by_zero = "Division by zero."; -static string custom_type_not_found = "custom type name not found"; -static string type_is_not_custom_type = "type is not a custom type"; -static string after_cannot_used_on_null = "'After' cannot be used on 'Null'"; -static string after_must_used_with_custom_type = "'After' must be used with a custom type object"; -static string before_cannot_used_with_null = "'Before' cannot be used with 'Null'"; -static string before_must_used_with_custom_type = "'Before' must be used with a custom type object"; -static string objecthandle_must_used_with_object = "'ObjectHandle' must be used with an object"; -static string internal_compiler_error = "INTERNAL COMPILER ERROR"; -static string type_not_found = "Type '{0}' not found"; -static string error_in_operand = "error in operand"; -static string illegal_operand_size = "illegal operand size"; -static string register_must_be_32_bit = "register must be 32 bit"; -static string next_without_for = "'Next' without 'For'"; -static string wend_without_while = "'Wend' without 'While'"; -static string else_without_if = "'Else' without 'If'"; -static string endif_without_if = "'Endif' without 'If'"; -static string end_function_without_function = "'End Function' without 'Function'"; -static string until_without_repeat = "'Until' without 'Repeat'"; -static string forever_without_repeat = "'Forever' without 'Repeat'"; -static string case_without_select = "'Case' without 'Select'"; -static string end_select_without_select = "'End Select' without 'Select'"; -static string expecting = "Expecting {0}"; -static string identifier = "identifier"; -static string include_filename = "include filename"; -static string unable_open_include_file = "Unable to open include file"; -static string end_of_file = "end-of-file"; -static string mismatched_brackets = "Mismatched brackets"; -static string variable_assignment = "variable assignment"; -static string until_or_forever = "'Until' or 'Forever'"; -static string expression_sequence = "expression sequence"; -static string case_default_or_end_select = "'Case', 'Default' or 'End Select'"; -static string before_or_after = "'Before' or 'After'"; -static string data_can_only_appear_in_main = "'Data' can only appear in main program"; -static string type_can_only_appear_in_main = "'Type' can only appear in main program"; -static string const_can_only_appear_in_main = "'Const' can only appear in main program"; -static string function_can_only_appear_in_main = "'Function' can only appear in main program"; -static string global_can_only_appear_in_main = "'Global' can only appear in main program"; -static string blitz_arrays_may_not_be_constant = "Blitz arrays may not be constant"; -static string cant_have_zero_dimension_array = "can't have a 0 dimensional array"; -static string field_or_end_type = "'Field' or 'End Type'"; -static string expression = "expression"; -static string undefined_label_check = "Undefined label '{0}'"; -static string array_not_found_in_main = "Array not found in main program"; -static string constants_can_not_assigned_to = "Constants can not be assigned to"; -static string blitz_arrays_can_not_assigned_to = "Blitz arrays can not be assigned to"; -static string gosub_may_not_used_inside_function = "'Gosub' may not be used inside a function"; -static string break_must_appear_inside_loop = "break must appear inside a loop"; -static string index_variable_can_not_constant = "Index variable can not be constant"; -static string index_variable_must_integer_or_real = "index variable must be integer or real"; -static string step_value_must_constant = "Step value must be constant"; -static string index_variable_is_not_newtype = "Index variable is not a NewType"; -static string type_name_not_found = "Type name not found"; -static string type_mismatch = "Type mismatch"; -static string main_cannot_return_value = "Main program cannot return a value"; -static string cant_delete_non_newtype = "Can't delete non-Newtype"; -static string specified_name_is_not_newtype_name = "Specified name is not a NewType name"; -static string illegal_expression_type = "Illegal expression type"; -static string objects_types_are_different = "Objects types are different"; -static string select_cannot_used_with_objects = "Select cannot be used with objects"; -static string constants_can_not_modified = "Constants can not be modified"; -static string data_can_not_read_into_object = "Data can not be read into an object"; -static string variable_type_mismatch = "Variable type mismatch"; -static string identifier_not_used_like_this = "Identifier '{0}' may not be used like this"; -static string array_not_found = "Array not found"; -static string array_type_mismatch = "array type mismatch"; -static string incorrect_number_of_dimensions = "incorrect number of dimensions"; -static string variable_must_be_type = "Variable must be a Type"; -static string type_field_not_found = "Type field not found"; -static string variable_must_a_blitz_array = "Variable must be a Blitz array"; -static string incorrect_number_of_subscripts = "Incorrect number of subscripts"; -static string blitz_array_subscript_out_of_range = "Blitz array subscript out of range"; -static wstring runtime_message = L"Runtime Message"; -static string current_language = "Current Language: English\r\n\r\n"; -static string debugger_locals = "Locals"; -static string debugger_globals = "Globals"; -static string debugger_consts = "Consts"; -static string debugger_unknown = ""; -static string debugger_cant_access_appdata = "Couldn't access the AppData folder! This is needed for the preferences file to work.\nThe IDE will use the default values."; -static string debugger_cant_create_folder = "Couldn't create a folder for the preferences!\nThe IDE will use the default values."; -static string debugger_empty_ini = "blitzide.ini is empty!\nDefaults will be set."; -static char credits[] = +static constexpr string bb_err = "Blitz Error"; +static constexpr string init_err = "Error when creating BlitzIDE process. Please make sure ide.exe is inside the \"bin\" folder."; +static constexpr string array_bounds_ex = "Blitz array index out of bounds."; +static constexpr string null_obj_ex = "Object does not exist!"; +static constexpr string bad_data_type = "Bad data type! Type is not a float, string or an integer."; +static constexpr string out_of_data = "Out of data!"; +static constexpr string stats_strings = "Active strings : {0}"; +static constexpr string stats_objects = "Active objects : {0}"; +static constexpr string stats_unreleased = "Unreleased objs: {0}"; +static constexpr string sound_not_exist = "Sound does not exist"; +static constexpr string bank_not_exist = "bbBank does not exist"; +static constexpr string offset_out_of_range = "Offset out of range"; +static constexpr string graphics_not_set = "3D Graphics mode not set."; +static constexpr string texture_not_exist = "Texture does not exist!"; +static constexpr string brush_not_exist = "Brush does not exist!"; +static constexpr string entity_not_exist = "Entity does not exist!"; +static constexpr string parent_entity_not_exist = "Parent entity does not exist."; +static constexpr string entity_not_mesh = "Entity is not a mesh!"; +static constexpr string entity_not_object = "Entity is not an object!"; +static constexpr string collision_out_of_range = "Collision index out of range."; +static constexpr string entity_not_camera = "Entity is not a camera!"; +static constexpr string entity_not_light = "Entity is not a light!"; +static constexpr string entity_not_model = "Entity is not a model!"; +static constexpr string entity_not_sprite = "Entity is not a sprite!"; +static constexpr string entity_not_md2_model = "Entity is not an MD2 Model!"; +static constexpr string entity_not_bsp_model = "Entity is not a BSP Model!"; +static constexpr string entity_not_terrain = "Entity is not a terrain!"; +static constexpr string illegal_number_segments = "Illegal number of segments!"; +static constexpr string vertex_out_of_range = "Vertex index out of range."; +static constexpr string texture_coordinate_out_of_range = "Texture coordinate set out of range."; +static constexpr string illegal_texture_frames = "Illegal number of texture frames!"; +static constexpr string mesh_cannot_add_to_self = "A mesh cannot be added to itself!"; +static constexpr string surface_out_of_range = "Surface Index out of range."; +static constexpr string illegal_terrain_size = "Illegal terrain size!"; +static constexpr string unable_load_heightmap = "Unable to load heightmap image."; +static constexpr string terrain_must_be_square = "Terrain must be square!"; +static constexpr string listener_already_created = "Listener already created!"; +static constexpr string no_listener_created = "No Listener created."; +static constexpr string entity_cannot_parented_itself = "Entity cannot be parented to itself!"; +static constexpr string entity_no_animations = "Entity has no animations."; +static constexpr string entity_not_model_or_camera = "Entity is not a model or camera!"; +static constexpr string entitytype_id_range = "EntityType ID must be a number from 0 to 999."; +static constexpr string unable_create_gxscene_instance = "Unable to create gxScene instance!"; +static constexpr string file_not_exist = "File does not exist"; +static constexpr string directory_not_exist = "Directory does not exist"; +static constexpr string image_not_exist = "Image doesn't exist."; +static constexpr string image_frame_out_of_range = "Image frame out of range!"; +static constexpr string font_not_exist = "Font doesn't exist."; +static constexpr string buffer_not_exist = "Buffer doesn't exist."; +static constexpr string illegal_graphics_driver_index = "Illegal graphics driver index."; +static constexpr string illegal_graphics_mode_index = "Illegal graphics mode index."; +static constexpr string unable_create_gxgraphics_instance = "Unable to create a gxGraphics instance."; +static constexpr string illegal_graphics_mode = "Illegal Graphics mode. Graphics modes are 0, 1, 2, 3, 4, 6 and 7."; +static constexpr string illegal_graphics3d_mode = "Illegal Graphics3D mode. Graphics modes are 0, 1, 2, 3, 4, 6 and 7."; +static constexpr string unable_close_gxgraphics_instance = "Unable to close gxGraphics instance."; +static constexpr wstring opencc_configure_not_found = L"OpenCC configure not found!"; +static constexpr wstring runtime_error = L"Catactrophic Error!"; +static constexpr string illegal_frame_count = "Illegal frame count!"; +static constexpr string illegal_first_frame = "Illegal first frame!"; +static constexpr string not_enough_frames_bitmap = "Not enough frames in bitmap."; +static constexpr string udp_stream_not_exist = "UDP Stream does not exist"; +static constexpr string tcp_stream_not_exist = "TCP Stream does not exist"; +static constexpr string tcp_server_not_exist = "TCP Server does not exist"; +static constexpr string host_out_of_range = "Host index out of range"; +static constexpr string stream_not_exist = "Stream does not exist"; +static constexpr string readbyte_invalid_byte = "ReadByte couldn't read a valid byte.\nMake sure the file you attempted to read isn't corrupted."; +static constexpr string readshort_invalid_short = "ReadShort couldn't read a valid short.\nMake sure the file you attempted to read isn't corrupted."; +static constexpr string readint_invalid_int = "ReadInt couldn't read a valid integer.\nMake sure the file you attempted to read isn't corrupted."; +static constexpr string readfloat_invalid_float = "ReadFloat couldn't read a valid float.\nMake sure the file you attempted to read isn't corrupted."; +static constexpr string readstring_invalid_string = "ReadString couldn't read a valid string.\nMake sure the file you attempted to read isn't corrupted."; +static constexpr string illegal_buffer_size = "Illegal buffer size"; +static constexpr string string_parameter_positive = "{0}: parameter must be positive"; +static constexpr string string_parameter_greater = "{0}: parameter must be greater than 0"; +static constexpr string userlib_not_found = "User lib not found"; +static constexpr string userlib_function_not_found = "User lib function not found"; +static constexpr string integer_divide_zero = "Integer divide by zero."; +static constexpr string memory_access_violation = "Memory Access Violation!\nThe program attempted to read or write to a protected memory address."; +static constexpr string illegal_instruction = "Illegal instruction.\nProcess tried to execute an invalid CPU instruction."; +static constexpr string stack_overflow = "Stack overflow.\nMake sure there is no recursion without a base case."; +static constexpr string integer_overflow = "Integer overflow!\nMake sure the integer doesnt exceed a value of 2147483647."; +static constexpr string float_overflow = "Float overflow!\nMake sure the float doesn't exceed a value of 3.40282347e+38F."; +static constexpr string float_divide_zero = "Float divide by zero."; +static constexpr string unknown_runtime_exception = "Unknown runtime exception."; +static constexpr string unable_run_module = "Unable to run Blitz Basic module."; +static constexpr string cant_find_symbol = "Can't find symbol: {0}"; +static constexpr string blitz3d_message = "Blitz3D Message"; +static constexpr string created_with_beta = "Created with Blitz3D Beta V{0}.{1}"; +static constexpr string expect_identifier = "expecting identifier after '.'"; +static constexpr string expect_string_afrer_directive = "expecting string after lib directive"; +static constexpr string unknown_decl_directive = "unknown decl directive"; +static constexpr string function_decl_without_directive = "function decl without lib directive"; +static constexpr string duplicate_identifier = "duplicate identifier"; +static constexpr string expect_left_bracket_after_function_identifier = "expecting '(' after function identifier"; +static constexpr string expect_right_bracket_after_function_identifier = "expecting ')' after function decl"; +static constexpr string expect_identifier_or_string_after_alias = "expecting identifier or string after alias"; +static constexpr string unable_open_linker_dll = "Unable to open linker.dll"; +static constexpr string error_in_linker_dll = "Error in linker.dll"; +static constexpr string unable_open_runtime_dll = "Unable to open runtime.dll"; +static constexpr string error_in_runtime_dll = "Error in runtime.dll"; +static constexpr string library_version_error = "Library version error"; +static constexpr string immediate_value_cannot_by_label = "immediate value cannot by a label"; +static constexpr string operand_must_be_immediate = "operand must be immediate"; +static constexpr string unrecognized_instruction = "unrecognized instruction"; +static constexpr string illegal_addressing_mode = "illegal addressing mode"; +static constexpr string operand_error = "operand error"; +static constexpr string duplicate_label = "duplicate label"; +static constexpr string missing_close_quote = "missing close quote"; +static constexpr string expect_comma = "expecting ','"; +static constexpr string too_many_operands = "Too many operands"; +static constexpr string expression_must_be_constant = "Expression must be constant"; +static constexpr string constants_must_initialized = "Constants must be initialized"; +static constexpr string duplicate_variable_name = "Duplicate variable name"; +static constexpr string undefined_label = "Undefined label"; +static constexpr string data_expression_must_be_constant = "Data expression must be constant"; +static constexpr string blitz_array_sizes_must_be_constant = "Blitz array sizes must be constant"; +static constexpr string blitz_array_sizes_must_not_negative = "Blitz array sizes must not be negative"; +static constexpr string illegal_type_conversion = "Illegal type conversion ({0} -> {1})"; +static constexpr string too_many_parameters = "Too many parameters"; +static constexpr string not_enough_parameters = "Not enough parameters"; +static constexpr string function_not_found = "Function '{0}' not found"; +static constexpr string incorrect_function_return_type = "incorrect function return type"; +static constexpr string cant_convert_null_to_int = "Can't convert null to int"; +static constexpr string cant_convert_null_to_float = "Can't convert null to float"; +static constexpr string cant_convert_null_to_string = "Can't convert null to string"; +static constexpr string illegal_operator_for_type = "Illegal operator for type"; +static constexpr string arithmetic_operator_custom_type = "Arithmetic operator cannot be applied to custom type objects"; +static constexpr string operator_cannot_applied_to_strings = "Operator cannot be applied to strings"; +static constexpr string division_by_zero = "Division by zero."; +static constexpr string custom_type_not_found = "custom type name not found"; +static constexpr string type_is_not_custom_type = "type is not a custom type"; +static constexpr string after_cannot_used_on_null = "'After' cannot be used on 'Null'"; +static constexpr string after_must_used_with_custom_type = "'After' must be used with a custom type object"; +static constexpr string before_cannot_used_with_null = "'Before' cannot be used with 'Null'"; +static constexpr string before_must_used_with_custom_type = "'Before' must be used with a custom type object"; +static constexpr string objecthandle_must_used_with_object = "'ObjectHandle' must be used with an object"; +static constexpr string internal_compiler_error = "INTERNAL COMPILER ERROR"; +static constexpr string type_not_found = "Type '{0}' not found"; +static constexpr string error_in_operand = "error in operand"; +static constexpr string illegal_operand_size = "illegal operand size"; +static constexpr string register_must_be_32_bit = "register must be 32 bit"; +static constexpr string next_without_for = "'Next' without 'For'"; +static constexpr string wend_without_while = "'Wend' without 'While'"; +static constexpr string else_without_if = "'Else' without 'If'"; +static constexpr string endif_without_if = "'Endif' without 'If'"; +static constexpr string end_function_without_function = "'End Function' without 'Function'"; +static constexpr string until_without_repeat = "'Until' without 'Repeat'"; +static constexpr string forever_without_repeat = "'Forever' without 'Repeat'"; +static constexpr string case_without_select = "'Case' without 'Select'"; +static constexpr string end_select_without_select = "'End Select' without 'Select'"; +static constexpr string expecting = "Expecting {0}"; +static constexpr string identifier = "identifier"; +static constexpr string include_filename = "include filename"; +static constexpr string unable_open_include_file = "Unable to open include file"; +static constexpr string end_of_file = "end-of-file"; +static constexpr string mismatched_brackets = "Mismatched brackets"; +static constexpr string variable_assignment = "variable assignment"; +static constexpr string until_or_forever = "'Until' or 'Forever'"; +static constexpr string expression_sequence = "expression sequence"; +static constexpr string case_default_or_end_select = "'Case', 'Default' or 'End Select'"; +static constexpr string before_or_after = "'Before' or 'After'"; +static constexpr string data_can_only_appear_in_main = "'Data' can only appear in main program"; +static constexpr string type_can_only_appear_in_main = "'Type' can only appear in main program"; +static constexpr string const_can_only_appear_in_main = "'Const' can only appear in main program"; +static constexpr string function_can_only_appear_in_main = "'Function' can only appear in main program"; +static constexpr string global_can_only_appear_in_main = "'Global' can only appear in main program"; +static constexpr string blitz_arrays_may_not_be_constant = "Blitz arrays may not be constant"; +static constexpr string cant_have_zero_dimension_array = "can't have a 0 dimensional array"; +static constexpr string field_or_end_type = "'Field' or 'End Type'"; +static constexpr string expression = "expression"; +static constexpr string undefined_label_check = "Undefined label '{0}'"; +static constexpr string array_not_found_in_main = "Array not found in main program"; +static constexpr string constants_can_not_assigned_to = "Constants can not be assigned to"; +static constexpr string blitz_arrays_can_not_assigned_to = "Blitz arrays can not be assigned to"; +static constexpr string gosub_may_not_used_inside_function = "'Gosub' may not be used inside a function"; +static constexpr string break_must_appear_inside_loop = "break must appear inside a loop"; +static constexpr string index_variable_can_not_constant = "Index variable can not be constant"; +static constexpr string index_variable_must_integer_or_real = "index variable must be integer or real"; +static constexpr string step_value_must_constant = "Step value must be constant"; +static constexpr string index_variable_is_not_newtype = "Index variable is not a NewType"; +static constexpr string type_name_not_found = "Type name not found"; +static constexpr string type_mismatch = "Type mismatch"; +static constexpr string main_cannot_return_value = "Main program cannot return a value"; +static constexpr string cant_delete_non_newtype = "Can't delete non-Newtype"; +static constexpr string specified_name_is_not_newtype_name = "Specified name is not a NewType name"; +static constexpr string illegal_expression_type = "Illegal expression type"; +static constexpr string objects_types_are_different = "Objects types are different"; +static constexpr string select_cannot_used_with_objects = "Select cannot be used with objects"; +static constexpr string constants_can_not_modified = "Constants can not be modified"; +static constexpr string data_can_not_read_into_object = "Data can not be read into an object"; +static constexpr string variable_type_mismatch = "Variable type mismatch"; +static constexpr string identifier_not_used_like_this = "Identifier '{0}' may not be used like this"; +static constexpr string array_not_found = "Array not found"; +static constexpr string array_type_mismatch = "array type mismatch"; +static constexpr string incorrect_number_of_dimensions = "incorrect number of dimensions"; +static constexpr string variable_must_be_type = "Variable must be a Type"; +static constexpr string type_field_not_found = "Type field not found"; +static constexpr string variable_must_a_blitz_array = "Variable must be a Blitz array"; +static constexpr string incorrect_number_of_subscripts = "Incorrect number of subscripts"; +static constexpr string blitz_array_subscript_out_of_range = "Blitz array subscript out of range"; +static constexpr wstring runtime_message = L"Runtime Message"; +static constexpr string current_language = "Current Language: English\r\n\r\n"; +static constexpr string debugger_locals = "Locals"; +static constexpr string debugger_globals = "Globals"; +static constexpr string debugger_consts = "Consts"; +static constexpr string debugger_unknown = ""; +static constexpr string debugger_cant_access_appdata = "Couldn't access the AppData folder! This is needed for the preferences file to work.\nThe IDE will use the default values."; +static constexpr string debugger_cant_create_folder = "Couldn't create a folder for the preferences!\nThe IDE will use the default values."; +static constexpr string debugger_empty_ini = "blitzide.ini is empty!\nDefaults will be set."; +static constexpr char credits[] = "Programming and design: Mark Sibly\r\n" "Keeping this thing alive: juanjp600, Saalvage, VaneBrain, AestheticalZ and ZiYueCommentary\r\n" ".INI loading using a modified version of \"IniPP\", originally by Matthias C. M. Troffaes\r\n" "Documentation: Mark Sibly, Simon Harrison, Paul Gerfen, Shane Monroe and the Blitz Doc Team\r\n" "Testing and support: James Boyd, Simon Armstrong and the Blitz Dev Team\r\n" "Image loader courtesy of FreeImage by Floris van den berg\r\n"; -static string with_opencc = "OpenCC extension is based on OpenCC\r\n"; -static string title_with_opencc = " - with OpenCC extension\n\n"; -static string title_release = " - Release Version\n\n"; -static string unable_start_program = "Unable to start program! A required module could not be started."; -static string program_ended = "Program has ended."; -static string unknown_exception_thrown = "Unknown/non-standard exception thrown!"; -static string startup_error = "Startup Error: {0}"; \ No newline at end of file +static constexpr string with_opencc = "OpenCC extension is based on OpenCC\r\n"; +static constexpr string title_with_opencc = " - with OpenCC extension\n\n"; +static constexpr string title_release = " - Release Version\n\n"; +static constexpr string unable_start_program = "Unable to start program! A required module could not be started."; +static constexpr string program_ended = "Program has ended."; +static constexpr string unknown_exception_thrown = "Unknown/non-standard exception thrown!"; +static constexpr string startup_error = "Startup Error: {0}"; \ No newline at end of file diff --git a/MultiLang/MultiLang.vcxproj b/MultiLang/MultiLang.vcxproj index 84a3f771..500ac085 100644 --- a/MultiLang/MultiLang.vcxproj +++ b/MultiLang/MultiLang.vcxproj @@ -127,7 +127,6 @@ - diff --git a/MultiLang/MultiLang.vcxproj.filters b/MultiLang/MultiLang.vcxproj.filters index e47b9f42..292596a4 100644 --- a/MultiLang/MultiLang.vcxproj.filters +++ b/MultiLang/MultiLang.vcxproj.filters @@ -18,9 +18,6 @@ 头文件 - - 头文件 - diff --git a/MultiLang/SimplifiedChinese.cpp b/MultiLang/SimplifiedChinese.cpp index fed44736..09b45838 100644 --- a/MultiLang/SimplifiedChinese.cpp +++ b/MultiLang/SimplifiedChinese.cpp @@ -5,225 +5,225 @@ using namespace MultiLang; -static string bb_err = "Blitz´íÎó"; -static string init_err = "Æô¶¯BlitzIDEʱ³ö´í¡£Çë¼ì²é\"bin\"Îļþ¼ÐÄÚÊÇ·ñÓÐide.exe¡£"; -static string array_bounds_ex = "BlitzÊý×éË÷ÒýÔ½½ç"; -static string null_obj_ex = "¶ÔÏó²»´æÔÚ"; -static string bad_data_type = "´íÎóµÄÊý¾ÝÀàÐÍ£¡Êý¾ÝÀàÐͲ»Ó¦ÊǸ¡µãÖµ¡¢×Ö·û´®»òÕûÐÍ"; -static string out_of_data = "Êý¾Ý²»×ã"; -static string stats_strings = "¼¤»îµÄ×Ö·û´®£º{0}"; -static string stats_objects = "¼¤»îµÄ¶ÔÏó£º{0}"; -static string stats_unreleased = "δÊͷŵĶÔÏó£º{0}"; -static string sound_not_exist = "ÉùÒô²»´æÔÚ"; -static string bank_not_exist = "bbBank²»´æÔÚ"; -static string offset_out_of_range = "λÖó¬³ö·¶Î§"; -static string graphics_not_set = "3D»­ÃæģʽδÉèÖÃ"; -static string texture_not_exist = "ÎÆÀí²»´æÔÚ"; -static string brush_not_exist = "Brush²»´æÔÚ"; -static string entity_not_exist = "ʵÌå²»´æÔÚ"; -static string parent_entity_not_exist = "¸¸ÊµÌå²»´æÔÚ"; -static string entity_not_mesh = "ʵÌå²»ÊÇMesh"; -static string entity_not_object = "ʵÌå²»ÊǶÔÏó"; -static string collision_out_of_range = "ÅöײË÷Òý³¬³ö·¶Î§"; -static string entity_not_camera = "ʵÌå²»ÊÇÏà»ú"; -static string entity_not_light = "ʵÌå²»Êǵƹâ"; -static string entity_not_model = "ʵÌå²»ÊÇÄ£ÐÍ"; -static string entity_not_sprite = "ʵÌå²»ÊÇSprite"; -static string entity_not_md2_model = "ʵÌå²»ÊÇMD2Ä£ÐÍ"; -static string entity_not_bsp_model = "ʵÌå²»ÊÇBSPÄ£ÐÍ"; -static string entity_not_terrain = "ʵÌå²»ÊǵØÐÎ"; -static string illegal_number_segments = "¶ÎÊý·Ç·¨"; -static string vertex_out_of_range = "¶¥µãË÷Òý³¬³ö·¶Î§"; -static string texture_coordinate_out_of_range = "ÎÆÀí×ø±êÉèÖó¬³ö·¶Î§"; -static string illegal_texture_frames = "·Ç·¨ÎÆÀíÖ¡Êý"; -static string mesh_cannot_add_to_self = "ÎÞ·¨½«MeshÌí¼Óµ½Æä±¾Éí"; -static string surface_out_of_range = "±íÃæË÷Òý³¬³ö·¶Î§"; -static string illegal_terrain_size = "·Ç·¨µØÐδóС"; -static string unable_load_heightmap = "ÎÞ·¨¼ÓÔظ߶Èͼ"; -static string terrain_must_be_square = "µØ±í±ØÐëΪÕý·½ÐÎ"; -static string listener_already_created = "ÒÑ´´½¨¼àÌýÆ÷"; -static string no_listener_created = "δ´´½¨¼àÌýÆ÷"; -static string entity_cannot_parented_itself = "ʵÌå²»ÄÜΪÆä×ÔÉíµÄ¸¸ÊµÌå"; -static string entity_no_animations = "ʵÌåÎÞ¶¯»­"; -static string entity_not_model_or_camera = "ʵÌå²»ÊÇÄ£ÐÍ»òÏà»ú"; -static string entitytype_id_range = "EntityType ID±ØÐëΪ0ÖÁ999Ö®¼äµÄÊý×Ö"; -static string unable_create_gxscene_instance = "ÎÞ·¨´´½¨gxSceneʵÀý"; -static string file_not_exist = "Îļþ²»´æÔÚ"; -static string directory_not_exist = "Îļþ¼Ð²»´æÔÚ"; -static string image_not_exist = "ͼÏñ²»´æÔÚ"; -static string image_frame_out_of_range = "ͼÏñÖ¡³¬³ö·¶Î§"; -static string font_not_exist = "×ÖÌå²»´æÔÚ"; -static string buffer_not_exist = "»º³åÇø²»´æÔÚ"; -static string illegal_graphics_driver_index = "·Ç·¨ÏÔʾÇý¶¯Ë÷Òý"; -static string illegal_graphics_mode_index = "·Ç·¨ÏÔʾģʽË÷Òý"; -static string unable_create_gxgraphics_instance = "ÎÞ·¨´´½¨gxGraphicsʵÀý"; -static string illegal_graphics_mode = "·Ç·¨ÏÔʾģʽ£¬ÏÔʾģʽΪ0µ½7Ö®¼äµÄÖµ¡£"; -static string illegal_graphics3d_mode = "·Ç·¨3DÏÔʾģʽ£¬ÏÔʾģʽΪ0µ½7Ö®¼äµÄÖµ¡£"; -static string unable_close_gxgraphics_instance = "ÎÞ·¨¹Ø±ÕgxGraphicsʵÀý"; -static wstring runtime_error = L"ÔËÐÐʱ´íÎó£¡"; -static wstring opencc_configure_not_found = L"ÕÒ²»µ½OpenCCÉèÖã¡"; -static string illegal_frame_count = "·Ç·¨Ö¡Êý"; -static string illegal_first_frame = "·Ç·¨µÚÒ»Ö¡"; -static string not_enough_frames_bitmap = "λͼ֡Êý²»×ã"; -static string udp_stream_not_exist = "UDPÁ÷²»´æÔÚ"; -static string tcp_stream_not_exist = "TCPÁ÷²»´æÔÚ"; -static string tcp_server_not_exist = "TCP·þÎñÆ÷²»´æÔÚ"; -static string host_out_of_range = "Ö÷»úË÷Òý³¬³ö·¶Î§"; -static string stream_not_exist = "Á÷²»´æÔÚ"; -static string readbyte_invalid_byte = "ReadByteÎÞ·¨¶ÁÈ¡ÓÐЧ×Ö½Ú\nÇëÈ·±£¶ÁÈ¡µÄÎļþÉÐδËð»µ"; -static string readshort_invalid_short = "ReadShortÎÞ·¨¶ÁÈ¡ÓÐЧ¶ÌÕûÐÍ\nÇëÈ·±£¶ÁÈ¡µÄÎļþÉÐδËð»µ"; -static string readint_invalid_int = "ReadIntÎÞ·¨¶ÁÈ¡ÓÐЧÕûÐÍ\nÇëÈ·±£¶ÁÈ¡µÄÎļþÉÐδËð»µ"; -static string readfloat_invalid_float = "ReadFloatÎÞ·¨¶ÁÈ¡ÓÐЧ¸¡µãÖµ\nÇëÈ·±£¶ÁÈ¡µÄÎļþÉÐδËð»µ"; -static string readstring_invalid_string = "ReadStringÎÞ·¨¶ÁÈ¡ÓÐЧ×Ö·û´®\nÇëÈ·±£¶ÁÈ¡µÄÎļþÉÐδËð»µ"; -static string illegal_buffer_size = "·Ç·¨»º³åÇø´óС"; -static string string_parameter_positive = "{0}£º²ÎÊý±ØÐëΪÕý"; -static string string_parameter_greater = "{0}£º²ÎÊý±ØÐë´óÓÚ0"; -static string userlib_not_found = "Óû§¿âδÕÒµ½"; -static string userlib_function_not_found = "Óû§¿âº¯ÊýδÕÒµ½"; -static wstring integer_divide_zero = L"ÕûÊý³ýÁã"; -static wstring memory_access_violation = L"ÄÚ´æ·ÃÎʳåÍ»£¡\n³ÌÐòÊÔͼ¶ÁÈ¡»òдÈëÊܱ£»¤µÄÄÚ´æµØÖ·¡£"; -static wstring illegal_instruction = L"·Ç·¨Ö¸Áî¡£\n³ÌÐòÊÔͼִÐÐÎÞЧµÄCPUÖ¸Áî"; -static wstring stack_overflow = L"¶ÑÕ»Òç³ö£¡\nÇëÈ·±£³ÌÐòÄÚûÓеݹéÏÖÏó"; -static wstring integer_overflow = L"ÕûÊýÒç³ö£¡\nÇëÈ·±£ÕûÊýµÄÖµ²»³¬¹ý2147483647"; -static wstring float_overflow = L"¸¡µãÒç³ö£¡\nÇëÈ·±£¸¡µãµÄÖµ²»³¬¹ý3.40282347e+38F"; -static wstring float_divide_zero = L"¸¡µã³ýÁã"; -static wstring unknown_runtime_exception = L"δ֪ÔËÐÐʱ´íÎó"; -static string unable_run_module = "ÎÞ·¨Æô¶¯Blitz BasicÄ£¿é"; -static string cant_find_symbol = "ÕÒ²»µ½·ûºÅ£º{0}"; -static string blitz3d_message = "Blitz3DÏûÏ¢"; -static string created_with_beta = "ʹÓÃBlitz3D Beta V{0}.{1}ÖÆ×÷"; -static string expect_identifier = "'.'ºóӦΪ±êʶ·û"; -static string expect_string_afrer_directive = "libÖ¸ÁîºóӦΪ×Ö·û´®"; -static string unknown_decl_directive = "δ֪¿âÖ¸Áî"; -static string function_decl_without_directive = "ÎÞlibµÄº¯Êý¿â"; -static string duplicate_identifier = "Öظ´±êʶ·û"; -static string expect_left_bracket_after_function_identifier = "expecting '(' after function identifier"; -static string expect_right_bracket_after_function_identifier = "expecting ')' after function decl"; -static string expect_identifier_or_string_after_alias = "expecting identifier or string after alias"; -static string unable_open_linker_dll = "ÎÞ·¨´ò¿ªlinker.dll"; -static string error_in_linker_dll = "linker.dll³ö´í"; -static string unable_open_runtime_dll = "ÎÞ·¨´ò¿ªruntime.dll"; -static string error_in_runtime_dll = "runtime.dll³ö´í"; -static string library_version_error = "¿â°æ±¾³ö´í"; -static string immediate_value_cannot_by_label = "immediate value cannot by a label"; -static string operand_must_be_immediate = "operand must be immediate"; -static string unrecognized_instruction = "unrecognized instruction"; -static string illegal_addressing_mode = "illegal addressing mode"; -static string operand_error = "²Ù×÷ÊýÎó²î"; -static string duplicate_label = "Öظ´±êÇ©"; -static string missing_close_quote = "missing close quote"; -static string expect_comma = "ȱÉÙ','"; -static string too_many_operands = "Too many operands"; -static string expression_must_be_constant = "Expression must be constant"; -static string constants_must_initialized = "Constants must be initialized"; -static string duplicate_variable_name = "Duplicate variable name"; -static string undefined_label = "Undefined label"; -static string data_expression_must_be_constant = "Data expression must be constant"; -static string blitz_array_sizes_must_be_constant = "Blitz array sizes must be constant"; -static string blitz_array_sizes_must_not_negative = "Blitz array sizes must not be negative"; -static string illegal_type_conversion = "Illegal type conversion ({0} -> {1})"; -static string too_many_parameters = "Too many parameters"; -static string not_enough_parameters = "Not enough parameters"; -static string function_not_found = "Function '{0}' not found"; -static string incorrect_function_return_type = "incorrect function return type"; -static string cant_convert_null_to_int = "Can't convert null to int"; -static string cant_convert_null_to_float = "Can't convert null to float"; -static string cant_convert_null_to_string = "Can't convert null to string"; -static string illegal_operator_for_type = "Illegal operator for type"; -static string arithmetic_operator_custom_type = "Arithmetic operator cannot be applied to custom type objects"; -static string operator_cannot_applied_to_strings = "Operator cannot be applied to strings"; -static string division_by_zero = "Êý×Ö³ýÁã"; -static string custom_type_not_found = "custom type name not found"; -static string type_is_not_custom_type = "type is not a custom type"; -static string after_cannot_used_on_null = "'After' cannot be used on 'Null'"; -static string after_must_used_with_custom_type = "'After' must be used with a custom type object"; -static string before_cannot_used_with_null = "'Before' cannot be used with 'Null'"; -static string before_must_used_with_custom_type = "'Before' must be used with a custom type object"; -static string objecthandle_must_used_with_object = "'ObjectHandle' must be used with an object"; -static string internal_compiler_error = "±àÒëÆ÷ÄÚ²¿´íÎó"; -static string type_not_found = "ÀàÐÍ'{0}'δÕÒµ½"; -static string error_in_operand = "error in operand"; -static string illegal_operand_size = "illegal operand size"; -static string register_must_be_32_bit = "register must be 32 bit"; -static string next_without_for = "'Next'ȱÉÙ'For'"; -static string wend_without_while = "'Wend'ȱÉÙ'While'"; -static string else_without_if = "'Else'ȱÉÙ'If'"; -static string endif_without_if = "'Endif'ȱÉÙ'If'"; -static string end_function_without_function = "'End Function'ȱÉÙ'Function'"; -static string until_without_repeat = "'Until'ȱÉÙ'Repeat'"; -static string forever_without_repeat = "'Forever'ȱÉÙ'Repeat'"; -static string case_without_select = "'Case'ȱÉÙ'Select'"; -static string end_select_without_select = "'End Select'ȱÉÙ'Select'"; -static string expecting = "ȱÉÙ{0}"; -static string identifier = "±êʶ·û"; -static string include_filename = "µ¼ÈëÎļþÃû"; -static string unable_open_include_file = "ÎÞ·¨´ò¿ªµ¼ÈëÎļþ"; -static string end_of_file = "end-of-file"; -static string mismatched_brackets = "Mismatched brackets"; -static string variable_assignment = "variable assignment"; -static string until_or_forever = "'Until'»ò'Forever'"; -static string expression_sequence = "expression sequence"; -static string case_default_or_end_select = "'Case', 'Default' or 'End Select'"; -static string before_or_after = "'Before' or 'After'"; -static string data_can_only_appear_in_main = "'Data' can only appear in main program"; -static string type_can_only_appear_in_main = "'Type' can only appear in main program"; -static string const_can_only_appear_in_main = "'Const' can only appear in main program"; -static string function_can_only_appear_in_main = "'Function' can only appear in main program"; -static string global_can_only_appear_in_main = "'Global' can only appear in main program"; -static string blitz_arrays_may_not_be_constant = "Blitz arrays may not be constant"; -static string cant_have_zero_dimension_array = "can't have a 0 dimensional array"; -static string field_or_end_type = "'Field' or 'End Type'"; -static string expression = "expression"; -static string undefined_label_check = "Undefined label '{0}'"; -static string array_not_found_in_main = "Array not found in main program"; -static string constants_can_not_assigned_to = "Constants can not be assigned to"; -static string blitz_arrays_can_not_assigned_to = "Blitz arrays can not be assigned to"; -static string gosub_may_not_used_inside_function = "'Gosub' may not be used inside a function"; -static string break_must_appear_inside_loop = "break must appear inside a loop"; -static string index_variable_can_not_constant = "Index variable can not be constant"; -static string index_variable_must_integer_or_real = "index variable must be integer or real"; -static string step_value_must_constant = "Step value must be constant"; -static string index_variable_is_not_newtype = "Index variable is not a NewType"; -static string type_name_not_found = "Type name not found"; -static string type_mismatch = "Type mismatch"; -static string main_cannot_return_value = "Main program cannot return a value"; -static string cant_delete_non_newtype = "Can't delete non-Newtype"; -static string specified_name_is_not_newtype_name = "Specified name is not a NewType name"; -static string illegal_expression_type = "Illegal expression type"; -static string objects_types_are_different = "Objects types are different"; -static string select_cannot_used_with_objects = "Select cannot be used with objects"; -static string constants_can_not_modified = "Constants can not be modified"; -static string data_can_not_read_into_object = "Data can not be read into an object"; -static string variable_type_mismatch = "Variable type mismatch"; -static string identifier_not_used_like_this = "Identifier '{0}' may not be used like this"; -static string array_not_found = "Êý×éδÕÒµ½"; -static string array_type_mismatch = "array type mismatch"; -static string incorrect_number_of_dimensions = "´íÎóά¶ÈÊý×Ö"; -static string variable_must_be_type = "±äÁ¿±ØÐëΪÀàÐÍ"; -static string type_field_not_found = "ÀàÐÍÊý¾ÝδÕÒµ½"; -static string variable_must_a_blitz_array = "±äÁ¿±ØÐëΪBlitzÊý×é"; -static string incorrect_number_of_subscripts = "ϱêÊý³ö´í"; -static string blitz_array_subscript_out_of_range = "BlitzÊý×éϱ곬³ö·¶Î§"; -static wstring runtime_message = L"ÔËÐÐʱÏûÏ¢"; -static string current_language = "µ±Ç°ÓïÑÔ£º¼òÌåÖÐÎÄ\r\n\r\n"; -static string debugger_locals = "±¾µØ"; -static string debugger_globals = "È«¾Ö"; -static string debugger_consts = "³£Á¿"; -static string debugger_unknown = "<δ֪>"; -static string debugger_cant_access_appdata = "ÎÞ·¨·ÃÎÊAppDataÎļþ¼Ð£¡ÅäÖÃÎļþÎÞ·¨¶ÁÈ¡¡£\nIDE½«Ê¹ÓÃĬÈÏÖµ"; -static string debugger_cant_create_folder = "ÎÞ·¨ÎªÅäÖÃÎļþ´´½¨Îļþ¼Ð£¡\nIDE½«Ê¹ÓÃĬÈÏÖµ"; -static string debugger_empty_ini = "blitzide.iniΪ¿Õ£¡\n½«Ê¹ÓÃĬÈÏÉèÖÃ"; -static char credits[] = +static constexpr string bb_err = "Blitz´íÎó"; +static constexpr string init_err = "Æô¶¯BlitzIDEʱ³ö´í¡£Çë¼ì²é\"bin\"Îļþ¼ÐÄÚÊÇ·ñÓÐide.exe¡£"; +static constexpr string array_bounds_ex = "BlitzÊý×éË÷ÒýÔ½½ç"; +static constexpr string null_obj_ex = "¶ÔÏó²»´æÔÚ"; +static constexpr string bad_data_type = "´íÎóµÄÊý¾ÝÀàÐÍ£¡Êý¾ÝÀàÐͲ»Ó¦ÊǸ¡µãÖµ¡¢×Ö·û´®»òÕûÐÍ"; +static constexpr string out_of_data = "Êý¾Ý²»×ã"; +static constexpr string stats_strings = "¼¤»îµÄ×Ö·û´®£º{0}"; +static constexpr string stats_objects = "¼¤»îµÄ¶ÔÏó£º{0}"; +static constexpr string stats_unreleased = "δÊͷŵĶÔÏó£º{0}"; +static constexpr string sound_not_exist = "ÉùÒô²»´æÔÚ"; +static constexpr string bank_not_exist = "bbBank²»´æÔÚ"; +static constexpr string offset_out_of_range = "λÖó¬³ö·¶Î§"; +static constexpr string graphics_not_set = "3D»­ÃæģʽδÉèÖÃ"; +static constexpr string texture_not_exist = "ÎÆÀí²»´æÔÚ"; +static constexpr string brush_not_exist = "Brush²»´æÔÚ"; +static constexpr string entity_not_exist = "ʵÌå²»´æÔÚ"; +static constexpr string parent_entity_not_exist = "¸¸ÊµÌå²»´æÔÚ"; +static constexpr string entity_not_mesh = "ʵÌå²»ÊÇMesh"; +static constexpr string entity_not_object = "ʵÌå²»ÊǶÔÏó"; +static constexpr string collision_out_of_range = "ÅöײË÷Òý³¬³ö·¶Î§"; +static constexpr string entity_not_camera = "ʵÌå²»ÊÇÏà»ú"; +static constexpr string entity_not_light = "ʵÌå²»Êǵƹâ"; +static constexpr string entity_not_model = "ʵÌå²»ÊÇÄ£ÐÍ"; +static constexpr string entity_not_sprite = "ʵÌå²»ÊÇSprite"; +static constexpr string entity_not_md2_model = "ʵÌå²»ÊÇMD2Ä£ÐÍ"; +static constexpr string entity_not_bsp_model = "ʵÌå²»ÊÇBSPÄ£ÐÍ"; +static constexpr string entity_not_terrain = "ʵÌå²»ÊǵØÐÎ"; +static constexpr string illegal_number_segments = "¶ÎÊý·Ç·¨"; +static constexpr string vertex_out_of_range = "¶¥µãË÷Òý³¬³ö·¶Î§"; +static constexpr string texture_coordinate_out_of_range = "ÎÆÀí×ø±êÉèÖó¬³ö·¶Î§"; +static constexpr string illegal_texture_frames = "·Ç·¨ÎÆÀíÖ¡Êý"; +static constexpr string mesh_cannot_add_to_self = "ÎÞ·¨½«MeshÌí¼Óµ½Æä±¾Éí"; +static constexpr string surface_out_of_range = "±íÃæË÷Òý³¬³ö·¶Î§"; +static constexpr string illegal_terrain_size = "·Ç·¨µØÐδóС"; +static constexpr string unable_load_heightmap = "ÎÞ·¨¼ÓÔظ߶Èͼ"; +static constexpr string terrain_must_be_square = "µØ±í±ØÐëΪÕý·½ÐÎ"; +static constexpr string listener_already_created = "ÒÑ´´½¨¼àÌýÆ÷"; +static constexpr string no_listener_created = "δ´´½¨¼àÌýÆ÷"; +static constexpr string entity_cannot_parented_itself = "ʵÌå²»ÄÜΪÆä×ÔÉíµÄ¸¸ÊµÌå"; +static constexpr string entity_no_animations = "ʵÌåÎÞ¶¯»­"; +static constexpr string entity_not_model_or_camera = "ʵÌå²»ÊÇÄ£ÐÍ»òÏà»ú"; +static constexpr string entitytype_id_range = "EntityType ID±ØÐëΪ0ÖÁ999Ö®¼äµÄÊý×Ö"; +static constexpr string unable_create_gxscene_instance = "ÎÞ·¨´´½¨gxSceneʵÀý"; +static constexpr string file_not_exist = "Îļþ²»´æÔÚ"; +static constexpr string directory_not_exist = "Îļþ¼Ð²»´æÔÚ"; +static constexpr string image_not_exist = "ͼÏñ²»´æÔÚ"; +static constexpr string image_frame_out_of_range = "ͼÏñÖ¡³¬³ö·¶Î§"; +static constexpr string font_not_exist = "×ÖÌå²»´æÔÚ"; +static constexpr string buffer_not_exist = "»º³åÇø²»´æÔÚ"; +static constexpr string illegal_graphics_driver_index = "·Ç·¨ÏÔʾÇý¶¯Ë÷Òý"; +static constexpr string illegal_graphics_mode_index = "·Ç·¨ÏÔʾģʽË÷Òý"; +static constexpr string unable_create_gxgraphics_instance = "ÎÞ·¨´´½¨gxGraphicsʵÀý"; +static constexpr string illegal_graphics_mode = "·Ç·¨ÏÔʾģʽ£¬ÏÔʾģʽΪ0µ½7Ö®¼äµÄÖµ¡£"; +static constexpr string illegal_graphics3d_mode = "·Ç·¨3DÏÔʾģʽ£¬ÏÔʾģʽΪ0µ½7Ö®¼äµÄÖµ¡£"; +static constexpr string unable_close_gxgraphics_instance = "ÎÞ·¨¹Ø±ÕgxGraphicsʵÀý"; +static constexpr wstring runtime_error = L"ÔËÐÐʱ´íÎó£¡"; +static constexpr wstring opencc_configure_not_found = L"ÕÒ²»µ½OpenCCÉèÖã¡"; +static constexpr string illegal_frame_count = "·Ç·¨Ö¡Êý"; +static constexpr string illegal_first_frame = "·Ç·¨µÚÒ»Ö¡"; +static constexpr string not_enough_frames_bitmap = "λͼ֡Êý²»×ã"; +static constexpr string udp_stream_not_exist = "UDPÁ÷²»´æÔÚ"; +static constexpr string tcp_stream_not_exist = "TCPÁ÷²»´æÔÚ"; +static constexpr string tcp_server_not_exist = "TCP·þÎñÆ÷²»´æÔÚ"; +static constexpr string host_out_of_range = "Ö÷»úË÷Òý³¬³ö·¶Î§"; +static constexpr string stream_not_exist = "Á÷²»´æÔÚ"; +static constexpr string readbyte_invalid_byte = "ReadByteÎÞ·¨¶ÁÈ¡ÓÐЧ×Ö½Ú\nÇëÈ·±£¶ÁÈ¡µÄÎļþÉÐδËð»µ"; +static constexpr string readshort_invalid_short = "ReadShortÎÞ·¨¶ÁÈ¡ÓÐЧ¶ÌÕûÐÍ\nÇëÈ·±£¶ÁÈ¡µÄÎļþÉÐδËð»µ"; +static constexpr string readint_invalid_int = "ReadIntÎÞ·¨¶ÁÈ¡ÓÐЧÕûÐÍ\nÇëÈ·±£¶ÁÈ¡µÄÎļþÉÐδËð»µ"; +static constexpr string readfloat_invalid_float = "ReadFloatÎÞ·¨¶ÁÈ¡ÓÐЧ¸¡µãÖµ\nÇëÈ·±£¶ÁÈ¡µÄÎļþÉÐδËð»µ"; +static constexpr string readstring_invalid_string = "ReadStringÎÞ·¨¶ÁÈ¡ÓÐЧ×Ö·û´®\nÇëÈ·±£¶ÁÈ¡µÄÎļþÉÐδËð»µ"; +static constexpr string illegal_buffer_size = "·Ç·¨»º³åÇø´óС"; +static constexpr string string_parameter_positive = "{0}£º²ÎÊý±ØÐëΪÕý"; +static constexpr string string_parameter_greater = "{0}£º²ÎÊý±ØÐë´óÓÚ0"; +static constexpr string userlib_not_found = "Óû§¿âδÕÒµ½"; +static constexpr string userlib_function_not_found = "Óû§¿âº¯ÊýδÕÒµ½"; +static constexpr wstring integer_divide_zero = L"ÕûÊý³ýÁã"; +static constexpr wstring memory_access_violation = L"ÄÚ´æ·ÃÎʳåÍ»£¡\n³ÌÐòÊÔͼ¶ÁÈ¡»òдÈëÊܱ£»¤µÄÄÚ´æµØÖ·¡£"; +static constexpr wstring illegal_instruction = L"·Ç·¨Ö¸Áî¡£\n³ÌÐòÊÔͼִÐÐÎÞЧµÄCPUÖ¸Áî"; +static constexpr wstring stack_overflow = L"¶ÑÕ»Òç³ö£¡\nÇëÈ·±£³ÌÐòÄÚûÓеݹéÏÖÏó"; +static constexpr wstring integer_overflow = L"ÕûÊýÒç³ö£¡\nÇëÈ·±£ÕûÊýµÄÖµ²»³¬¹ý2147483647"; +static constexpr wstring float_overflow = L"¸¡µãÒç³ö£¡\nÇëÈ·±£¸¡µãµÄÖµ²»³¬¹ý3.40282347e+38F"; +static constexpr wstring float_divide_zero = L"¸¡µã³ýÁã"; +static constexpr wstring unknown_runtime_exception = L"δ֪ÔËÐÐʱ´íÎó"; +static constexpr string unable_run_module = "ÎÞ·¨Æô¶¯Blitz BasicÄ£¿é"; +static constexpr string cant_find_symbol = "ÕÒ²»µ½·ûºÅ£º{0}"; +static constexpr string blitz3d_message = "Blitz3DÏûÏ¢"; +static constexpr string created_with_beta = "ʹÓÃBlitz3D Beta V{0}.{1}ÖÆ×÷"; +static constexpr string expect_identifier = "'.'ºóӦΪ±êʶ·û"; +static constexpr string expect_string_afrer_directive = "libÖ¸ÁîºóӦΪ×Ö·û´®"; +static constexpr string unknown_decl_directive = "δ֪¿âÖ¸Áî"; +static constexpr string function_decl_without_directive = "ÎÞlibµÄº¯Êý¿â"; +static constexpr string duplicate_identifier = "Öظ´±êʶ·û"; +static constexpr string expect_left_bracket_after_function_identifier = "expecting '(' after function identifier"; +static constexpr string expect_right_bracket_after_function_identifier = "expecting ')' after function decl"; +static constexpr string expect_identifier_or_string_after_alias = "expecting identifier or string after alias"; +static constexpr string unable_open_linker_dll = "ÎÞ·¨´ò¿ªlinker.dll"; +static constexpr string error_in_linker_dll = "linker.dll³ö´í"; +static constexpr string unable_open_runtime_dll = "ÎÞ·¨´ò¿ªruntime.dll"; +static constexpr string error_in_runtime_dll = "runtime.dll³ö´í"; +static constexpr string library_version_error = "¿â°æ±¾³ö´í"; +static constexpr string immediate_value_cannot_by_label = "immediate value cannot by a label"; +static constexpr string operand_must_be_immediate = "operand must be immediate"; +static constexpr string unrecognized_instruction = "unrecognized instruction"; +static constexpr string illegal_addressing_mode = "illegal addressing mode"; +static constexpr string operand_error = "²Ù×÷ÊýÎó²î"; +static constexpr string duplicate_label = "Öظ´±êÇ©"; +static constexpr string missing_close_quote = "missing close quote"; +static constexpr string expect_comma = "ȱÉÙ','"; +static constexpr string too_many_operands = "Too many operands"; +static constexpr string expression_must_be_constant = "Expression must be constant"; +static constexpr string constants_must_initialized = "Constants must be initialized"; +static constexpr string duplicate_variable_name = "Duplicate variable name"; +static constexpr string undefined_label = "Undefined label"; +static constexpr string data_expression_must_be_constant = "Data expression must be constant"; +static constexpr string blitz_array_sizes_must_be_constant = "Blitz array sizes must be constant"; +static constexpr string blitz_array_sizes_must_not_negative = "Blitz array sizes must not be negative"; +static constexpr string illegal_type_conversion = "Illegal type conversion ({0} -> {1})"; +static constexpr string too_many_parameters = "Too many parameters"; +static constexpr string not_enough_parameters = "Not enough parameters"; +static constexpr string function_not_found = "Function '{0}' not found"; +static constexpr string incorrect_function_return_type = "incorrect function return type"; +static constexpr string cant_convert_null_to_int = "Can't convert null to int"; +static constexpr string cant_convert_null_to_float = "Can't convert null to float"; +static constexpr string cant_convert_null_to_string = "Can't convert null to string"; +static constexpr string illegal_operator_for_type = "Illegal operator for type"; +static constexpr string arithmetic_operator_custom_type = "Arithmetic operator cannot be applied to custom type objects"; +static constexpr string operator_cannot_applied_to_strings = "Operator cannot be applied to strings"; +static constexpr string division_by_zero = "Êý×Ö³ýÁã"; +static constexpr string custom_type_not_found = "custom type name not found"; +static constexpr string type_is_not_custom_type = "type is not a custom type"; +static constexpr string after_cannot_used_on_null = "'After' cannot be used on 'Null'"; +static constexpr string after_must_used_with_custom_type = "'After' must be used with a custom type object"; +static constexpr string before_cannot_used_with_null = "'Before' cannot be used with 'Null'"; +static constexpr string before_must_used_with_custom_type = "'Before' must be used with a custom type object"; +static constexpr string objecthandle_must_used_with_object = "'ObjectHandle' must be used with an object"; +static constexpr string internal_compiler_error = "±àÒëÆ÷ÄÚ²¿´íÎó"; +static constexpr string type_not_found = "ÀàÐÍ'{0}'δÕÒµ½"; +static constexpr string error_in_operand = "error in operand"; +static constexpr string illegal_operand_size = "illegal operand size"; +static constexpr string register_must_be_32_bit = "register must be 32 bit"; +static constexpr string next_without_for = "'Next'ȱÉÙ'For'"; +static constexpr string wend_without_while = "'Wend'ȱÉÙ'While'"; +static constexpr string else_without_if = "'Else'ȱÉÙ'If'"; +static constexpr string endif_without_if = "'Endif'ȱÉÙ'If'"; +static constexpr string end_function_without_function = "'End Function'ȱÉÙ'Function'"; +static constexpr string until_without_repeat = "'Until'ȱÉÙ'Repeat'"; +static constexpr string forever_without_repeat = "'Forever'ȱÉÙ'Repeat'"; +static constexpr string case_without_select = "'Case'ȱÉÙ'Select'"; +static constexpr string end_select_without_select = "'End Select'ȱÉÙ'Select'"; +static constexpr string expecting = "ȱÉÙ{0}"; +static constexpr string identifier = "±êʶ·û"; +static constexpr string include_filename = "µ¼ÈëÎļþÃû"; +static constexpr string unable_open_include_file = "ÎÞ·¨´ò¿ªµ¼ÈëÎļþ"; +static constexpr string end_of_file = "end-of-file"; +static constexpr string mismatched_brackets = "Mismatched brackets"; +static constexpr string variable_assignment = "variable assignment"; +static constexpr string until_or_forever = "'Until'»ò'Forever'"; +static constexpr string expression_sequence = "expression sequence"; +static constexpr string case_default_or_end_select = "'Case', 'Default' or 'End Select'"; +static constexpr string before_or_after = "'Before' or 'After'"; +static constexpr string data_can_only_appear_in_main = "'Data' can only appear in main program"; +static constexpr string type_can_only_appear_in_main = "'Type' can only appear in main program"; +static constexpr string const_can_only_appear_in_main = "'Const' can only appear in main program"; +static constexpr string function_can_only_appear_in_main = "'Function' can only appear in main program"; +static constexpr string global_can_only_appear_in_main = "'Global' can only appear in main program"; +static constexpr string blitz_arrays_may_not_be_constant = "Blitz arrays may not be constant"; +static constexpr string cant_have_zero_dimension_array = "can't have a 0 dimensional array"; +static constexpr string field_or_end_type = "'Field' or 'End Type'"; +static constexpr string expression = "expression"; +static constexpr string undefined_label_check = "Undefined label '{0}'"; +static constexpr string array_not_found_in_main = "Array not found in main program"; +static constexpr string constants_can_not_assigned_to = "Constants can not be assigned to"; +static constexpr string blitz_arrays_can_not_assigned_to = "Blitz arrays can not be assigned to"; +static constexpr string gosub_may_not_used_inside_function = "'Gosub' may not be used inside a function"; +static constexpr string break_must_appear_inside_loop = "break must appear inside a loop"; +static constexpr string index_variable_can_not_constant = "Index variable can not be constant"; +static constexpr string index_variable_must_integer_or_real = "index variable must be integer or real"; +static constexpr string step_value_must_constant = "Step value must be constant"; +static constexpr string index_variable_is_not_newtype = "Index variable is not a NewType"; +static constexpr string type_name_not_found = "Type name not found"; +static constexpr string type_mismatch = "Type mismatch"; +static constexpr string main_cannot_return_value = "Main program cannot return a value"; +static constexpr string cant_delete_non_newtype = "Can't delete non-Newtype"; +static constexpr string specified_name_is_not_newtype_name = "Specified name is not a NewType name"; +static constexpr string illegal_expression_type = "Illegal expression type"; +static constexpr string objects_types_are_different = "Objects types are different"; +static constexpr string select_cannot_used_with_objects = "Select cannot be used with objects"; +static constexpr string constants_can_not_modified = "Constants can not be modified"; +static constexpr string data_can_not_read_into_object = "Data can not be read into an object"; +static constexpr string variable_type_mismatch = "Variable type mismatch"; +static constexpr string identifier_not_used_like_this = "Identifier '{0}' may not be used like this"; +static constexpr string array_not_found = "Êý×éδÕÒµ½"; +static constexpr string array_type_mismatch = "array type mismatch"; +static constexpr string incorrect_number_of_dimensions = "´íÎóά¶ÈÊý×Ö"; +static constexpr string variable_must_be_type = "±äÁ¿±ØÐëΪÀàÐÍ"; +static constexpr string type_field_not_found = "ÀàÐÍÊý¾ÝδÕÒµ½"; +static constexpr string variable_must_a_blitz_array = "±äÁ¿±ØÐëΪBlitzÊý×é"; +static constexpr string incorrect_number_of_subscripts = "ϱêÊý³ö´í"; +static constexpr string blitz_array_subscript_out_of_range = "BlitzÊý×éϱ곬³ö·¶Î§"; +static constexpr wstring runtime_message = L"ÔËÐÐʱÏûÏ¢"; +static constexpr string current_language = "µ±Ç°ÓïÑÔ£º¼òÌåÖÐÎÄ\r\n\r\n"; +static constexpr string debugger_locals = "±¾µØ"; +static constexpr string debugger_globals = "È«¾Ö"; +static constexpr string debugger_consts = "³£Á¿"; +static constexpr string debugger_unknown = "<δ֪>"; +static constexpr string debugger_cant_access_appdata = "ÎÞ·¨·ÃÎÊAppDataÎļþ¼Ð£¡ÅäÖÃÎļþÎÞ·¨¶ÁÈ¡¡£\nIDE½«Ê¹ÓÃĬÈÏÖµ"; +static constexpr string debugger_cant_create_folder = "ÎÞ·¨ÎªÅäÖÃÎļþ´´½¨Îļþ¼Ð£¡\nIDE½«Ê¹ÓÃĬÈÏÖµ"; +static constexpr string debugger_empty_ini = "blitzide.iniΪ¿Õ£¡\n½«Ê¹ÓÃĬÈÏÉèÖÃ"; +static constexpr char credits[] = "±à³Ì¼°Éè¼Æ£ºMark Sibly\r\n" "ÏîÄ¿ÐøÃü£ºjuanjp600¡¢Saalvage¡¢VaneBrain¡¢AestheticalZºÍZiYueCommentary\r\n" ".INI¼ÓÔØÆ÷ʹÓÃ\"IniPP\"µÄÐ޸İ汾£¬Ô­°æÓÉMatthias C. M. TroffaesÖÆ×÷\r\n" "Îĵµ£ºMark Sibly¡¢Simon Harrison¡¢Paul Gerfen¡¢Shane MonroeºÍBlitzÎĵµ×«Ð´ÍŶÓ\r\n" "²âÊÔ¼°Ö§³Ö£ºJames Boyd¡¢Simon ArmstrongºÍBlitz¿ª·¢ÍŶÓ\r\n" "ͼÏñ¼ÓÔØÆ÷£ºFloris van den bergÖÆ×÷µÄFreeImage\r\n"; -static string with_opencc = "OpenCC²å¼þ»ùÓÚOpenCCÖÆ×÷\r\n"; -static string title_with_opencc = " - °üº¬OpenCC²å¼þ\n\n"; -static string title_release = " - ·¢²¼°æ±¾\n\n"; -static string unable_start_program = "ÎÞ·¨Æô¶¯³ÌÐò£¡ÎÞ·¨Æô¶¯ËùÐèÄ£¿é"; -static string program_ended = "³ÌÐòÒѽáÊø"; -static string unknown_exception_thrown = "δ֪/·Ç±ê×¼Òì³£Å׳ö£¡"; -static string startup_error = "Æô¶¯´íÎó£º{0}"; \ No newline at end of file +static constexpr string with_opencc = "OpenCC²å¼þ»ùÓÚOpenCCÖÆ×÷\r\n"; +static constexpr string title_with_opencc = " - °üº¬OpenCC²å¼þ\n\n"; +static constexpr string title_release = " - ·¢²¼°æ±¾\n\n"; +static constexpr string unable_start_program = "ÎÞ·¨Æô¶¯³ÌÐò£¡ÎÞ·¨Æô¶¯ËùÐèÄ£¿é"; +static constexpr string program_ended = "³ÌÐòÒѽáÊø"; +static constexpr string unknown_exception_thrown = "δ֪/·Ç±ê×¼Òì³£Å׳ö£¡"; +static constexpr string startup_error = "Æô¶¯´íÎó£º{0}"; \ No newline at end of file diff --git a/MultiLang/sformat.h b/MultiLang/sformat.h deleted file mode 100644 index 58a8b508..00000000 --- a/MultiLang/sformat.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef SFORMAT -#define SFORMAT - -/* https://github.com/mmc1993/sformat/blob/master/src/sformat.h */ - -#include -#include -#include - -template -inline void ToString(std::string& ret, T&& val) -{ - ret.append(std::to_string(std::forward(val))); -} - -inline void ToString(std::string& ret, const std::string& val) -{ - ret.append(val); -} - -inline void ToString(std::string& ret, const char* val) -{ - ret.append(val); -} - -template -struct SFormatN { - static std::string Format(const char* fmt) - { - static_assert(false, ""); - } -}; - -template <> -struct SFormatN<0> { - template - static std::string Format(const char* fmt, const std::tuple&) - { - return fmt; - } -}; - -template -std::string SFormat(const char* fmt, const ARGS &...args) -{ - const auto tuple = std::forward_as_tuple(args...); - return SFormatN::Format(fmt, tuple); -} - -#define FMT_N(idx) case idx: ToString(ret, std::get(args)); break; - -#define FMT_PARSE(N, ...) \ -template <> \ -struct SFormatN { \ - template \ - static std::string Format(const char * fmt, const std::tuple & args) \ - { std::string ret; \ - while (*fmt != '\0') { auto idx = -1; \ - if (*fmt == '{') { idx = 0; ++fmt; \ - while (*fmt >= '0' && *fmt <= '9') \ - { idx *= 10; idx += (int)(*fmt++ - '0'); } \ - if (*fmt != '}') idx = -1; else ++fmt; \ - } \ - switch (idx) { __VA_ARGS__ default: ret.append(1, *fmt++); break; } \ - } \ - return ret; \ - } \ -}; - -FMT_PARSE(1, FMT_N(0)) -FMT_PARSE(2, FMT_N(0) FMT_N(1)) -FMT_PARSE(3, FMT_N(0) FMT_N(1) FMT_N(2)) -FMT_PARSE(4, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3)) -FMT_PARSE(5, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4)) -FMT_PARSE(6, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5)) -FMT_PARSE(7, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6)) -FMT_PARSE(8, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7)) -FMT_PARSE(9, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8)) -FMT_PARSE(10, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9)) -FMT_PARSE(11, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10)) -FMT_PARSE(12, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11)) -FMT_PARSE(13, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12)) -FMT_PARSE(14, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12) FMT_N(13)) -FMT_PARSE(15, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12) FMT_N(13) FMT_N(14)) -FMT_PARSE(16, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12) FMT_N(13) FMT_N(14) FMT_N(15)) -FMT_PARSE(17, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12) FMT_N(13) FMT_N(14) FMT_N(15) FMT_N(16)) -FMT_PARSE(18, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12) FMT_N(13) FMT_N(14) FMT_N(15) FMT_N(16) FMT_N(17)) -FMT_PARSE(19, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12) FMT_N(13) FMT_N(14) FMT_N(15) FMT_N(16) FMT_N(17) FMT_N(18)) -FMT_PARSE(20, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12) FMT_N(13) FMT_N(14) FMT_N(15) FMT_N(16) FMT_N(17) FMT_N(18) FMT_N(19)) -FMT_PARSE(21, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12) FMT_N(13) FMT_N(14) FMT_N(15) FMT_N(16) FMT_N(17) FMT_N(18) FMT_N(19) FMT_N(20)) -FMT_PARSE(22, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12) FMT_N(13) FMT_N(14) FMT_N(15) FMT_N(16) FMT_N(17) FMT_N(18) FMT_N(19) FMT_N(20) FMT_N(21)) -FMT_PARSE(23, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12) FMT_N(13) FMT_N(14) FMT_N(15) FMT_N(16) FMT_N(17) FMT_N(18) FMT_N(19) FMT_N(20) FMT_N(21) FMT_N(22)) -FMT_PARSE(24, FMT_N(0) FMT_N(1) FMT_N(2) FMT_N(3) FMT_N(4) FMT_N(5) FMT_N(6) FMT_N(7) FMT_N(8) FMT_N(9) FMT_N(10) FMT_N(11) FMT_N(12) FMT_N(13) FMT_N(14) FMT_N(15) FMT_N(16) FMT_N(17) FMT_N(18) FMT_N(19) FMT_N(20) FMT_N(21) FMT_N(22) FMT_N(23)) - -#endif \ No newline at end of file diff --git a/_release/help/commands/2d_commands/GetUserLanguage.htm b/_release/help/commands/2d_commands/GetUserLanguage.htm index 29e17e4f..ca7955d1 100644 --- a/_release/help/commands/2d_commands/GetUserLanguage.htm +++ b/_release/help/commands/2d_commands/GetUserLanguage.htm @@ -5,7 +5,7 @@ -

GetUserLanguage

+

GetUserLanguageStrict

Parameters

@@ -18,7 +18,7 @@

Description

- Get display language of current user. + Get display language of current user (for example, en-US).
diff --git a/bblaunch/bblaunch.vcxproj b/bblaunch/bblaunch.vcxproj index 0283523c..7900bb96 100644 --- a/bblaunch/bblaunch.vcxproj +++ b/bblaunch/bblaunch.vcxproj @@ -130,7 +130,7 @@ NoListing false StdCall - stdcpp17 + stdcpp20 true
diff --git a/bbruntime/basic.cpp b/bbruntime/basic.cpp index cbb986aa..87c39068 100644 --- a/bbruntime/basic.cpp +++ b/bbruntime/basic.cpp @@ -1,7 +1,6 @@ #include "std.h" #include "bbsys.h" #include "../MultiLang/MultiLang.h" -#include "../MultiLang/sformat.h" #include "bbruntime.h" //how many strings allocated @@ -477,9 +476,9 @@ float _bbFPow(float x, float y) { } void bbRuntimeStats() { - gx_runtime->debugLog(SFormat(MultiLang::stats_strings, stringCnt).c_str()); - gx_runtime->debugLog(SFormat(MultiLang::stats_objects, objCnt).c_str()); - gx_runtime->debugLog(SFormat(MultiLang::stats_unreleased, unrelObjCnt).c_str()); + gx_runtime->debugLog(std::format(MultiLang::stats_strings, stringCnt).c_str()); + gx_runtime->debugLog(std::format(MultiLang::stats_objects, objCnt).c_str()); + gx_runtime->debugLog(std::format(MultiLang::stats_unreleased, unrelObjCnt).c_str()); } void bbMav() { diff --git a/bbruntime/bbblitz3d.cpp b/bbruntime/bbblitz3d.cpp index 130fb60c..f16ce78b 100644 --- a/bbruntime/bbblitz3d.cpp +++ b/bbruntime/bbblitz3d.cpp @@ -1011,7 +1011,7 @@ int bbCameraProject(Camera* c, float x, float y, float z) { float nr = c->getFrustumNear(); float nr_w = c->getFrustumWidth(); float nr_h = c->getFrustumHeight(); - projected = Vector((v.x / nr_w + .5f) * vp_w, (.5f - v.y / nr_h) * vp_h, nr); + ::projected = Vector((v.x / nr_w + .5f) * vp_w, (.5f - v.y / nr_h) * vp_h, nr); return 1; } if(v.z > 0) { @@ -1022,26 +1022,26 @@ int bbCameraProject(Camera* c, float x, float y, float z) { float nr = c->getFrustumNear(); float nr_w = c->getFrustumWidth(); float nr_h = c->getFrustumHeight(); - projected = Vector( + ::projected = Vector( (v.x * nr / v.z / nr_w + .5f) * vp_w, (.5f - v.y * nr / v.z / nr_h) * vp_h, nr); return 1; } } - projected = Vector(); + ::projected = Vector(); return 0; } float bbProjectedX() { - return projected.x; + return ::projected.x; } float bbProjectedY() { - return projected.y; + return ::projected.y; } float bbProjectedZ() { - return projected.z; + return ::projected.z; } static Object* doPick(const Line& l, float radius) { @@ -2059,7 +2059,7 @@ void blitz3d_open() { gx_scene = gx_graphics->createScene(0); if(!gx_scene) RTEX(MultiLang::unable_create_gxscene_instance); world = new World(); - projected = Vector(); + ::projected = Vector(); picked.collision = Collision(); picked.with = 0; picked.coords = Vector(); Texture::clearFilters(); diff --git a/bbruntime/bbruntime.cpp b/bbruntime/bbruntime.cpp index 04f619e7..1d62b6af 100644 --- a/bbruntime/bbruntime.cpp +++ b/bbruntime/bbruntime.cpp @@ -3,7 +3,6 @@ #include "bbruntime.h" #include "../gxruntime/gxutf8.h" #include "../MultiLang/MultiLang.h" -#include "../MultiLang/sformat.h" #include std::string* ErrorMessagePool::memoryAccessViolation = 0; @@ -55,6 +54,12 @@ BBStr* bbGetUserLanguage() { return new BBStr(std::wstring_convert>().to_bytes(buf)); } +BBStr* bbGetLocaleInfo() { + char szLangName[10]; + GetLocaleInfoA(GetSystemDefaultLCID(), LOCALE_SABBREVLANGNAME, szLangName, sizeof(szLangName) / sizeof(szLangName[0])); + return new BBStr(szLangName); +} + int bbExecFile(BBStr* f) { std::string t = *f; delete f; @@ -219,6 +224,7 @@ void bbruntime_link(void (*rtSym)(const char* sym, void* pc)) { rtSym("SetEnv$env_var$value", bbSetEnv); rtSym("DisableClose", bbDisableClose); rtSym("$GetUserLanguage", bbGetUserLanguage); + rtSym("$GetLocaleInfo", bbGetLocaleInfo); rtSym("%CreateTimer%hertz", bbCreateTimer); rtSym("%WaitTimer%timer", bbWaitTimer); @@ -247,7 +253,7 @@ void bbruntime_link(void (*rtSym)(const char* sym, void* pc)) { //start up error static void sue(const char* t) { - std::string p = SFormat(MultiLang::startup_error, t); + std::string p = std::format(MultiLang::startup_error, t); gx_runtime->debugError(p.c_str()); } diff --git a/bbruntime/bbruntime.vcxproj b/bbruntime/bbruntime.vcxproj index 122a3ae8..3dc8a3c1 100644 --- a/bbruntime/bbruntime.vcxproj +++ b/bbruntime/bbruntime.vcxproj @@ -123,7 +123,7 @@ false StdCall Async - stdcpp17 + stdcpp20 ..\freetype\include; true diff --git a/bbruntime/bbsockets.cpp b/bbruntime/bbsockets.cpp index f04194ae..52a9b17d 100644 --- a/bbruntime/bbsockets.cpp +++ b/bbruntime/bbsockets.cpp @@ -1,7 +1,6 @@ #include "std.h" #include "bbsockets.h" #include -#include "../MultiLang/sformat.h" #include "../MultiLang/MultiLang.h" #pragma comment (lib, "wininet.lib") @@ -509,7 +508,7 @@ BBStr* bbParseDomainTXT(BBStr* txt, BBStr* name) { } BBStr* bbGetDomainTXT(BBStr* domain) { - std::string result = exec(SFormat("nslookup -qt=TXT {0}", domain->c_str()).data()); + std::string result = exec(std::format("nslookup -qt=TXT {0}", domain->c_str()).data()); result = clearTabLeft(result); if (result[0] == '\"') result = result.substr(1); if (result[result.length() - 2] == '\"') result = result.substr(0, result.length() - 2); diff --git a/bbruntime/bbstring.cpp b/bbruntime/bbstring.cpp index bf1b17d9..a5150130 100644 --- a/bbruntime/bbstring.cpp +++ b/bbruntime/bbstring.cpp @@ -1,12 +1,12 @@ #include "std.h" #include "bbsys.h" #include "../gxruntime/gxutf8.h" +#include "../bbruntime/bbgraphics.h" #include #include "../MultiLang/MultiLang.h" -#include "../MultiLang/sformat.h" -#define CHKPOS(x) if( (x)<0 ) RTEX( SFormat(MultiLang::string_parameter_positive, __func__).c_str() ); -#define CHKOFF(x) if( (x)<=0 ) RTEX( SFormat(MultiLang::string_parameter_greater, __func__ ).c_str() ); +#define CHKPOS(x) if( (x)<0 ) RTEX( std::format(MultiLang::string_parameter_positive, __func__).c_str() ); +#define CHKOFF(x) if( (x)<=0 ) RTEX( std::format(MultiLang::string_parameter_greater, __func__ ).c_str() ); BBStr* bbString(BBStr* s, int n) { BBStr* t = new BBStr(); diff --git a/bbruntime_dll/bbruntime_dll.cpp b/bbruntime_dll/bbruntime_dll.cpp index 08b5735e..bc460e22 100644 --- a/bbruntime_dll/bbruntime_dll.cpp +++ b/bbruntime_dll/bbruntime_dll.cpp @@ -12,7 +12,6 @@ #include "../gxruntime/gxutf8.h" #include "../MultiLang/MultiLang.h" -#include "../MultiLang/sformat.h" #include "../bbruntime/bbsys.h" class DummyDebugger : public Debugger { @@ -235,7 +234,7 @@ static int findSym(const std::string& t) { it = runtime_syms.find(t); if(it != runtime_syms.end()) return it->second; - std::string err = SFormat(MultiLang::cant_find_symbol, t); + std::string err = std::format(MultiLang::cant_find_symbol, t); MessageBox(0, err.c_str(), 0, 0); ExitProcess(0); return 0; diff --git a/bbruntime_dll/bbruntime_dll.vcxproj b/bbruntime_dll/bbruntime_dll.vcxproj index 4c3639cb..49a27d4b 100644 --- a/bbruntime_dll/bbruntime_dll.vcxproj +++ b/bbruntime_dll/bbruntime_dll.vcxproj @@ -133,7 +133,7 @@ false false StdCall - Default + stdcpp20 ..\freetype\include; true diff --git a/blitz/blitz.vcxproj b/blitz/blitz.vcxproj index e36c498b..c71bb6f6 100644 --- a/blitz/blitz.vcxproj +++ b/blitz/blitz.vcxproj @@ -127,7 +127,7 @@ NoListing false StdCall - stdcpp17 + stdcpp20 ..\freetype\include; true diff --git a/blitz3d/blitz3d.vcxproj b/blitz3d/blitz3d.vcxproj index 23e1ac45..cf364427 100644 --- a/blitz3d/blitz3d.vcxproj +++ b/blitz3d/blitz3d.vcxproj @@ -87,7 +87,7 @@ NoListing false StdCall - stdcpp17 + stdcpp20 ..\freetype\include; true diff --git a/blitzide/blitzide.vcxproj b/blitzide/blitzide.vcxproj index 976e671f..90a965a7 100644 --- a/blitzide/blitzide.vcxproj +++ b/blitzide/blitzide.vcxproj @@ -137,7 +137,7 @@ NoListing false StdCall - stdcpp17 + stdcpp20 ..\freetype\include; true diff --git a/blitzide/libs.cpp b/blitzide/libs.cpp index 095245f6..3c8cd498 100644 --- a/blitzide/libs.cpp +++ b/blitzide/libs.cpp @@ -104,7 +104,7 @@ bool isMediaFile(const std::string& f) { return false; #endif - static char* exts[] = { + static const char* exts[] = { "bmp","jpg","png","tga","iff","pcx", "wav","mid","mp3","mod","s3m","xm","it","rmi","sgt", "x","3ds",0 @@ -113,7 +113,7 @@ bool isMediaFile(const std::string& f) { int i = f.rfind('.'); if(i == std::string::npos || i + 1 == f.size()) return false; std::string ext = f.substr(i + 1); - char** p = exts; + const char** p = exts; while(const char* e = *p++) { std::string t(e); if(i + t.size() + 1 != f.size()) continue; diff --git a/blitzide/mainframe.cpp b/blitzide/mainframe.cpp index 731bcafd..126cae32 100644 --- a/blitzide/mainframe.cpp +++ b/blitzide/mainframe.cpp @@ -256,7 +256,7 @@ void MainFrame::OnSize(UINT type, int sw, int sh) { tabber.MoveWindow(x, y, w, h); } -static char* bbFilter = +static const char* bbFilter = "Blitz Basic files (.bb)|*.bb|" @@ -704,7 +704,7 @@ void MainFrame::build(bool exec, bool publish) { exe = "untitled"; } - static char* exeFilter = "Executable files (*.exe)|*.exe||"; + static const char* exeFilter = "Executable files (*.exe)|*.exe||"; int t = OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; CFileDialog fd(false, "exe", exe.c_str(), t, exeFilter); fd.m_ofn.lpstrTitle = "Select executable filename"; @@ -943,15 +943,15 @@ void MainFrame::updateCmdUI(CCmdUI* ui) { static std::string commandURL(const std::string& t) { - static char* dirs[] = { + static const char* dirs[] = { "help\\commands\\2d_commands\\", "help\\commands\\3d_commands\\", 0 }; - char** dir_p = dirs; + const char** dir_p = dirs; - while (char* dir = *dir_p++) { + while (const char* dir = *dir_p++) { WIN32_FIND_DATA fd; std::string path = prefs.homeDir + "/" + dir + t + ".htm"; HANDLE h = FindFirstFile(path.c_str(), &fd); diff --git a/compiler/compiler.vcxproj b/compiler/compiler.vcxproj index f2e23911..a85bb7bd 100644 --- a/compiler/compiler.vcxproj +++ b/compiler/compiler.vcxproj @@ -122,7 +122,7 @@ NoListing false StdCall - stdcpp17 + stdcpp20 ..\freetype\include; true diff --git a/compiler/exprnode.cpp b/compiler/exprnode.cpp index 8851313a..04f4aabb 100644 --- a/compiler/exprnode.cpp +++ b/compiler/exprnode.cpp @@ -1,17 +1,16 @@ #include "std.h" #include "nodes.h" #include "../MultiLang/MultiLang.h" -#include "../MultiLang/sformat.h" - #include #include +#include ////////////////////////////////// // Cast an expression to a type // ////////////////////////////////// ExprNode* ExprNode::castTo(Type* ty, Environ* e) { if(!sem_type->canCastTo(ty)) { - ex(SFormat(MultiLang::illegal_type_conversion, sem_type->name(), ty->name())); + ex(std::format(MultiLang::illegal_type_conversion, sem_type->name(), ty->name())); } ExprNode* cast = new CastNode(this, ty); @@ -126,7 +125,7 @@ void ExprSeqNode::castTo(DeclSeq* decls, Environ* e, bool cfunc) { exprs[k]->sem_type = Type::void_type; } else { - ex(SFormat(MultiLang::illegal_type_conversion, exprs[k]->sem_type->name(), d->type->name())); + ex(std::format(MultiLang::illegal_type_conversion, exprs[k]->sem_type->name(), d->type->name())); } continue; } @@ -155,7 +154,7 @@ void ExprSeqNode::castTo(Type* t, Environ* e) { ExprNode* CallNode::semant(Environ* e) { Type* t = e->findType(tag); sem_decl = e->findFunc(ident); - if(!sem_decl || !(sem_decl->kind & DECL_FUNC)) ex(SFormat(MultiLang::function_not_found, ident)); + if(!sem_decl || !(sem_decl->kind & DECL_FUNC)) ex(std::format(MultiLang::function_not_found, ident)); FuncType* f = sem_decl->type->funcType(); if(t && f->returnType != t) ex(MultiLang::incorrect_function_return_type); exprs->semant(e); diff --git a/compiler/node.cpp b/compiler/node.cpp index df9b1116..f6aedeb9 100644 --- a/compiler/node.cpp +++ b/compiler/node.cpp @@ -1,7 +1,7 @@ #include "std.h" #include "nodes.h" #include "../MultiLang/MultiLang.h" -#include "../MultiLang/sformat.h" +#include std::set Node::usedfuncs; @@ -172,7 +172,7 @@ Type* Node::tagType(const std::string& tag, Environ* e) { Type* t; if(tag.size()) { t = e->findType(tag); - if(!t) ex(SFormat(MultiLang::type_not_found, tag)); + if(!t) ex(std::format(MultiLang::type_not_found, tag)); } else t = 0; return t; diff --git a/compiler/parser.cpp b/compiler/parser.cpp index 3a5d2827..75d16404 100644 --- a/compiler/parser.cpp +++ b/compiler/parser.cpp @@ -2,7 +2,7 @@ #include #include "parser.h" #include "../MultiLang/MultiLang.h" -#include "../MultiLang/sformat.h" +#include static const int TEXTLIMIT = 1024 * 1024 - 1; @@ -53,7 +53,7 @@ void Parser::exp(const std::string& s) { case CASE:ex(MultiLang::case_without_select); case ENDSELECT:ex(MultiLang::end_select_without_select); } - ex(SFormat(MultiLang::expecting, s)); + ex(std::format(MultiLang::expecting, s)); } std::string Parser::parseIdent() { diff --git a/compiler/prognode.cpp b/compiler/prognode.cpp index 3a06db00..7f5320fa 100644 --- a/compiler/prognode.cpp +++ b/compiler/prognode.cpp @@ -1,7 +1,7 @@ #include "std.h" #include "nodes.h" #include "../MultiLang/MultiLang.h" -#include "../MultiLang/sformat.h" +#include ////////////////// // The program! // @@ -70,7 +70,7 @@ void ProgNode::translate(Codegen* g, const std::vector& usrfuncs) { //check labels for(k = 0; k < sem_env->labels.size(); ++k) { - if(sem_env->labels[k]->def < 0) ex(SFormat(MultiLang::undefined_label_check, sem_env->labels[k]->name), sem_env->labels[k]->ref, stmts->file); + if(sem_env->labels[k]->def < 0) ex(std::format(MultiLang::undefined_label_check, sem_env->labels[k]->name), sem_env->labels[k]->ref, stmts->file); } //leave main program diff --git a/compiler/varnode.cpp b/compiler/varnode.cpp index e58bb237..79fb69e0 100644 --- a/compiler/varnode.cpp +++ b/compiler/varnode.cpp @@ -1,7 +1,7 @@ #include "std.h" #include "nodes.h" #include "../MultiLang/MultiLang.h" -#include "../MultiLang/sformat.h" +#include ////////////////////////////////// // Common get/set for variables // @@ -54,7 +54,7 @@ void IdentVarNode::semant(Environ* e) { Type* t = tagType(tag, e); if(!t) t = Type::int_type; if(sem_decl = e->findDecl(ident)) { if(!(sem_decl->kind & (DECL_GLOBAL | DECL_LOCAL | DECL_PARAM))) { - ex(SFormat(MultiLang::identifier_not_used_like_this, sem_decl->name)); + ex(std::format(MultiLang::identifier_not_used_like_this, sem_decl->name)); } Type* ty = sem_decl->type; if(ty->constType()) ty = ty->constType()->valueType; diff --git a/config/config.vcxproj b/config/config.vcxproj index 87590291..8902aa12 100644 --- a/config/config.vcxproj +++ b/config/config.vcxproj @@ -67,7 +67,7 @@ .\Release\config.pch .\Release\ .\Release\ - stdcpp17 + stdcpp20 0x0409 diff --git a/debugger/debugger.vcxproj b/debugger/debugger.vcxproj index 398264c1..00f493fa 100644 --- a/debugger/debugger.vcxproj +++ b/debugger/debugger.vcxproj @@ -87,7 +87,7 @@ NoListing false StdCall - stdcpp17 + stdcpp20 ..\freetype\include; true diff --git a/freeimage/FreeImageLib/FreeImageLib.vcxproj b/freeimage/FreeImageLib/FreeImageLib.vcxproj index 92adf2a2..e8c7dd7a 100644 --- a/freeimage/FreeImageLib/FreeImageLib.vcxproj +++ b/freeimage/FreeImageLib/FreeImageLib.vcxproj @@ -94,7 +94,7 @@ false NoListing false - stdcpp17 + stdcpp20 true diff --git a/freeimage/LibJPEG/LibJPEG.vcxproj b/freeimage/LibJPEG/LibJPEG.vcxproj index 5318689f..4d3bcb47 100644 --- a/freeimage/LibJPEG/LibJPEG.vcxproj +++ b/freeimage/LibJPEG/LibJPEG.vcxproj @@ -125,7 +125,7 @@ false NoListing false - stdcpp17 + stdcpp20 true diff --git a/freeimage/LibPNG/LibPNG.vcxproj b/freeimage/LibPNG/LibPNG.vcxproj index 39b977f1..3fb9e6c2 100644 --- a/freeimage/LibPNG/LibPNG.vcxproj +++ b/freeimage/LibPNG/LibPNG.vcxproj @@ -92,7 +92,7 @@ false NoListing false - stdcpp17 + stdcpp20 true diff --git a/freeimage/ZLib/ZLib.vcxproj b/freeimage/ZLib/ZLib.vcxproj index 217ccdb1..8d23be73 100644 --- a/freeimage/ZLib/ZLib.vcxproj +++ b/freeimage/ZLib/ZLib.vcxproj @@ -125,7 +125,7 @@ false NoListing false - stdcpp17 + stdcpp20 true diff --git a/freetype/builds/windows/vc2010/freetype.vcxproj b/freetype/builds/windows/vc2010/freetype.vcxproj index c8524abd..30b7e8a8 100644 --- a/freetype/builds/windows/vc2010/freetype.vcxproj +++ b/freetype/builds/windows/vc2010/freetype.vcxproj @@ -207,7 +207,7 @@ true StreamingSIMDExtensions2 true - stdcpp17 + stdcpp20 NDEBUG;DLL_EXPORT;$(UserDefines);%(PreprocessorDefinitions) diff --git a/gxruntime/gxutf8.h b/gxruntime/gxutf8.h index 631f0900..7f665df5 100644 --- a/gxruntime/gxutf8.h +++ b/gxruntime/gxutf8.h @@ -21,7 +21,7 @@ class UTF8 { static void popBack(std::string& str); static std::string substr(const std::string& str, int start, int length); static std::wstring convertToUtf16(const std::string& str); - static std::string UTF8::GetSystemFontFile(const std::string& faceName); + static std::string GetSystemFontFile(const std::string& faceName); }; #endif \ No newline at end of file diff --git a/inipp/inipp.vcxproj b/inipp/inipp.vcxproj index cf4e73ac..499a656f 100644 --- a/inipp/inipp.vcxproj +++ b/inipp/inipp.vcxproj @@ -90,6 +90,7 @@ true true true + stdcpp20 true diff --git a/linker/linker.vcxproj b/linker/linker.vcxproj index 098afb21..362c06f1 100644 --- a/linker/linker.vcxproj +++ b/linker/linker.vcxproj @@ -119,7 +119,7 @@ NoListing false StdCall - stdcpp17 + stdcpp20 true diff --git a/linker_dll/linker_dll.vcxproj b/linker_dll/linker_dll.vcxproj index f18ea02c..7face75c 100644 --- a/linker_dll/linker_dll.vcxproj +++ b/linker_dll/linker_dll.vcxproj @@ -132,7 +132,7 @@ NoListing false StdCall - stdcpp17 + stdcpp20 true diff --git a/opencc/include/benchmark/benchmark.h b/opencc/include/benchmark/benchmark.h deleted file mode 100644 index e5f67789..00000000 --- a/opencc/include/benchmark/benchmark.h +++ /dev/null @@ -1,1589 +0,0 @@ -// Copyright 2015 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Support for registering benchmarks for functions. - -/* Example usage: -// Define a function that executes the code to be measured a -// specified number of times: -static void BM_StringCreation(benchmark::State& state) { - for (auto _ : state) - std::string empty_string; -} - -// Register the function as a benchmark -BENCHMARK(BM_StringCreation); - -// Define another benchmark -static void BM_StringCopy(benchmark::State& state) { - std::string x = "hello"; - for (auto _ : state) - std::string copy(x); -} -BENCHMARK(BM_StringCopy); - -// Augment the main() program to invoke benchmarks if specified -// via the --benchmarks command line flag. E.g., -// my_unittest --benchmark_filter=all -// my_unittest --benchmark_filter=BM_StringCreation -// my_unittest --benchmark_filter=String -// my_unittest --benchmark_filter='Copy|Creation' -int main(int argc, char** argv) { - benchmark::Initialize(&argc, argv); - benchmark::RunSpecifiedBenchmarks(); - return 0; -} - -// Sometimes a family of microbenchmarks can be implemented with -// just one routine that takes an extra argument to specify which -// one of the family of benchmarks to run. For example, the following -// code defines a family of microbenchmarks for measuring the speed -// of memcpy() calls of different lengths: - -static void BM_memcpy(benchmark::State& state) { - char* src = new char[state.range(0)]; char* dst = new char[state.range(0)]; - memset(src, 'x', state.range(0)); - for (auto _ : state) - memcpy(dst, src, state.range(0)); - state.SetBytesProcessed(state.iterations() * state.range(0)); - delete[] src; delete[] dst; -} -BENCHMARK(BM_memcpy)->Arg(8)->Arg(64)->Arg(512)->Arg(1<<10)->Arg(8<<10); - -// The preceding code is quite repetitive, and can be replaced with the -// following short-hand. The following invocation will pick a few -// appropriate arguments in the specified range and will generate a -// microbenchmark for each such argument. -BENCHMARK(BM_memcpy)->Range(8, 8<<10); - -// You might have a microbenchmark that depends on two inputs. For -// example, the following code defines a family of microbenchmarks for -// measuring the speed of set insertion. -static void BM_SetInsert(benchmark::State& state) { - set data; - for (auto _ : state) { - state.PauseTiming(); - data = ConstructRandomSet(state.range(0)); - state.ResumeTiming(); - for (int j = 0; j < state.range(1); ++j) - data.insert(RandomNumber()); - } -} -BENCHMARK(BM_SetInsert) - ->Args({1<<10, 128}) - ->Args({2<<10, 128}) - ->Args({4<<10, 128}) - ->Args({8<<10, 128}) - ->Args({1<<10, 512}) - ->Args({2<<10, 512}) - ->Args({4<<10, 512}) - ->Args({8<<10, 512}); - -// The preceding code is quite repetitive, and can be replaced with -// the following short-hand. The following macro will pick a few -// appropriate arguments in the product of the two specified ranges -// and will generate a microbenchmark for each such pair. -BENCHMARK(BM_SetInsert)->Ranges({{1<<10, 8<<10}, {128, 512}}); - -// For more complex patterns of inputs, passing a custom function -// to Apply allows programmatic specification of an -// arbitrary set of arguments to run the microbenchmark on. -// The following example enumerates a dense range on -// one parameter, and a sparse range on the second. -static void CustomArguments(benchmark::internal::Benchmark* b) { - for (int i = 0; i <= 10; ++i) - for (int j = 32; j <= 1024*1024; j *= 8) - b->Args({i, j}); -} -BENCHMARK(BM_SetInsert)->Apply(CustomArguments); - -// Templated microbenchmarks work the same way: -// Produce then consume 'size' messages 'iters' times -// Measures throughput in the absence of multiprogramming. -template int BM_Sequential(benchmark::State& state) { - Q q; - typename Q::value_type v; - for (auto _ : state) { - for (int i = state.range(0); i--; ) - q.push(v); - for (int e = state.range(0); e--; ) - q.Wait(&v); - } - // actually messages, not bytes: - state.SetBytesProcessed(state.iterations() * state.range(0)); -} -BENCHMARK_TEMPLATE(BM_Sequential, WaitQueue)->Range(1<<0, 1<<10); - -Use `Benchmark::MinTime(double t)` to set the minimum time used to run the -benchmark. This option overrides the `benchmark_min_time` flag. - -void BM_test(benchmark::State& state) { - ... body ... -} -BENCHMARK(BM_test)->MinTime(2.0); // Run for at least 2 seconds. - -In a multithreaded test, it is guaranteed that none of the threads will start -until all have reached the loop start, and all will have finished before any -thread exits the loop body. As such, any global setup or teardown you want to -do can be wrapped in a check against the thread index: - -static void BM_MultiThreaded(benchmark::State& state) { - if (state.thread_index == 0) { - // Setup code here. - } - for (auto _ : state) { - // Run the test as normal. - } - if (state.thread_index == 0) { - // Teardown code here. - } -} -BENCHMARK(BM_MultiThreaded)->Threads(4); - - -If a benchmark runs a few milliseconds it may be hard to visually compare the -measured times, since the output data is given in nanoseconds per default. In -order to manually set the time unit, you can specify it manually: - -BENCHMARK(BM_test)->Unit(benchmark::kMillisecond); -*/ - -#ifndef BENCHMARK_BENCHMARK_H_ -#define BENCHMARK_BENCHMARK_H_ - -// The _MSVC_LANG check should detect Visual Studio 2015 Update 3 and newer. -#if __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) -#define BENCHMARK_HAS_CXX11 -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(BENCHMARK_HAS_CXX11) -#include -#include -#include -#endif - -#if defined(_MSC_VER) -#include // for _ReadWriteBarrier -#endif - -#ifndef BENCHMARK_HAS_CXX11 -#define BENCHMARK_DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&); \ - TypeName& operator=(const TypeName&) -#else -#define BENCHMARK_DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&) = delete; \ - TypeName& operator=(const TypeName&) = delete -#endif - -#if defined(__GNUC__) -#define BENCHMARK_UNUSED __attribute__((unused)) -#define BENCHMARK_ALWAYS_INLINE __attribute__((always_inline)) -#define BENCHMARK_NOEXCEPT noexcept -#define BENCHMARK_NOEXCEPT_OP(x) noexcept(x) -#elif defined(_MSC_VER) && !defined(__clang__) -#define BENCHMARK_UNUSED -#define BENCHMARK_ALWAYS_INLINE __forceinline -#if _MSC_VER >= 1900 -#define BENCHMARK_NOEXCEPT noexcept -#define BENCHMARK_NOEXCEPT_OP(x) noexcept(x) -#else -#define BENCHMARK_NOEXCEPT -#define BENCHMARK_NOEXCEPT_OP(x) -#endif -#define __func__ __FUNCTION__ -#else -#define BENCHMARK_UNUSED -#define BENCHMARK_ALWAYS_INLINE -#define BENCHMARK_NOEXCEPT -#define BENCHMARK_NOEXCEPT_OP(x) -#endif - -#define BENCHMARK_INTERNAL_TOSTRING2(x) #x -#define BENCHMARK_INTERNAL_TOSTRING(x) BENCHMARK_INTERNAL_TOSTRING2(x) - -#if defined(__GNUC__) || defined(__clang__) -#define BENCHMARK_BUILTIN_EXPECT(x, y) __builtin_expect(x, y) -#define BENCHMARK_DEPRECATED_MSG(msg) __attribute__((deprecated(msg))) -#else -#define BENCHMARK_BUILTIN_EXPECT(x, y) x -#define BENCHMARK_DEPRECATED_MSG(msg) -#define BENCHMARK_WARNING_MSG(msg) \ - __pragma(message(__FILE__ "(" BENCHMARK_INTERNAL_TOSTRING( \ - __LINE__) ") : warning note: " msg)) -#endif - -#if defined(__GNUC__) && !defined(__clang__) -#define BENCHMARK_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__) -#endif - -#ifndef __has_builtin -#define __has_builtin(x) 0 -#endif - -#if defined(__GNUC__) || __has_builtin(__builtin_unreachable) -#define BENCHMARK_UNREACHABLE() __builtin_unreachable() -#elif defined(_MSC_VER) -#define BENCHMARK_UNREACHABLE() __assume(false) -#else -#define BENCHMARK_UNREACHABLE() ((void)0) -#endif - -namespace benchmark { -class BenchmarkReporter; -class MemoryManager; - -void Initialize(int* argc, char** argv); - -// Report to stdout all arguments in 'argv' as unrecognized except the first. -// Returns true there is at least on unrecognized argument (i.e. 'argc' > 1). -bool ReportUnrecognizedArguments(int argc, char** argv); - -// Generate a list of benchmarks matching the specified --benchmark_filter flag -// and if --benchmark_list_tests is specified return after printing the name -// of each matching benchmark. Otherwise run each matching benchmark and -// report the results. -// -// The second and third overload use the specified 'display_reporter' and -// 'file_reporter' respectively. 'file_reporter' will write to the file -// specified -// by '--benchmark_output'. If '--benchmark_output' is not given the -// 'file_reporter' is ignored. -// -// RETURNS: The number of matching benchmarks. -size_t RunSpecifiedBenchmarks(); -size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter); -size_t RunSpecifiedBenchmarks(BenchmarkReporter* display_reporter, - BenchmarkReporter* file_reporter); - -// Register a MemoryManager instance that will be used to collect and report -// allocation measurements for benchmark runs. -void RegisterMemoryManager(MemoryManager* memory_manager); - -namespace internal { -class Benchmark; -class BenchmarkImp; -class BenchmarkFamilies; - -void UseCharPointer(char const volatile*); - -// Take ownership of the pointer and register the benchmark. Return the -// registered benchmark. -Benchmark* RegisterBenchmarkInternal(Benchmark*); - -// Ensure that the standard streams are properly initialized in every TU. -int InitializeStreams(); -BENCHMARK_UNUSED static int stream_init_anchor = InitializeStreams(); - -} // namespace internal - -#if (!defined(__GNUC__) && !defined(__clang__)) || defined(__pnacl__) || \ - defined(__EMSCRIPTEN__) -#define BENCHMARK_HAS_NO_INLINE_ASSEMBLY -#endif - -// The DoNotOptimize(...) function can be used to prevent a value or -// expression from being optimized away by the compiler. This function is -// intended to add little to no overhead. -// See: https://youtu.be/nXaxk27zwlk?t=2441 -#ifndef BENCHMARK_HAS_NO_INLINE_ASSEMBLY -template -inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) { - asm volatile("" : : "r,m"(value) : "memory"); -} - -template -inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp& value) { -#if defined(__clang__) - asm volatile("" : "+r,m"(value) : : "memory"); -#else - asm volatile("" : "+m,r"(value) : : "memory"); -#endif -} - -// Force the compiler to flush pending writes to global memory. Acts as an -// effective read/write barrier -inline BENCHMARK_ALWAYS_INLINE void ClobberMemory() { - asm volatile("" : : : "memory"); -} -#elif defined(_MSC_VER) -template -inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) { - internal::UseCharPointer(&reinterpret_cast(value)); - _ReadWriteBarrier(); -} - -inline BENCHMARK_ALWAYS_INLINE void ClobberMemory() { _ReadWriteBarrier(); } -#else -template -inline BENCHMARK_ALWAYS_INLINE void DoNotOptimize(Tp const& value) { - internal::UseCharPointer(&reinterpret_cast(value)); -} -// FIXME Add ClobberMemory() for non-gnu and non-msvc compilers -#endif - -// This class is used for user-defined counters. -class Counter { - public: - enum Flags { - kDefaults = 0, - // Mark the counter as a rate. It will be presented divided - // by the duration of the benchmark. - kIsRate = 1U << 0U, - // Mark the counter as a thread-average quantity. It will be - // presented divided by the number of threads. - kAvgThreads = 1U << 1U, - // Mark the counter as a thread-average rate. See above. - kAvgThreadsRate = kIsRate | kAvgThreads, - // Mark the counter as a constant value, valid/same for *every* iteration. - // When reporting, it will be *multiplied* by the iteration count. - kIsIterationInvariant = 1U << 2U, - // Mark the counter as a constant rate. - // When reporting, it will be *multiplied* by the iteration count - // and then divided by the duration of the benchmark. - kIsIterationInvariantRate = kIsRate | kIsIterationInvariant, - // Mark the counter as a iteration-average quantity. - // It will be presented divided by the number of iterations. - kAvgIterations = 1U << 3U, - // Mark the counter as a iteration-average rate. See above. - kAvgIterationsRate = kIsRate | kAvgIterations, - - // In the end, invert the result. This is always done last! - kInvert = 1U << 31U - }; - - enum OneK { - // 1'000 items per 1k - kIs1000 = 1000, - // 1'024 items per 1k - kIs1024 = 1024 - }; - - double value; - Flags flags; - OneK oneK; - - BENCHMARK_ALWAYS_INLINE - Counter(double v = 0., Flags f = kDefaults, OneK k = kIs1000) - : value(v), flags(f), oneK(k) {} - - BENCHMARK_ALWAYS_INLINE operator double const&() const { return value; } - BENCHMARK_ALWAYS_INLINE operator double&() { return value; } -}; - -// A helper for user code to create unforeseen combinations of Flags, without -// having to do this cast manually each time, or providing this operator. -Counter::Flags inline operator|(const Counter::Flags& LHS, - const Counter::Flags& RHS) { - return static_cast(static_cast(LHS) | - static_cast(RHS)); -} - -// This is the container for the user-defined counters. -typedef std::map UserCounters; - -// TimeUnit is passed to a benchmark in order to specify the order of magnitude -// for the measured time. -enum TimeUnit { kNanosecond, kMicrosecond, kMillisecond }; - -// BigO is passed to a benchmark in order to specify the asymptotic -// computational -// complexity for the benchmark. In case oAuto is selected, complexity will be -// calculated automatically to the best fit. -enum BigO { oNone, o1, oN, oNSquared, oNCubed, oLogN, oNLogN, oAuto, oLambda }; - -typedef uint64_t IterationCount; - -// BigOFunc is passed to a benchmark in order to specify the asymptotic -// computational complexity for the benchmark. -typedef double(BigOFunc)(IterationCount); - -// StatisticsFunc is passed to a benchmark in order to compute some descriptive -// statistics over all the measurements of some type -typedef double(StatisticsFunc)(const std::vector&); - -namespace internal { -struct Statistics { - std::string name_; - StatisticsFunc* compute_; - - Statistics(const std::string& name, StatisticsFunc* compute) - : name_(name), compute_(compute) {} -}; - -struct BenchmarkInstance; -class ThreadTimer; -class ThreadManager; - -enum AggregationReportMode -#if defined(BENCHMARK_HAS_CXX11) - : unsigned -#else -#endif -{ - // The mode has not been manually specified - ARM_Unspecified = 0, - // The mode is user-specified. - // This may or may not be set when the following bit-flags are set. - ARM_Default = 1U << 0U, - // File reporter should only output aggregates. - ARM_FileReportAggregatesOnly = 1U << 1U, - // Display reporter should only output aggregates - ARM_DisplayReportAggregatesOnly = 1U << 2U, - // Both reporters should only display aggregates. - ARM_ReportAggregatesOnly = - ARM_FileReportAggregatesOnly | ARM_DisplayReportAggregatesOnly -}; - -} // namespace internal - -// State is passed to a running Benchmark and contains state for the -// benchmark to use. -class State { - public: - struct StateIterator; - friend struct StateIterator; - - // Returns iterators used to run each iteration of a benchmark using a - // C++11 ranged-based for loop. These functions should not be called directly. - // - // REQUIRES: The benchmark has not started running yet. Neither begin nor end - // have been called previously. - // - // NOTE: KeepRunning may not be used after calling either of these functions. - BENCHMARK_ALWAYS_INLINE StateIterator begin(); - BENCHMARK_ALWAYS_INLINE StateIterator end(); - - // Returns true if the benchmark should continue through another iteration. - // NOTE: A benchmark may not return from the test until KeepRunning() has - // returned false. - bool KeepRunning(); - - // Returns true iff the benchmark should run n more iterations. - // REQUIRES: 'n' > 0. - // NOTE: A benchmark must not return from the test until KeepRunningBatch() - // has returned false. - // NOTE: KeepRunningBatch() may overshoot by up to 'n' iterations. - // - // Intended usage: - // while (state.KeepRunningBatch(1000)) { - // // process 1000 elements - // } - bool KeepRunningBatch(IterationCount n); - - // REQUIRES: timer is running and 'SkipWithError(...)' has not been called - // by the current thread. - // Stop the benchmark timer. If not called, the timer will be - // automatically stopped after the last iteration of the benchmark loop. - // - // For threaded benchmarks the PauseTiming() function only pauses the timing - // for the current thread. - // - // NOTE: The "real time" measurement is per-thread. If different threads - // report different measurements the largest one is reported. - // - // NOTE: PauseTiming()/ResumeTiming() are relatively - // heavyweight, and so their use should generally be avoided - // within each benchmark iteration, if possible. - void PauseTiming(); - - // REQUIRES: timer is not running and 'SkipWithError(...)' has not been called - // by the current thread. - // Start the benchmark timer. The timer is NOT running on entrance to the - // benchmark function. It begins running after control flow enters the - // benchmark loop. - // - // NOTE: PauseTiming()/ResumeTiming() are relatively - // heavyweight, and so their use should generally be avoided - // within each benchmark iteration, if possible. - void ResumeTiming(); - - // REQUIRES: 'SkipWithError(...)' has not been called previously by the - // current thread. - // Report the benchmark as resulting in an error with the specified 'msg'. - // After this call the user may explicitly 'return' from the benchmark. - // - // If the ranged-for style of benchmark loop is used, the user must explicitly - // break from the loop, otherwise all future iterations will be run. - // If the 'KeepRunning()' loop is used the current thread will automatically - // exit the loop at the end of the current iteration. - // - // For threaded benchmarks only the current thread stops executing and future - // calls to `KeepRunning()` will block until all threads have completed - // the `KeepRunning()` loop. If multiple threads report an error only the - // first error message is used. - // - // NOTE: Calling 'SkipWithError(...)' does not cause the benchmark to exit - // the current scope immediately. If the function is called from within - // the 'KeepRunning()' loop the current iteration will finish. It is the users - // responsibility to exit the scope as needed. - void SkipWithError(const char* msg); - - // Returns true if an error has been reported with 'SkipWithError(...)'. - bool error_occurred() const { return error_occurred_; } - - // REQUIRES: called exactly once per iteration of the benchmarking loop. - // Set the manually measured time for this benchmark iteration, which - // is used instead of automatically measured time if UseManualTime() was - // specified. - // - // For threaded benchmarks the final value will be set to the largest - // reported values. - void SetIterationTime(double seconds); - - // Set the number of bytes processed by the current benchmark - // execution. This routine is typically called once at the end of a - // throughput oriented benchmark. - // - // REQUIRES: a benchmark has exited its benchmarking loop. - BENCHMARK_ALWAYS_INLINE - void SetBytesProcessed(int64_t bytes) { - counters["bytes_per_second"] = - Counter(static_cast(bytes), Counter::kIsRate, Counter::kIs1024); - } - - BENCHMARK_ALWAYS_INLINE - int64_t bytes_processed() const { - if (counters.find("bytes_per_second") != counters.end()) - return static_cast(counters.at("bytes_per_second")); - return 0; - } - - // If this routine is called with complexity_n > 0 and complexity report is - // requested for the - // family benchmark, then current benchmark will be part of the computation - // and complexity_n will - // represent the length of N. - BENCHMARK_ALWAYS_INLINE - void SetComplexityN(int64_t complexity_n) { complexity_n_ = complexity_n; } - - BENCHMARK_ALWAYS_INLINE - int64_t complexity_length_n() const { return complexity_n_; } - - // If this routine is called with items > 0, then an items/s - // label is printed on the benchmark report line for the currently - // executing benchmark. It is typically called at the end of a processing - // benchmark where a processing items/second output is desired. - // - // REQUIRES: a benchmark has exited its benchmarking loop. - BENCHMARK_ALWAYS_INLINE - void SetItemsProcessed(int64_t items) { - counters["items_per_second"] = - Counter(static_cast(items), benchmark::Counter::kIsRate); - } - - BENCHMARK_ALWAYS_INLINE - int64_t items_processed() const { - if (counters.find("items_per_second") != counters.end()) - return static_cast(counters.at("items_per_second")); - return 0; - } - - // If this routine is called, the specified label is printed at the - // end of the benchmark report line for the currently executing - // benchmark. Example: - // static void BM_Compress(benchmark::State& state) { - // ... - // double compress = input_size / output_size; - // state.SetLabel(StrFormat("compress:%.1f%%", 100.0*compression)); - // } - // Produces output that looks like: - // BM_Compress 50 50 14115038 compress:27.3% - // - // REQUIRES: a benchmark has exited its benchmarking loop. - void SetLabel(const char* label); - - void BENCHMARK_ALWAYS_INLINE SetLabel(const std::string& str) { - this->SetLabel(str.c_str()); - } - - // Range arguments for this run. CHECKs if the argument has been set. - BENCHMARK_ALWAYS_INLINE - int64_t range(std::size_t pos = 0) const { - assert(range_.size() > pos); - return range_[pos]; - } - - BENCHMARK_DEPRECATED_MSG("use 'range(0)' instead") - int64_t range_x() const { return range(0); } - - BENCHMARK_DEPRECATED_MSG("use 'range(1)' instead") - int64_t range_y() const { return range(1); } - - BENCHMARK_ALWAYS_INLINE - IterationCount iterations() const { - if (BENCHMARK_BUILTIN_EXPECT(!started_, false)) { - return 0; - } - return max_iterations - total_iterations_ + batch_leftover_; - } - - private - : // items we expect on the first cache line (ie 64 bytes of the struct) - // When total_iterations_ is 0, KeepRunning() and friends will return false. - // May be larger than max_iterations. - IterationCount total_iterations_; - - // When using KeepRunningBatch(), batch_leftover_ holds the number of - // iterations beyond max_iters that were run. Used to track - // completed_iterations_ accurately. - IterationCount batch_leftover_; - - public: - const IterationCount max_iterations; - - private: - bool started_; - bool finished_; - bool error_occurred_; - - private: // items we don't need on the first cache line - std::vector range_; - - int64_t complexity_n_; - - public: - // Container for user-defined counters. - UserCounters counters; - // Index of the executing thread. Values from [0, threads). - const int thread_index; - // Number of threads concurrently executing the benchmark. - const int threads; - - private: - State(IterationCount max_iters, const std::vector& ranges, - int thread_i, int n_threads, internal::ThreadTimer* timer, - internal::ThreadManager* manager); - - void StartKeepRunning(); - // Implementation of KeepRunning() and KeepRunningBatch(). - // is_batch must be true unless n is 1. - bool KeepRunningInternal(IterationCount n, bool is_batch); - void FinishKeepRunning(); - internal::ThreadTimer* timer_; - internal::ThreadManager* manager_; - - friend struct internal::BenchmarkInstance; -}; - -inline BENCHMARK_ALWAYS_INLINE bool State::KeepRunning() { - return KeepRunningInternal(1, /*is_batch=*/false); -} - -inline BENCHMARK_ALWAYS_INLINE bool State::KeepRunningBatch(IterationCount n) { - return KeepRunningInternal(n, /*is_batch=*/true); -} - -inline BENCHMARK_ALWAYS_INLINE bool State::KeepRunningInternal(IterationCount n, - bool is_batch) { - // total_iterations_ is set to 0 by the constructor, and always set to a - // nonzero value by StartKepRunning(). - assert(n > 0); - // n must be 1 unless is_batch is true. - assert(is_batch || n == 1); - if (BENCHMARK_BUILTIN_EXPECT(total_iterations_ >= n, true)) { - total_iterations_ -= n; - return true; - } - if (!started_) { - StartKeepRunning(); - if (!error_occurred_ && total_iterations_ >= n) { - total_iterations_ -= n; - return true; - } - } - // For non-batch runs, total_iterations_ must be 0 by now. - if (is_batch && total_iterations_ != 0) { - batch_leftover_ = n - total_iterations_; - total_iterations_ = 0; - return true; - } - FinishKeepRunning(); - return false; -} - -struct State::StateIterator { - struct BENCHMARK_UNUSED Value {}; - typedef std::forward_iterator_tag iterator_category; - typedef Value value_type; - typedef Value reference; - typedef Value pointer; - typedef std::ptrdiff_t difference_type; - - private: - friend class State; - BENCHMARK_ALWAYS_INLINE - StateIterator() : cached_(0), parent_() {} - - BENCHMARK_ALWAYS_INLINE - explicit StateIterator(State* st) - : cached_(st->error_occurred_ ? 0 : st->max_iterations), parent_(st) {} - - public: - BENCHMARK_ALWAYS_INLINE - Value operator*() const { return Value(); } - - BENCHMARK_ALWAYS_INLINE - StateIterator& operator++() { - assert(cached_ > 0); - --cached_; - return *this; - } - - BENCHMARK_ALWAYS_INLINE - bool operator!=(StateIterator const&) const { - if (BENCHMARK_BUILTIN_EXPECT(cached_ != 0, true)) return true; - parent_->FinishKeepRunning(); - return false; - } - - private: - IterationCount cached_; - State* const parent_; -}; - -inline BENCHMARK_ALWAYS_INLINE State::StateIterator State::begin() { - return StateIterator(this); -} -inline BENCHMARK_ALWAYS_INLINE State::StateIterator State::end() { - StartKeepRunning(); - return StateIterator(); -} - -namespace internal { - -typedef void(Function)(State&); - -// ------------------------------------------------------ -// Benchmark registration object. The BENCHMARK() macro expands -// into an internal::Benchmark* object. Various methods can -// be called on this object to change the properties of the benchmark. -// Each method returns "this" so that multiple method calls can -// chained into one expression. -class Benchmark { - public: - virtual ~Benchmark(); - - // Note: the following methods all return "this" so that multiple - // method calls can be chained together in one expression. - - // Run this benchmark once with "x" as the extra argument passed - // to the function. - // REQUIRES: The function passed to the constructor must accept an arg1. - Benchmark* Arg(int64_t x); - - // Run this benchmark with the given time unit for the generated output report - Benchmark* Unit(TimeUnit unit); - - // Run this benchmark once for a number of values picked from the - // range [start..limit]. (start and limit are always picked.) - // REQUIRES: The function passed to the constructor must accept an arg1. - Benchmark* Range(int64_t start, int64_t limit); - - // Run this benchmark once for all values in the range [start..limit] with - // specific step - // REQUIRES: The function passed to the constructor must accept an arg1. - Benchmark* DenseRange(int64_t start, int64_t limit, int step = 1); - - // Run this benchmark once with "args" as the extra arguments passed - // to the function. - // REQUIRES: The function passed to the constructor must accept arg1, arg2 ... - Benchmark* Args(const std::vector& args); - - // Equivalent to Args({x, y}) - // NOTE: This is a legacy C++03 interface provided for compatibility only. - // New code should use 'Args'. - Benchmark* ArgPair(int64_t x, int64_t y) { - std::vector args; - args.push_back(x); - args.push_back(y); - return Args(args); - } - - // Run this benchmark once for a number of values picked from the - // ranges [start..limit]. (starts and limits are always picked.) - // REQUIRES: The function passed to the constructor must accept arg1, arg2 ... - Benchmark* Ranges(const std::vector >& ranges); - - // Equivalent to ArgNames({name}) - Benchmark* ArgName(const std::string& name); - - // Set the argument names to display in the benchmark name. If not called, - // only argument values will be shown. - Benchmark* ArgNames(const std::vector& names); - - // Equivalent to Ranges({{lo1, hi1}, {lo2, hi2}}). - // NOTE: This is a legacy C++03 interface provided for compatibility only. - // New code should use 'Ranges'. - Benchmark* RangePair(int64_t lo1, int64_t hi1, int64_t lo2, int64_t hi2) { - std::vector > ranges; - ranges.push_back(std::make_pair(lo1, hi1)); - ranges.push_back(std::make_pair(lo2, hi2)); - return Ranges(ranges); - } - - // Pass this benchmark object to *func, which can customize - // the benchmark by calling various methods like Arg, Args, - // Threads, etc. - Benchmark* Apply(void (*func)(Benchmark* benchmark)); - - // Set the range multiplier for non-dense range. If not called, the range - // multiplier kRangeMultiplier will be used. - Benchmark* RangeMultiplier(int multiplier); - - // Set the minimum amount of time to use when running this benchmark. This - // option overrides the `benchmark_min_time` flag. - // REQUIRES: `t > 0` and `Iterations` has not been called on this benchmark. - Benchmark* MinTime(double t); - - // Specify the amount of iterations that should be run by this benchmark. - // REQUIRES: 'n > 0' and `MinTime` has not been called on this benchmark. - // - // NOTE: This function should only be used when *exact* iteration control is - // needed and never to control or limit how long a benchmark runs, where - // `--benchmark_min_time=N` or `MinTime(...)` should be used instead. - Benchmark* Iterations(IterationCount n); - - // Specify the amount of times to repeat this benchmark. This option overrides - // the `benchmark_repetitions` flag. - // REQUIRES: `n > 0` - Benchmark* Repetitions(int n); - - // Specify if each repetition of the benchmark should be reported separately - // or if only the final statistics should be reported. If the benchmark - // is not repeated then the single result is always reported. - // Applies to *ALL* reporters (display and file). - Benchmark* ReportAggregatesOnly(bool value = true); - - // Same as ReportAggregatesOnly(), but applies to display reporter only. - Benchmark* DisplayAggregatesOnly(bool value = true); - - // By default, the CPU time is measured only for the main thread, which may - // be unrepresentative if the benchmark uses threads internally. If called, - // the total CPU time spent by all the threads will be measured instead. - // By default, the only the main thread CPU time will be measured. - Benchmark* MeasureProcessCPUTime(); - - // If a particular benchmark should use the Wall clock instead of the CPU time - // (be it either the CPU time of the main thread only (default), or the - // total CPU usage of the benchmark), call this method. If called, the elapsed - // (wall) time will be used to control how many iterations are run, and in the - // printing of items/second or MB/seconds values. - // If not called, the CPU time used by the benchmark will be used. - Benchmark* UseRealTime(); - - // If a benchmark must measure time manually (e.g. if GPU execution time is - // being - // measured), call this method. If called, each benchmark iteration should - // call - // SetIterationTime(seconds) to report the measured time, which will be used - // to control how many iterations are run, and in the printing of items/second - // or MB/second values. - Benchmark* UseManualTime(); - - // Set the asymptotic computational complexity for the benchmark. If called - // the asymptotic computational complexity will be shown on the output. - Benchmark* Complexity(BigO complexity = benchmark::oAuto); - - // Set the asymptotic computational complexity for the benchmark. If called - // the asymptotic computational complexity will be shown on the output. - Benchmark* Complexity(BigOFunc* complexity); - - // Add this statistics to be computed over all the values of benchmark run - Benchmark* ComputeStatistics(std::string name, StatisticsFunc* statistics); - - // Support for running multiple copies of the same benchmark concurrently - // in multiple threads. This may be useful when measuring the scaling - // of some piece of code. - - // Run one instance of this benchmark concurrently in t threads. - Benchmark* Threads(int t); - - // Pick a set of values T from [min_threads,max_threads]. - // min_threads and max_threads are always included in T. Run this - // benchmark once for each value in T. The benchmark run for a - // particular value t consists of t threads running the benchmark - // function concurrently. For example, consider: - // BENCHMARK(Foo)->ThreadRange(1,16); - // This will run the following benchmarks: - // Foo in 1 thread - // Foo in 2 threads - // Foo in 4 threads - // Foo in 8 threads - // Foo in 16 threads - Benchmark* ThreadRange(int min_threads, int max_threads); - - // For each value n in the range, run this benchmark once using n threads. - // min_threads and max_threads are always included in the range. - // stride specifies the increment. E.g. DenseThreadRange(1, 8, 3) starts - // a benchmark with 1, 4, 7 and 8 threads. - Benchmark* DenseThreadRange(int min_threads, int max_threads, int stride = 1); - - // Equivalent to ThreadRange(NumCPUs(), NumCPUs()) - Benchmark* ThreadPerCpu(); - - virtual void Run(State& state) = 0; - - protected: - explicit Benchmark(const char* name); - Benchmark(Benchmark const&); - void SetName(const char* name); - - int ArgsCnt() const; - - private: - friend class BenchmarkFamilies; - - std::string name_; - AggregationReportMode aggregation_report_mode_; - std::vector arg_names_; // Args for all benchmark runs - std::vector > args_; // Args for all benchmark runs - TimeUnit time_unit_; - int range_multiplier_; - double min_time_; - IterationCount iterations_; - int repetitions_; - bool measure_process_cpu_time_; - bool use_real_time_; - bool use_manual_time_; - BigO complexity_; - BigOFunc* complexity_lambda_; - std::vector statistics_; - std::vector thread_counts_; - - Benchmark& operator=(Benchmark const&); -}; - -} // namespace internal - -// Create and register a benchmark with the specified 'name' that invokes -// the specified functor 'fn'. -// -// RETURNS: A pointer to the registered benchmark. -internal::Benchmark* RegisterBenchmark(const char* name, - internal::Function* fn); - -#if defined(BENCHMARK_HAS_CXX11) -template -internal::Benchmark* RegisterBenchmark(const char* name, Lambda&& fn); -#endif - -// Remove all registered benchmarks. All pointers to previously registered -// benchmarks are invalidated. -void ClearRegisteredBenchmarks(); - -namespace internal { -// The class used to hold all Benchmarks created from static function. -// (ie those created using the BENCHMARK(...) macros. -class FunctionBenchmark : public Benchmark { - public: - FunctionBenchmark(const char* name, Function* func) - : Benchmark(name), func_(func) {} - - virtual void Run(State& st); - - private: - Function* func_; -}; - -#ifdef BENCHMARK_HAS_CXX11 -template -class LambdaBenchmark : public Benchmark { - public: - virtual void Run(State& st) { lambda_(st); } - - private: - template - LambdaBenchmark(const char* name, OLambda&& lam) - : Benchmark(name), lambda_(std::forward(lam)) {} - - LambdaBenchmark(LambdaBenchmark const&) = delete; - - private: - template - friend Benchmark* ::benchmark::RegisterBenchmark(const char*, Lam&&); - - Lambda lambda_; -}; -#endif - -} // namespace internal - -inline internal::Benchmark* RegisterBenchmark(const char* name, - internal::Function* fn) { - return internal::RegisterBenchmarkInternal( - ::new internal::FunctionBenchmark(name, fn)); -} - -#ifdef BENCHMARK_HAS_CXX11 -template -internal::Benchmark* RegisterBenchmark(const char* name, Lambda&& fn) { - using BenchType = - internal::LambdaBenchmark::type>; - return internal::RegisterBenchmarkInternal( - ::new BenchType(name, std::forward(fn))); -} -#endif - -#if defined(BENCHMARK_HAS_CXX11) && \ - (!defined(BENCHMARK_GCC_VERSION) || BENCHMARK_GCC_VERSION >= 409) -template -internal::Benchmark* RegisterBenchmark(const char* name, Lambda&& fn, - Args&&... args) { - return benchmark::RegisterBenchmark( - name, [=](benchmark::State& st) { fn(st, args...); }); -} -#else -#define BENCHMARK_HAS_NO_VARIADIC_REGISTER_BENCHMARK -#endif - -// The base class for all fixture tests. -class Fixture : public internal::Benchmark { - public: - Fixture() : internal::Benchmark("") {} - - virtual void Run(State& st) { - this->SetUp(st); - this->BenchmarkCase(st); - this->TearDown(st); - } - - // These will be deprecated ... - virtual void SetUp(const State&) {} - virtual void TearDown(const State&) {} - // ... In favor of these. - virtual void SetUp(State& st) { SetUp(const_cast(st)); } - virtual void TearDown(State& st) { TearDown(const_cast(st)); } - - protected: - virtual void BenchmarkCase(State&) = 0; -}; - -} // namespace benchmark - -// ------------------------------------------------------ -// Macro to register benchmarks - -// Check that __COUNTER__ is defined and that __COUNTER__ increases by 1 -// every time it is expanded. X + 1 == X + 0 is used in case X is defined to be -// empty. If X is empty the expression becomes (+1 == +0). -#if defined(__COUNTER__) && (__COUNTER__ + 1 == __COUNTER__ + 0) -#define BENCHMARK_PRIVATE_UNIQUE_ID __COUNTER__ -#else -#define BENCHMARK_PRIVATE_UNIQUE_ID __LINE__ -#endif - -// Helpers for generating unique variable names -#define BENCHMARK_PRIVATE_NAME(n) \ - BENCHMARK_PRIVATE_CONCAT(_benchmark_, BENCHMARK_PRIVATE_UNIQUE_ID, n) -#define BENCHMARK_PRIVATE_CONCAT(a, b, c) BENCHMARK_PRIVATE_CONCAT2(a, b, c) -#define BENCHMARK_PRIVATE_CONCAT2(a, b, c) a##b##c - -#define BENCHMARK_PRIVATE_DECLARE(n) \ - static ::benchmark::internal::Benchmark* BENCHMARK_PRIVATE_NAME(n) \ - BENCHMARK_UNUSED - -#define BENCHMARK(n) \ - BENCHMARK_PRIVATE_DECLARE(n) = \ - (::benchmark::internal::RegisterBenchmarkInternal( \ - new ::benchmark::internal::FunctionBenchmark(#n, n))) - -// Old-style macros -#define BENCHMARK_WITH_ARG(n, a) BENCHMARK(n)->Arg((a)) -#define BENCHMARK_WITH_ARG2(n, a1, a2) BENCHMARK(n)->Args({(a1), (a2)}) -#define BENCHMARK_WITH_UNIT(n, t) BENCHMARK(n)->Unit((t)) -#define BENCHMARK_RANGE(n, lo, hi) BENCHMARK(n)->Range((lo), (hi)) -#define BENCHMARK_RANGE2(n, l1, h1, l2, h2) \ - BENCHMARK(n)->RangePair({{(l1), (h1)}, {(l2), (h2)}}) - -#ifdef BENCHMARK_HAS_CXX11 - -// Register a benchmark which invokes the function specified by `func` -// with the additional arguments specified by `...`. -// -// For example: -// -// template ` -// void BM_takes_args(benchmark::State& state, ExtraArgs&&... extra_args) { -// [...] -//} -// /* Registers a benchmark named "BM_takes_args/int_string_test` */ -// BENCHMARK_CAPTURE(BM_takes_args, int_string_test, 42, std::string("abc")); -#define BENCHMARK_CAPTURE(func, test_case_name, ...) \ - BENCHMARK_PRIVATE_DECLARE(func) = \ - (::benchmark::internal::RegisterBenchmarkInternal( \ - new ::benchmark::internal::FunctionBenchmark( \ - #func "/" #test_case_name, \ - [](::benchmark::State& st) { func(st, __VA_ARGS__); }))) - -#endif // BENCHMARK_HAS_CXX11 - -// This will register a benchmark for a templatized function. For example: -// -// template -// void BM_Foo(int iters); -// -// BENCHMARK_TEMPLATE(BM_Foo, 1); -// -// will register BM_Foo<1> as a benchmark. -#define BENCHMARK_TEMPLATE1(n, a) \ - BENCHMARK_PRIVATE_DECLARE(n) = \ - (::benchmark::internal::RegisterBenchmarkInternal( \ - new ::benchmark::internal::FunctionBenchmark(#n "<" #a ">", n))) - -#define BENCHMARK_TEMPLATE2(n, a, b) \ - BENCHMARK_PRIVATE_DECLARE(n) = \ - (::benchmark::internal::RegisterBenchmarkInternal( \ - new ::benchmark::internal::FunctionBenchmark(#n "<" #a "," #b ">", \ - n))) - -#ifdef BENCHMARK_HAS_CXX11 -#define BENCHMARK_TEMPLATE(n, ...) \ - BENCHMARK_PRIVATE_DECLARE(n) = \ - (::benchmark::internal::RegisterBenchmarkInternal( \ - new ::benchmark::internal::FunctionBenchmark( \ - #n "<" #__VA_ARGS__ ">", n<__VA_ARGS__>))) -#else -#define BENCHMARK_TEMPLATE(n, a) BENCHMARK_TEMPLATE1(n, a) -#endif - -#define BENCHMARK_PRIVATE_DECLARE_F(BaseClass, Method) \ - class BaseClass##_##Method##_Benchmark : public BaseClass { \ - public: \ - BaseClass##_##Method##_Benchmark() : BaseClass() { \ - this->SetName(#BaseClass "/" #Method); \ - } \ - \ - protected: \ - virtual void BenchmarkCase(::benchmark::State&); \ - }; - -#define BENCHMARK_TEMPLATE1_PRIVATE_DECLARE_F(BaseClass, Method, a) \ - class BaseClass##_##Method##_Benchmark : public BaseClass { \ - public: \ - BaseClass##_##Method##_Benchmark() : BaseClass() { \ - this->SetName(#BaseClass "<" #a ">/" #Method); \ - } \ - \ - protected: \ - virtual void BenchmarkCase(::benchmark::State&); \ - }; - -#define BENCHMARK_TEMPLATE2_PRIVATE_DECLARE_F(BaseClass, Method, a, b) \ - class BaseClass##_##Method##_Benchmark : public BaseClass { \ - public: \ - BaseClass##_##Method##_Benchmark() : BaseClass() { \ - this->SetName(#BaseClass "<" #a "," #b ">/" #Method); \ - } \ - \ - protected: \ - virtual void BenchmarkCase(::benchmark::State&); \ - }; - -#ifdef BENCHMARK_HAS_CXX11 -#define BENCHMARK_TEMPLATE_PRIVATE_DECLARE_F(BaseClass, Method, ...) \ - class BaseClass##_##Method##_Benchmark : public BaseClass<__VA_ARGS__> { \ - public: \ - BaseClass##_##Method##_Benchmark() : BaseClass<__VA_ARGS__>() { \ - this->SetName(#BaseClass "<" #__VA_ARGS__ ">/" #Method); \ - } \ - \ - protected: \ - virtual void BenchmarkCase(::benchmark::State&); \ - }; -#else -#define BENCHMARK_TEMPLATE_PRIVATE_DECLARE_F(n, a) \ - BENCHMARK_TEMPLATE1_PRIVATE_DECLARE_F(n, a) -#endif - -#define BENCHMARK_DEFINE_F(BaseClass, Method) \ - BENCHMARK_PRIVATE_DECLARE_F(BaseClass, Method) \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#define BENCHMARK_TEMPLATE1_DEFINE_F(BaseClass, Method, a) \ - BENCHMARK_TEMPLATE1_PRIVATE_DECLARE_F(BaseClass, Method, a) \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#define BENCHMARK_TEMPLATE2_DEFINE_F(BaseClass, Method, a, b) \ - BENCHMARK_TEMPLATE2_PRIVATE_DECLARE_F(BaseClass, Method, a, b) \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#ifdef BENCHMARK_HAS_CXX11 -#define BENCHMARK_TEMPLATE_DEFINE_F(BaseClass, Method, ...) \ - BENCHMARK_TEMPLATE_PRIVATE_DECLARE_F(BaseClass, Method, __VA_ARGS__) \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase -#else -#define BENCHMARK_TEMPLATE_DEFINE_F(BaseClass, Method, a) \ - BENCHMARK_TEMPLATE1_DEFINE_F(BaseClass, Method, a) -#endif - -#define BENCHMARK_REGISTER_F(BaseClass, Method) \ - BENCHMARK_PRIVATE_REGISTER_F(BaseClass##_##Method##_Benchmark) - -#define BENCHMARK_PRIVATE_REGISTER_F(TestName) \ - BENCHMARK_PRIVATE_DECLARE(TestName) = \ - (::benchmark::internal::RegisterBenchmarkInternal(new TestName())) - -// This macro will define and register a benchmark within a fixture class. -#define BENCHMARK_F(BaseClass, Method) \ - BENCHMARK_PRIVATE_DECLARE_F(BaseClass, Method) \ - BENCHMARK_REGISTER_F(BaseClass, Method); \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#define BENCHMARK_TEMPLATE1_F(BaseClass, Method, a) \ - BENCHMARK_TEMPLATE1_PRIVATE_DECLARE_F(BaseClass, Method, a) \ - BENCHMARK_REGISTER_F(BaseClass, Method); \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#define BENCHMARK_TEMPLATE2_F(BaseClass, Method, a, b) \ - BENCHMARK_TEMPLATE2_PRIVATE_DECLARE_F(BaseClass, Method, a, b) \ - BENCHMARK_REGISTER_F(BaseClass, Method); \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase - -#ifdef BENCHMARK_HAS_CXX11 -#define BENCHMARK_TEMPLATE_F(BaseClass, Method, ...) \ - BENCHMARK_TEMPLATE_PRIVATE_DECLARE_F(BaseClass, Method, __VA_ARGS__) \ - BENCHMARK_REGISTER_F(BaseClass, Method); \ - void BaseClass##_##Method##_Benchmark::BenchmarkCase -#else -#define BENCHMARK_TEMPLATE_F(BaseClass, Method, a) \ - BENCHMARK_TEMPLATE1_F(BaseClass, Method, a) -#endif - -// Helper macro to create a main routine in a test that runs the benchmarks -#define BENCHMARK_MAIN() \ - int main(int argc, char** argv) { \ - ::benchmark::Initialize(&argc, argv); \ - if (::benchmark::ReportUnrecognizedArguments(argc, argv)) return 1; \ - ::benchmark::RunSpecifiedBenchmarks(); \ - } \ - int main(int, char**) - -// ------------------------------------------------------ -// Benchmark Reporters - -namespace benchmark { - -struct CPUInfo { - struct CacheInfo { - std::string type; - int level; - int size; - int num_sharing; - }; - - int num_cpus; - double cycles_per_second; - std::vector caches; - bool scaling_enabled; - std::vector load_avg; - - static const CPUInfo& Get(); - - private: - CPUInfo(); - BENCHMARK_DISALLOW_COPY_AND_ASSIGN(CPUInfo); -}; - -// Adding Struct for System Information -struct SystemInfo { - std::string name; - static const SystemInfo& Get(); - - private: - SystemInfo(); - BENCHMARK_DISALLOW_COPY_AND_ASSIGN(SystemInfo); -}; - -// BenchmarkName contains the components of the Benchmark's name -// which allows individual fields to be modified or cleared before -// building the final name using 'str()'. -struct BenchmarkName { - std::string function_name; - std::string args; - std::string min_time; - std::string iterations; - std::string repetitions; - std::string time_type; - std::string threads; - - // Return the full name of the benchmark with each non-empty - // field separated by a '/' - std::string str() const; -}; - -// Interface for custom benchmark result printers. -// By default, benchmark reports are printed to stdout. However an application -// can control the destination of the reports by calling -// RunSpecifiedBenchmarks and passing it a custom reporter object. -// The reporter object must implement the following interface. -class BenchmarkReporter { - public: - struct Context { - CPUInfo const& cpu_info; - SystemInfo const& sys_info; - // The number of chars in the longest benchmark name. - size_t name_field_width; - static const char* executable_name; - Context(); - }; - - struct Run { - static const int64_t no_repetition_index = -1; - enum RunType { RT_Iteration, RT_Aggregate }; - - Run() - : run_type(RT_Iteration), - error_occurred(false), - iterations(1), - threads(1), - time_unit(kNanosecond), - real_accumulated_time(0), - cpu_accumulated_time(0), - max_heapbytes_used(0), - complexity(oNone), - complexity_lambda(), - complexity_n(0), - report_big_o(false), - report_rms(false), - counters(), - has_memory_result(false), - allocs_per_iter(0.0), - max_bytes_used(0) {} - - std::string benchmark_name() const; - BenchmarkName run_name; - RunType run_type; - std::string aggregate_name; - std::string report_label; // Empty if not set by benchmark. - bool error_occurred; - std::string error_message; - - IterationCount iterations; - int64_t threads; - int64_t repetition_index; - int64_t repetitions; - TimeUnit time_unit; - double real_accumulated_time; - double cpu_accumulated_time; - - // Return a value representing the real time per iteration in the unit - // specified by 'time_unit'. - // NOTE: If 'iterations' is zero the returned value represents the - // accumulated time. - double GetAdjustedRealTime() const; - - // Return a value representing the cpu time per iteration in the unit - // specified by 'time_unit'. - // NOTE: If 'iterations' is zero the returned value represents the - // accumulated time. - double GetAdjustedCPUTime() const; - - // This is set to 0.0 if memory tracing is not enabled. - double max_heapbytes_used; - - // Keep track of arguments to compute asymptotic complexity - BigO complexity; - BigOFunc* complexity_lambda; - int64_t complexity_n; - - // what statistics to compute from the measurements - const std::vector* statistics; - - // Inform print function whether the current run is a complexity report - bool report_big_o; - bool report_rms; - - UserCounters counters; - - // Memory metrics. - bool has_memory_result; - double allocs_per_iter; - int64_t max_bytes_used; - }; - - // Construct a BenchmarkReporter with the output stream set to 'std::cout' - // and the error stream set to 'std::cerr' - BenchmarkReporter(); - - // Called once for every suite of benchmarks run. - // The parameter "context" contains information that the - // reporter may wish to use when generating its report, for example the - // platform under which the benchmarks are running. The benchmark run is - // never started if this function returns false, allowing the reporter - // to skip runs based on the context information. - virtual bool ReportContext(const Context& context) = 0; - - // Called once for each group of benchmark runs, gives information about - // cpu-time and heap memory usage during the benchmark run. If the group - // of runs contained more than two entries then 'report' contains additional - // elements representing the mean and standard deviation of those runs. - // Additionally if this group of runs was the last in a family of benchmarks - // 'reports' contains additional entries representing the asymptotic - // complexity and RMS of that benchmark family. - virtual void ReportRuns(const std::vector& report) = 0; - - // Called once and only once after ever group of benchmarks is run and - // reported. - virtual void Finalize() {} - - // REQUIRES: The object referenced by 'out' is valid for the lifetime - // of the reporter. - void SetOutputStream(std::ostream* out) { - assert(out); - output_stream_ = out; - } - - // REQUIRES: The object referenced by 'err' is valid for the lifetime - // of the reporter. - void SetErrorStream(std::ostream* err) { - assert(err); - error_stream_ = err; - } - - std::ostream& GetOutputStream() const { return *output_stream_; } - - std::ostream& GetErrorStream() const { return *error_stream_; } - - virtual ~BenchmarkReporter(); - - // Write a human readable string to 'out' representing the specified - // 'context'. - // REQUIRES: 'out' is non-null. - static void PrintBasicContext(std::ostream* out, Context const& context); - - private: - std::ostream* output_stream_; - std::ostream* error_stream_; -}; - -// Simple reporter that outputs benchmark data to the console. This is the -// default reporter used by RunSpecifiedBenchmarks(). -class ConsoleReporter : public BenchmarkReporter { - public: - enum OutputOptions { - OO_None = 0, - OO_Color = 1, - OO_Tabular = 2, - OO_ColorTabular = OO_Color | OO_Tabular, - OO_Defaults = OO_ColorTabular - }; - explicit ConsoleReporter(OutputOptions opts_ = OO_Defaults) - : output_options_(opts_), - name_field_width_(0), - prev_counters_(), - printed_header_(false) {} - - virtual bool ReportContext(const Context& context); - virtual void ReportRuns(const std::vector& reports); - - protected: - virtual void PrintRunData(const Run& report); - virtual void PrintHeader(const Run& report); - - OutputOptions output_options_; - size_t name_field_width_; - UserCounters prev_counters_; - bool printed_header_; -}; - -class JSONReporter : public BenchmarkReporter { - public: - JSONReporter() : first_report_(true) {} - virtual bool ReportContext(const Context& context); - virtual void ReportRuns(const std::vector& reports); - virtual void Finalize(); - - private: - void PrintRunData(const Run& report); - - bool first_report_; -}; - -class BENCHMARK_DEPRECATED_MSG( - "The CSV Reporter will be removed in a future release") CSVReporter - : public BenchmarkReporter { - public: - CSVReporter() : printed_header_(false) {} - virtual bool ReportContext(const Context& context); - virtual void ReportRuns(const std::vector& reports); - - private: - void PrintRunData(const Run& report); - - bool printed_header_; - std::set user_counter_names_; -}; - -// If a MemoryManager is registered, it can be used to collect and report -// allocation metrics for a run of the benchmark. -class MemoryManager { - public: - struct Result { - Result() : num_allocs(0), max_bytes_used(0) {} - - // The number of allocations made in total between Start and Stop. - int64_t num_allocs; - - // The peak memory use between Start and Stop. - int64_t max_bytes_used; - }; - - virtual ~MemoryManager() {} - - // Implement this to start recording allocation information. - virtual void Start() = 0; - - // Implement this to stop recording and fill out the given Result structure. - virtual void Stop(Result* result) = 0; -}; - -inline const char* GetTimeUnitString(TimeUnit unit) { - switch (unit) { - case kMillisecond: - return "ms"; - case kMicrosecond: - return "us"; - case kNanosecond: - return "ns"; - } - BENCHMARK_UNREACHABLE(); -} - -inline double GetTimeUnitMultiplier(TimeUnit unit) { - switch (unit) { - case kMillisecond: - return 1e3; - case kMicrosecond: - return 1e6; - case kNanosecond: - return 1e9; - } - BENCHMARK_UNREACHABLE(); -} - -} // namespace benchmark - -#endif // BENCHMARK_BENCHMARK_H_ diff --git a/opencc/include/opencc/BinaryDict.hpp b/opencc/include/opencc/BinaryDict.hpp deleted file mode 100644 index 7c23268f..00000000 --- a/opencc/include/opencc/BinaryDict.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "SerializableDict.hpp" - -namespace opencc { -/** - * Binary dictionary for faster deserialization - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT BinaryDict : public SerializableDict { -public: - BinaryDict(const LexiconPtr& _lexicon) : lexicon(_lexicon) {} - - virtual ~BinaryDict() {} - - virtual void SerializeToFile(FILE* fp) const; - - static BinaryDictPtr NewFromFile(FILE* fp); - - const LexiconPtr& GetLexicon() const { return lexicon; } - - size_t KeyMaxLength() const; - -private: - LexiconPtr lexicon; - std::string keyBuffer; - std::string valueBuffer; - - void ConstructBuffer(std::string& keyBuffer, std::vector& keyOffset, - size_t& keyTotalLength, std::string& valueBuffer, - std::vector& valueOffset, - size_t& valueTotalLength) const; -}; -} // namespace opencc diff --git a/opencc/include/opencc/Common.hpp b/opencc/include/opencc/Common.hpp deleted file mode 100644 index 067966b5..00000000 --- a/opencc/include/opencc/Common.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -// Microsoft Visual C++ specific -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma warning(disable : 4251 4266 4350 4503 4512 4514 4710 4820) -#endif - -#include -#include -#include -#include - -#include "Export.hpp" -#include "Optional.hpp" -#include "opencc_config.h" - -// Forward decalarations and alias -namespace opencc { -class Config; -class Conversion; -class ConversionChain; -class Converter; -class Dict; -class DictEntry; -class DictGroup; -class Lexicon; -class MarisaDict; -class MultiValueDictEntry; -class NoValueDictEntry; -class Segmentation; -class Segments; -class SerializableDict; -class SingleValueDictEntry; -class TextDict; -typedef std::shared_ptr ConversionPtr; -typedef std::shared_ptr ConversionChainPtr; -typedef std::shared_ptr ConverterPtr; -typedef std::shared_ptr DictPtr; -typedef std::shared_ptr DictGroupPtr; -typedef std::shared_ptr LexiconPtr; -typedef std::shared_ptr MarisaDictPtr; -typedef std::shared_ptr SegmentationPtr; -typedef std::shared_ptr SegmentsPtr; -typedef std::shared_ptr SerializableDictPtr; -typedef std::shared_ptr TextDictPtr; - -#ifdef OPENCC_ENABLE_DARTS -class BinaryDict; -class DartsDict; -typedef std::shared_ptr BinaryDictPtr; -typedef std::shared_ptr DartsDictPtr; -#endif - -} // namespace opencc - -#ifndef PKGDATADIR -const std::string PACKAGE_DATA_DIRECTORY = ""; -#else // ifndef PKGDATADIR -const std::string PACKAGE_DATA_DIRECTORY = PKGDATADIR "/"; -#endif // ifndef PKGDATADIR - -#ifndef VERSION -#define VERSION "1.0.*" -#endif // ifndef VERSION diff --git a/opencc/include/opencc/Config.hpp b/opencc/include/opencc/Config.hpp deleted file mode 100644 index 7a904cee..00000000 --- a/opencc/include/opencc/Config.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" - -namespace opencc { -/** - * Configuration loader - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Config { -public: - Config(); - - virtual ~Config(); - - ConverterPtr NewFromString(const std::string& json, - const std::string& configDirectory); - - ConverterPtr NewFromFile(const std::string& fileName); - -private: - void* internal; -}; -} // namespace opencc diff --git a/opencc/include/opencc/Conversion.hpp b/opencc/include/opencc/Conversion.hpp deleted file mode 100644 index cf73a254..00000000 --- a/opencc/include/opencc/Conversion.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "Segmentation.hpp" - -namespace opencc { -/** - * Conversion interface - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Conversion { -public: - Conversion(DictPtr _dict) : dict(_dict) {} - - // Convert single phrase - std::string Convert(const std::string& phrase) const; - - // Convert single phrase - std::string Convert(const char* phrase) const; - - // Convert segmented text - SegmentsPtr Convert(const SegmentsPtr& input) const; - - const DictPtr GetDict() const { return dict; } - -private: - const DictPtr dict; -}; -} // namespace opencc diff --git a/opencc/include/opencc/ConversionChain.hpp b/opencc/include/opencc/ConversionChain.hpp deleted file mode 100644 index 28853c67..00000000 --- a/opencc/include/opencc/ConversionChain.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -#include "Common.hpp" -#include "Conversion.hpp" - -namespace opencc { -/** - * Chain of conversions - * Consists of a list of conversions. Converts input in sequence. - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT ConversionChain { -public: - ConversionChain(const std::list _conversions); - - SegmentsPtr Convert(const SegmentsPtr& input) const; - - const std::list GetConversions() const { return conversions; } - -private: - const std::list conversions; -}; -} // namespace opencc diff --git a/opencc/include/opencc/Converter.hpp b/opencc/include/opencc/Converter.hpp deleted file mode 100644 index 9f1f3f94..00000000 --- a/opencc/include/opencc/Converter.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "Segmentation.hpp" - -namespace opencc { -/** - * Controller of segmentation and conversion - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Converter { -public: - Converter(const std::string& _name, SegmentationPtr _segmentation, - ConversionChainPtr _conversionChain) - : name(_name), segmentation(_segmentation), - conversionChain(_conversionChain) {} - - std::string Convert(const std::string& text) const; - - size_t Convert(const char* input, char* output) const; - - const SegmentationPtr GetSegmentation() const { return segmentation; } - - const ConversionChainPtr GetConversionChain() const { - return conversionChain; - } - -private: - const std::string name; - const SegmentationPtr segmentation; - const ConversionChainPtr conversionChain; -}; -} // namespace opencc diff --git a/opencc/include/opencc/DartsDict.hpp b/opencc/include/opencc/DartsDict.hpp deleted file mode 100644 index eacc1a8c..00000000 --- a/opencc/include/opencc/DartsDict.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "SerializableDict.hpp" - -namespace opencc { -/** - * Darts dictionary - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT DartsDict : public Dict, public SerializableDict { -public: - virtual ~DartsDict(); - - virtual size_t KeyMaxLength() const; - - virtual Optional Match(const char* word, size_t len) const; - - virtual Optional MatchPrefix(const char* word, - size_t len) const; - - virtual LexiconPtr GetLexicon() const; - - virtual void SerializeToFile(FILE* fp) const; - - /** - * Constructs a DartsDict from another dictionary. - */ - static DartsDictPtr NewFromDict(const Dict& thatDict); - - static DartsDictPtr NewFromFile(FILE* fp); - -private: - DartsDict(); - - size_t maxLength; - LexiconPtr lexicon; - - class DartsInternal; - DartsInternal* internal; -}; -} // namespace opencc diff --git a/opencc/include/opencc/Dict.hpp b/opencc/include/opencc/Dict.hpp deleted file mode 100644 index 1c810346..00000000 --- a/opencc/include/opencc/Dict.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2020 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "DictEntry.hpp" - -namespace opencc { -/** - * Abstract class of dictionary - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Dict { -public: - /** - * Matches a word exactly and returns the DictEntry or Optional::Null(). - */ - virtual Optional Match(const char* word, - size_t len) const = 0; - - /** - * Matches a word exactly and returns the DictEntry or Optional::Null(). - */ - Optional Match(const std::string& word) const { - return Match(word.c_str(), word.length()); - } - - /** - * Matches the longest matched prefix of a word. - * For example given a dictionary having "a", "an", "b", "ba", "ban", "bana", - * the longest prefix of "banana" matched is "bana". - */ - virtual Optional MatchPrefix(const char* word, - size_t len) const; - - /** - * Matches the longest matched prefix of a word. - */ - Optional MatchPrefix(const char* word) const { - return MatchPrefix(word, KeyMaxLength()); - } - - /** - * Matches the longest matched prefix of a word. - */ - Optional MatchPrefix(const std::string& word) const { - return MatchPrefix(word.c_str(), word.length()); - } - - /** - * Returns all matched prefixes of a word, sorted by the length (desc). - * For example given a dictionary having "a", "an", "b", "ba", "ban", "bana", - * all the matched prefixes of "banana" are "bana", "ban", "ba", "b". - */ - virtual std::vector MatchAllPrefixes(const char* word, - size_t len) const; - - /** - * Returns all matched prefixes of a word, sorted by the length (desc). - */ - std::vector - MatchAllPrefixes(const std::string& word) const { - return MatchAllPrefixes(word.c_str(), word.length()); - } - - /** - * Returns the length of the longest key in the dictionary. - */ - virtual size_t KeyMaxLength() const = 0; - - /** - * Returns all entries in the dictionary. - */ - virtual LexiconPtr GetLexicon() const = 0; -}; -} // namespace opencc diff --git a/opencc/include/opencc/DictConverter.hpp b/opencc/include/opencc/DictConverter.hpp deleted file mode 100644 index f911c4fe..00000000 --- a/opencc/include/opencc/DictConverter.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2017 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" - -namespace opencc { -/** - * Converts a dictionary from a format to another. - * @ingroup opencc_cpp_api - */ -OPENCC_EXPORT void ConvertDictionary(const std::string& inputFileName, - const std::string& outputFileName, - const std::string& formatFrom, - const std::string& formatTo); -} // namespace opencc diff --git a/opencc/include/opencc/DictEntry.hpp b/opencc/include/opencc/DictEntry.hpp deleted file mode 100644 index 7b2babda..00000000 --- a/opencc/include/opencc/DictEntry.hpp +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2020 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "Segments.hpp" -#include "UTF8Util.hpp" - -namespace opencc { -/** - * Key-values pair entry - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT DictEntry { -public: - virtual ~DictEntry() {} - - virtual std::string Key() const = 0; - - virtual std::vector Values() const = 0; - - virtual std::string GetDefault() const = 0; - - virtual size_t NumValues() const = 0; - - virtual std::string ToString() const = 0; - - size_t KeyLength() const { return Key().length(); } - - bool operator<(const DictEntry& that) const { return Key() < that.Key(); } - - bool operator==(const DictEntry& that) const { return Key() == that.Key(); } - - static bool UPtrLessThan(const std::unique_ptr& a, - const std::unique_ptr& b) { - return *a < *b; - } -}; - -class OPENCC_EXPORT NoValueDictEntry : public DictEntry { -public: - NoValueDictEntry(const std::string& _key) : key(_key) {} - - virtual ~NoValueDictEntry() {} - - virtual std::string Key() const { return key; } - - virtual std::vector Values() const { - return std::vector(); - } - - virtual std::string GetDefault() const { return key; } - - virtual size_t NumValues() const { return 0; } - - virtual std::string ToString() const { return key; } - -private: - std::string key; -}; - -class OPENCC_EXPORT SingleValueDictEntry : public DictEntry { -public: - virtual std::string Value() const = 0; - - virtual std::vector Values() const { - return std::vector{Value()}; - } - - virtual std::string GetDefault() const { return Value(); } - - virtual size_t NumValues() const { return 1; } - - virtual std::string ToString() const { - return std::string(Key()) + "\t" + Value(); - } -}; - -class OPENCC_EXPORT StrSingleValueDictEntry : public SingleValueDictEntry { -public: - StrSingleValueDictEntry(const std::string& _key, const std::string& _value) - : key(_key), value(_value) {} - - virtual ~StrSingleValueDictEntry() {} - - virtual std::string Key() const { return key; } - - virtual std::string Value() const { return value; } - -private: - std::string key; - std::string value; -}; - -class OPENCC_EXPORT MultiValueDictEntry : public DictEntry { -public: - virtual std::string GetDefault() const { - if (NumValues() > 0) { - return Values().at(0); - } else { - return Key(); - } - } - - virtual std::string ToString() const; -}; - -class OPENCC_EXPORT StrMultiValueDictEntry : public MultiValueDictEntry { -public: - StrMultiValueDictEntry(const std::string& _key, - const std::vector& _values) - : key(_key), values(_values) {} - - virtual ~StrMultiValueDictEntry() {} - - virtual std::string Key() const { return key; } - - size_t NumValues() const { return values.size(); } - - std::vector Values() const { return values; } - -private: - std::string key; - std::vector values; -}; - -class OPENCC_EXPORT DictEntryFactory { -public: - static DictEntry* New(const std::string& key) { - return new NoValueDictEntry(key); - } - - static DictEntry* New(const std::string& key, const std::string& value) { - return new StrSingleValueDictEntry(key, value); - } - - static DictEntry* New(const std::string& key, - const std::vector& values) { - if (values.size() == 0) { - return New(key); - } else if (values.size() == 1) { - return New(key, values.front()); - } - return new StrMultiValueDictEntry(key, values); - } - - static DictEntry* New(const DictEntry* entry) { - if (entry->NumValues() == 0) { - return new NoValueDictEntry(entry->Key()); - } else if (entry->NumValues() == 1) { - return new StrSingleValueDictEntry(entry->Key(), entry->Values().front()); - } else { - return new StrMultiValueDictEntry(entry->Key(), entry->Values()); - } - } -}; -} // namespace opencc diff --git a/opencc/include/opencc/DictGroup.hpp b/opencc/include/opencc/DictGroup.hpp deleted file mode 100644 index fd51d913..00000000 --- a/opencc/include/opencc/DictGroup.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -#include "Common.hpp" -#include "Dict.hpp" - -namespace opencc { -/** - * Group of dictionaries - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT DictGroup : public Dict { -public: - DictGroup(const std::list& dicts); - - static DictGroupPtr NewFromDict(const Dict& dict); - - virtual ~DictGroup(); - - virtual size_t KeyMaxLength() const; - - virtual Optional Match(const char* word, size_t len) const; - - virtual Optional MatchPrefix(const char* word, - size_t len) const; - - virtual std::vector MatchAllPrefixes(const char* word, - size_t len) const; - - virtual LexiconPtr GetLexicon() const; - - const std::list GetDicts() const { return dicts; } - -private: - const size_t keyMaxLength; - const std::list dicts; -}; -} // namespace opencc diff --git a/opencc/include/opencc/Exception.hpp b/opencc/include/opencc/Exception.hpp deleted file mode 100644 index 7875537f..00000000 --- a/opencc/include/opencc/Exception.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include -#include - -#include "Export.hpp" - -#if defined(_MSC_VER) && _MSC_VER < 1900 -// Before Visual Studio 2015 (14.0), C++ 11 "noexcept" qualifier is not -// supported -#define noexcept -#endif // ifdef _MSC_VER - -namespace opencc { - -class OPENCC_EXPORT Exception { -public: - Exception() {} - - virtual ~Exception() throw() {} - - Exception(const std::string& _message) : message(_message) {} - - virtual const char* what() const noexcept { return message.c_str(); } - -protected: - std::string message; -}; - -class OPENCC_EXPORT FileNotFound : public Exception { -public: - FileNotFound(const std::string& fileName) - : Exception(fileName + " not found or not accessible.") {} -}; - -class OPENCC_EXPORT FileNotWritable : public Exception { -public: - FileNotWritable(const std::string& fileName) - : Exception(fileName + " not writable.") {} -}; - -class OPENCC_EXPORT InvalidFormat : public Exception { -public: - InvalidFormat(const std::string& message) - : Exception("Invalid format: " + message) {} -}; - -class OPENCC_EXPORT InvalidTextDictionary : public InvalidFormat { -public: - InvalidTextDictionary(const std::string& _message, size_t lineNum) - : InvalidFormat("") { - std::ostringstream buffer; - buffer << "Invalid text dictionary at line " << lineNum << ": " << _message; - message = buffer.str(); - } -}; - -class OPENCC_EXPORT InvalidUTF8 : public Exception { -public: - InvalidUTF8(const std::string& _message) - : Exception("Invalid UTF8: " + _message) {} -}; - -class OPENCC_EXPORT ShouldNotBeHere : public Exception { -public: - ShouldNotBeHere() : Exception("ShouldNotBeHere! This must be a bug.") {} -}; - -} // namespace opencc diff --git a/opencc/include/opencc/Export.hpp b/opencc/include/opencc/Export.hpp deleted file mode 100644 index 0015e880..00000000 --- a/opencc/include/opencc/Export.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) -#define OPENCC_EXPORT -#define OPENCC_NO_EXPORT -#else // if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) -#ifndef OPENCC_EXPORT -#ifdef libopencc_EXPORTS - -/* We are building this library */ -#define OPENCC_EXPORT __declspec(dllexport) -#else // ifdef libopencc_EXPORTS - -/* We are using this library */ -#define OPENCC_EXPORT __declspec(dllimport) -#endif // ifdef libopencc_EXPORTS -#endif // ifndef OPENCC_EXPORT - -#ifndef OPENCC_NO_EXPORT -#define OPENCC_NO_EXPORT -#endif // ifndef OPENCC_NO_EXPORT -#endif // if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) diff --git a/opencc/include/opencc/Lexicon.hpp b/opencc/include/opencc/Lexicon.hpp deleted file mode 100644 index 68891287..00000000 --- a/opencc/include/opencc/Lexicon.hpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "DictEntry.hpp" - -namespace opencc { -/** - * Storage of all entries - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Lexicon { -public: - Lexicon() {} - Lexicon(std::vector> entries_) - : entries(std::move(entries_)) {} - Lexicon(const Lexicon&) = delete; - Lexicon& operator=(const Lexicon&) = delete; - - // Lexicon will take the ownership of the entry. - void Add(DictEntry* entry) { entries.emplace_back(entry); } - - void Add(std::unique_ptr entry) { - entries.push_back(std::move(entry)); - } - - void Sort(); - - // Returns true if the lexicon is sorted by key. - bool IsSorted(); - - // Returns true if every key unique (after sorted). - // When dupkey is set, it is set to the duplicate key. - bool IsUnique(std::string* dupkey = nullptr); - - const DictEntry* At(size_t index) const { return entries.at(index).get(); } - - size_t Length() const { return entries.size(); } - - std::vector>::const_iterator begin() const { - return entries.begin(); - } - - std::vector>::const_iterator end() const { - return entries.end(); - } - -private: - std::vector> entries; -}; -} // namespace opencc diff --git a/opencc/include/opencc/MarisaDict.hpp b/opencc/include/opencc/MarisaDict.hpp deleted file mode 100644 index 6917c23a..00000000 --- a/opencc/include/opencc/MarisaDict.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2020 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "SerializableDict.hpp" - -namespace opencc { -/** - * Darts dictionary - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT MarisaDict : public Dict, public SerializableDict { -public: - virtual ~MarisaDict(); - - virtual size_t KeyMaxLength() const; - - virtual Optional Match(const char* word, size_t len) const; - - virtual Optional MatchPrefix(const char* word, - size_t len) const; - - virtual std::vector MatchAllPrefixes(const char* word, - size_t len) const; - - virtual LexiconPtr GetLexicon() const; - - virtual void SerializeToFile(FILE* fp) const; - - /** - * Constructs a MarisaDict from another dictionary. - */ - static MarisaDictPtr NewFromDict(const Dict& thatDict); - - static MarisaDictPtr NewFromFile(FILE* fp); - -private: - MarisaDict(); - - size_t maxLength; - LexiconPtr lexicon; - - class MarisaInternal; - std::unique_ptr internal; -}; -} // namespace opencc diff --git a/opencc/include/opencc/MaxMatchSegmentation.hpp b/opencc/include/opencc/MaxMatchSegmentation.hpp deleted file mode 100644 index 1ecc227e..00000000 --- a/opencc/include/opencc/MaxMatchSegmentation.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "DictGroup.hpp" -#include "Segmentation.hpp" - -namespace opencc { -/** - * Implementation of maximal match segmentation - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT MaxMatchSegmentation : public Segmentation { -public: - MaxMatchSegmentation(const DictPtr _dict) : dict(_dict) {} - - virtual ~MaxMatchSegmentation() {} - - virtual SegmentsPtr Segment(const std::string& text) const; - - const DictPtr GetDict() const { return dict; } - -private: - const DictPtr dict; -}; -} // namespace opencc diff --git a/opencc/include/opencc/Optional.hpp b/opencc/include/opencc/Optional.hpp deleted file mode 100644 index 8a510f43..00000000 --- a/opencc/include/opencc/Optional.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -namespace opencc { -/** - * A class that wraps type T into a nullable type. - * @ingroup opencc_cpp_api - */ -template class Optional { -public: - /** - * The constructor of Optional. - */ - Optional(T actual) : isNull(false), data(actual) {} - - /** - * Returns true if the instance is null. - */ - bool IsNull() const { return isNull; } - - /** - * Returns the containing data of the instance. - */ - const T& Get() const { return data; } - - /** - * Constructs a null instance. - */ - static Optional Null() { return Optional(); } - -private: - Optional() : isNull(true) {} - - bool isNull; - T data; -}; - -/** - * Specialization of Optional for pointers. - * - * Reduce a bool. - */ -template class Optional { -private: - Optional() : data(nullptr) {} - - typedef T* TPtr; - TPtr data; - -public: - Optional(TPtr actual) : data(actual) {} - - bool IsNull() const { return data == nullptr; } - - const TPtr& Get() const { return data; } - - static Optional Null() { return Optional(); } -}; -} // namespace opencc \ No newline at end of file diff --git a/opencc/include/opencc/PhraseExtract.hpp b/opencc/include/opencc/PhraseExtract.hpp deleted file mode 100644 index 75a165de..00000000 --- a/opencc/include/opencc/PhraseExtract.hpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2015 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include - -#include "Common.hpp" -#include "UTF8StringSlice.hpp" - -namespace opencc { - -class OPENCC_EXPORT PhraseExtract { -public: - typedef UTF8StringSlice::LengthType LengthType; - - typedef UTF8StringSliceBase UTF8StringSlice8Bit; - - PhraseExtract(); - - virtual ~PhraseExtract(); - - void Extract(const std::string& text) { - SetFullText(text); - ExtractSuffixes(); - CalculateFrequency(); - CalculateSuffixEntropy(); - ReleaseSuffixes(); - ExtractPrefixes(); - CalculatePrefixEntropy(); - ReleasePrefixes(); - ExtractWordCandidates(); - CalculateCohesions(); - SelectWords(); - } - - void SetFullText(const std::string& fullText) { - utf8FullText = UTF8StringSlice(fullText.c_str()); - } - - void SetFullText(const char* fullText) { - utf8FullText = UTF8StringSlice(fullText); - } - - void SetFullText(const UTF8StringSlice& fullText) { utf8FullText = fullText; } - - void SetWordMinLength(const LengthType _wordMinLength) { - wordMinLength = _wordMinLength; - } - - void SetWordMaxLength(const LengthType _wordMaxLength) { - wordMaxLength = _wordMaxLength; - } - - void SetPrefixSetLength(const LengthType _prefixSetLength) { - prefixSetLength = _prefixSetLength; - } - - void SetSuffixSetLength(const LengthType _suffixSetLength) { - suffixSetLength = _suffixSetLength; - } - - // PreCalculationFilter is called after frequencies statistics. - void SetPreCalculationFilter( - const std::function& filter) { - preCalculationFilter = filter; - } - - void SetPostCalculationFilter( - const std::function& filter) { - postCalculationFilter = filter; - } - - void ReleaseSuffixes() { std::vector().swap(suffixes); } - - void ReleasePrefixes() { std::vector().swap(prefixes); } - - const std::vector& Words() const { return words; } - - const std::vector& WordCandidates() const { - return wordCandidates; - } - - struct Signals { - size_t frequency; - double cohesion; - double suffixEntropy; - double prefixEntropy; - }; - - const Signals& Signal(const UTF8StringSlice8Bit& wordCandidate) const; - - double Cohesion(const UTF8StringSlice8Bit& wordCandidate) const; - - double Entropy(const UTF8StringSlice8Bit& wordCandidate) const; - - double SuffixEntropy(const UTF8StringSlice8Bit& wordCandidate) const; - - double PrefixEntropy(const UTF8StringSlice8Bit& wordCandidate) const; - - size_t Frequency(const UTF8StringSlice8Bit& word) const; - - double Probability(const UTF8StringSlice8Bit& word) const; - - double LogProbability(const UTF8StringSlice8Bit& word) const; - - void Reset(); - - void ExtractSuffixes(); - - void ExtractPrefixes(); - - void ExtractWordCandidates(); - - void CalculateFrequency(); - - void CalculateCohesions(); - - void CalculateSuffixEntropy(); - - void CalculatePrefixEntropy(); - - void SelectWords(); - - static bool - DefaultPreCalculationFilter(const PhraseExtract&, - const PhraseExtract::UTF8StringSlice8Bit&); - - static bool - DefaultPostCalculationFilter(const PhraseExtract&, - const PhraseExtract::UTF8StringSlice8Bit&); - -private: - class DictType; - - // Pointwise Mutual Information - double PMI(const UTF8StringSlice8Bit& wordCandidate, - const UTF8StringSlice8Bit& part1, - const UTF8StringSlice8Bit& part2) const; - - double CalculateCohesion(const UTF8StringSlice8Bit& wordCandidate) const; - - double CalculateEntropy( - const std::unordered_map& choices) const; - - LengthType wordMinLength; - LengthType wordMaxLength; - LengthType prefixSetLength; - LengthType suffixSetLength; - std::function - preCalculationFilter; - std::function - postCalculationFilter; - - bool prefixesExtracted; - bool suffixesExtracted; - bool frequenciesCalculated; - bool wordCandidatesExtracted; - bool cohesionsCalculated; - bool prefixEntropiesCalculated; - bool suffixEntropiesCalculated; - bool wordsSelected; - - UTF8StringSlice utf8FullText; - size_t totalOccurrence; - double logTotalOccurrence; - std::vector prefixes; - std::vector suffixes; - std::vector wordCandidates; - std::vector words; - DictType* signals; - - friend class PhraseExtractTest; -}; - -} // namespace opencc diff --git a/opencc/include/opencc/Segmentation.hpp b/opencc/include/opencc/Segmentation.hpp deleted file mode 100644 index c260ea6d..00000000 --- a/opencc/include/opencc/Segmentation.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" - -namespace opencc { -/** - * Abstract segmentation - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Segmentation { -public: - virtual SegmentsPtr Segment(const std::string& text) const = 0; -}; -} // namespace opencc diff --git a/opencc/include/opencc/Segments.hpp b/opencc/include/opencc/Segments.hpp deleted file mode 100644 index 21c39813..00000000 --- a/opencc/include/opencc/Segments.hpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -#include "Common.hpp" - -namespace opencc { -/** - * Segmented text - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT Segments { -public: - Segments() {} - - Segments(std::initializer_list initList) { - for (const std::string& item : initList) { - AddSegment(item); - } - } - - Segments(std::initializer_list initList) { - for (const std::string& item : initList) { - AddSegment(item); - } - } - - void AddSegment(const char* unmanagedString) { - indexes.push_back(std::make_pair(unmanaged.size(), false)); - unmanaged.push_back(unmanagedString); - } - - void AddSegment(const std::string& str) { - indexes.push_back(std::make_pair(managed.size(), true)); - managed.push_back(str); - } - - class iterator : public std::iterator { - public: - iterator(const Segments* const _segments, size_t _cursor) - : segments(_segments), cursor(_cursor) {} - - iterator& operator++() { - cursor++; - return *this; - } - - bool operator==(const iterator& that) const { - return cursor == that.cursor && segments == that.segments; - } - - bool operator!=(const iterator& that) const { - return !this->operator==(that); - } - - const char* operator*() const { return segments->At(cursor); } - - private: - const Segments* const segments; - size_t cursor; - }; - - const char* At(size_t cursor) const { - const auto& index = indexes[cursor]; - if (index.second) { - return managed[index.first].c_str(); - } else { - return unmanaged[index.first]; - } - } - - size_t Length() const { return indexes.size(); } - - iterator begin() const { return iterator(this, 0); } - - iterator end() const { return iterator(this, indexes.size()); } - - std::string ToString() const { - // TODO implement a nested structure to reduce concatenation, - // like a purely functional differential list - std::ostringstream buffer; - for (const char* segment : *this) { - buffer << segment; - } - return buffer.str(); - } - -private: - Segments(const Segments&) {} - - std::vector unmanaged; - std::vector managed; - // index, managed - std::vector> indexes; -}; -} // namespace opencc diff --git a/opencc/include/opencc/SerializableDict.hpp b/opencc/include/opencc/SerializableDict.hpp deleted file mode 100644 index 17cea890..00000000 --- a/opencc/include/opencc/SerializableDict.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Dict.hpp" - -namespace opencc { -/** - * Serializable dictionary interface - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT SerializableDict { -public: - /** - * Serializes the dictionary and writes in to a file. - */ - virtual void SerializeToFile(FILE* fp) const = 0; - - /** - * Serializes the dictionary and writes in to a file. - */ - virtual void SerializeToFile(const std::string& fileName) const { - FILE* fp = fopen(fileName.c_str(), "wb"); - if (fp == NULL) { - throw FileNotWritable(fileName); - } - SerializeToFile(fp); - fclose(fp); - } - - template - static bool TryLoadFromFile(const std::string& fileName, - std::shared_ptr* dict) { - FILE* fp = -#ifdef _MSC_VER - // well, the 'GetPlatformString' shall return a 'wstring' - _wfopen(UTF8Util::GetPlatformString(fileName).c_str(), L"rb") -#else - fopen(UTF8Util::GetPlatformString(fileName).c_str(), "rb") -#endif // _MSC_VER - ; - - if (fp == NULL) { - return false; - } - std::shared_ptr loadedDict = DICT::NewFromFile(fp); - fclose(fp); - *dict = loadedDict; - return true; - } - - template - static std::shared_ptr NewFromFile(const std::string& fileName) { - std::shared_ptr dict; - if (!TryLoadFromFile(fileName, &dict)) { - throw FileNotFound(fileName); - } - return dict; - } -}; -} // namespace opencc diff --git a/opencc/include/opencc/SerializedValues.hpp b/opencc/include/opencc/SerializedValues.hpp deleted file mode 100644 index c17210ba..00000000 --- a/opencc/include/opencc/SerializedValues.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2020 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "SerializableDict.hpp" - -namespace opencc { -/** - * Binary format for dictionary values serialization. - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT SerializedValues : public SerializableDict { -public: - SerializedValues(const LexiconPtr& _lexicon) : lexicon(_lexicon) {} - - virtual ~SerializedValues() {} - - virtual void SerializeToFile(FILE* fp) const; - - static std::shared_ptr NewFromFile(FILE* fp); - - const LexiconPtr& GetLexicon() const { return lexicon; } - - size_t KeyMaxLength() const; - -private: - LexiconPtr lexicon; - - void ConstructBuffer(std::string* valueBuffer, - std::vector* valueBytes, - uint32_t* valueTotalLength) const; -}; -} // namespace opencc diff --git a/opencc/include/opencc/SimpleConverter.hpp b/opencc/include/opencc/SimpleConverter.hpp deleted file mode 100644 index 206edea7..00000000 --- a/opencc/include/opencc/SimpleConverter.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Export.hpp" -#include - -#ifndef __OPENCC_SIMPLECONVERTER_HPP_ -#define __OPENCC_SIMPLECONVERTER_HPP_ - -/** - * @defgroup opencc_simple_api OpenCC C++ Simple API - * - * Simple API in C++ language - */ - -namespace opencc { -/** - * A high level converter - * This interface does not require C++11 to compile. - * @ingroup opencc_simple_api - */ -class OPENCC_EXPORT SimpleConverter { -public: - /** - * Constructor of SimpleConverter - * @param configFileName File name of configuration. - */ - SimpleConverter(const std::string& configFileName); - - ~SimpleConverter(); - - /** - * Converts a text - * @param input Text to be converted. - */ - std::string Convert(const std::string& input) const; - - /** - * Converts a text - * @param input A C-Style std::string (terminated by '\0') to be converted. - */ - std::string Convert(const char* input) const; - - /** - * Converts a text - * @param input A C-Style std::string limited by a given length to be - * converted. - * @param length Maximal length in byte of the input std::string. - */ - std::string Convert(const char* input, size_t length) const; - - /** - * Converts a text and writes to an allocated buffer - * Please make sure the buffer has sufficent space. - * @param input A C-Style std::string (terminated by '\0') to be converted. - * @param output Buffer to write the converted text. - * @return Length of converted text. - */ - size_t Convert(const char* input, char* output) const; - - /** - * Converts a text and writes to an allocated buffer - * Please make sure the buffer has sufficent space. - * @param input A C-Style std::string limited by a given length to be - * converted. - * @param length Maximal length in byte of the input std::string. - * @param output Buffer to write the converted text. - * @return Length of converted text. - */ - size_t Convert(const char* input, size_t length, char* output) const; - -private: - const void* internalData; -}; - -} // namespace opencc - -#endif diff --git a/opencc/include/opencc/TextDict.hpp b/opencc/include/opencc/TextDict.hpp deleted file mode 100644 index f1cb67d9..00000000 --- a/opencc/include/opencc/TextDict.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2020 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "SerializableDict.hpp" - -namespace opencc { -/** - * Text dictionary - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT TextDict : public Dict, public SerializableDict { -public: - /** - * Constructor of TextDict. - * _lexicon must be sorted. - */ - TextDict(const LexiconPtr& _lexicon); - - virtual ~TextDict(); - - virtual size_t KeyMaxLength() const; - - virtual Optional Match(const char* word, size_t len) const; - - virtual LexiconPtr GetLexicon() const; - - virtual void SerializeToFile(FILE* fp) const; - - /** - * Constructs a TextDict from another dictionary. - */ - static TextDictPtr NewFromDict(const Dict& dict); - - static TextDictPtr NewFromFile(FILE* fp); - - static TextDictPtr NewFromSortedFile(FILE* fp); - -private: - const size_t maxLength; - const LexiconPtr lexicon; -}; -} // namespace opencc diff --git a/opencc/include/opencc/UTF8StringSlice.hpp b/opencc/include/opencc/UTF8StringSlice.hpp deleted file mode 100644 index 0c9dfdc6..00000000 --- a/opencc/include/opencc/UTF8StringSlice.hpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2015 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "Common.hpp" -#include "UTF8Util.hpp" - -namespace opencc { - -namespace internal { - -inline size_t FNVHash(const char* text, const size_t byteLength, - const size_t FNV_prime, const size_t FNV_offset_basis) { - size_t hash = FNV_offset_basis; - for (const char* pstr = text; pstr < text + byteLength; pstr++) { - hash ^= *pstr; - hash *= FNV_prime; - } - return hash; -} - -template size_t FNVHash(const char* text, const size_t byteLength); - -template <> -inline size_t FNVHash<4>(const char* text, const size_t byteLength) { - return FNVHash(text, byteLength, 16777619UL, 2166136261UL); -} - -#if SIZE_MAX == 0xffffffffffffffff -template <> -inline size_t FNVHash<8>(const char* text, const size_t byteLength) { - return FNVHash(text, byteLength, 1099511628211UL, 14695981039346656037UL); -} -#endif - -} // namespace internal - -template class UTF8StringSliceBase { -public: - typedef LENGTH_TYPE LengthType; - - UTF8StringSliceBase(const char* _str) - : str(_str), utf8Length(static_cast(UTF8Util::Length(_str))), - byteLength(static_cast(strlen(_str))) {} - - UTF8StringSliceBase(const char* _str, const LengthType _utf8Length) - : str(_str), utf8Length(_utf8Length) { - CalculateByteLength(); - } - - UTF8StringSliceBase(const char* _str, const LengthType _utf8Length, - const LengthType _byteLength) - : str(_str), utf8Length(_utf8Length), byteLength(_byteLength) { - CalculateByteLength(); - } - - LengthType UTF8Length() const { return utf8Length; } - - LengthType ByteLength() const { return byteLength; } - - UTF8StringSliceBase Left(const LengthType numberOfCharacters) const { - if (numberOfCharacters == UTF8Length()) { - return *this; - } else { - return UTF8StringSliceBase(str, numberOfCharacters); - } - } - - UTF8StringSliceBase Right(const LengthType numberOfCharacters) const { - if (numberOfCharacters == UTF8Length()) { - return *this; - } else { - const char* pstr = str + byteLength; - for (size_t i = 0; i < numberOfCharacters; i++) { - pstr = UTF8Util::PrevChar(pstr); - } - return UTF8StringSliceBase(pstr, numberOfCharacters); - } - } - - UTF8StringSliceBase SubString(const LengthType offset, - const LengthType numberOfCharacters) const { - if (offset == 0) { - return Left(numberOfCharacters); - } else { - const char* pstr = str; - for (size_t i = 0; i < offset; i++) { - pstr = UTF8Util::NextChar(pstr); - } - return UTF8StringSliceBase(pstr, numberOfCharacters); - } - } - - std::string ToString() const { return std::string(str, str + byteLength); } - - const char* CString() const { return str; } - - LengthType CommonPrefixLength(const UTF8StringSliceBase& that) const { - if (str == that.str) { - return (std::min)(utf8Length, that.utf8Length); - } else { - const char* pstr1 = str; - const char* pstr2 = that.str; - for (size_t length = 0; length < utf8Length && length < that.utf8Length; - length++) { - size_t charLen1 = UTF8Util::NextCharLength(pstr1); - size_t charLen2 = UTF8Util::NextCharLength(pstr2); - if (charLen1 != charLen2 || strncmp(pstr1, pstr2, charLen1) != 0) { - return length; - } - pstr1 += charLen1; - pstr2 += charLen2; - } - return 0; - } - } - - void MoveRight() { - if (utf8Length > 0) { - const size_t charLen = UTF8Util::NextCharLength(str); - str += charLen; - utf8Length--; - byteLength -= charLen; - } - } - - void MoveLeft() { - if (utf8Length > 0) { - const size_t charLen = UTF8Util::PrevCharLength(str + byteLength); - utf8Length--; - byteLength -= charLen; - } - } - - int ReverseCompare(const UTF8StringSliceBase& that) const { - const char* pstr1 = str + byteLength; - const char* pstr2 = that.str + that.byteLength; - const size_t length = (std::min)(utf8Length, that.utf8Length); - for (size_t i = 0; i < length; i++) { - const size_t charLen1 = UTF8Util::PrevCharLength(pstr1); - const size_t charLen2 = UTF8Util::PrevCharLength(pstr2); - pstr1 -= charLen1; - pstr2 -= charLen2; - const int cmp = strncmp(pstr1, pstr2, (std::min)(charLen1, charLen2)); - if (cmp < 0) { - return -1; - } else if (cmp > 0) { - return 1; - } else if (charLen1 < charLen2) { - return -1; - } else if (charLen1 > charLen2) { - return 1; - } - } - if (utf8Length < that.utf8Length) { - return -1; - } else if (utf8Length > that.utf8Length) { - return 1; - } else { - return 0; - } - } - - LengthType FindBytePosition(const UTF8StringSliceBase& pattern) const { - return static_cast( - ToString().find(pattern.str, 0, pattern.byteLength)); - } - - bool operator<(const UTF8StringSliceBase& that) const { - return Compare(that) < 0; - } - - bool operator>(const UTF8StringSliceBase& that) const { - return Compare(that) > 0; - } - - bool operator==(const UTF8StringSliceBase& that) const { - return (str == that.str && utf8Length == that.utf8Length) || - Compare(that) == 0; - } - - bool operator!=(const UTF8StringSliceBase& that) const { - return !this->operator==(that); - } - - class Hasher { - public: - size_t operator()(const UTF8StringSliceBase& text) const { - return internal::FNVHash(text.CString(), - text.ByteLength()); - } - }; - -private: - inline int Compare(const UTF8StringSliceBase& that) const { - int cmp = strncmp(str, that.str, (std::min)(byteLength, that.byteLength)); - if (cmp == 0) { - if (utf8Length < that.utf8Length) { - cmp = -1; - } else if (utf8Length > that.utf8Length) { - cmp = 1; - } else { - cmp = 0; - } - } - return cmp; - } - - void CalculateByteLength() { - const char* pstr = str; - for (size_t i = 0; i < utf8Length; i++) { - pstr = UTF8Util::NextChar(pstr); - } - byteLength = static_cast(pstr - str); - } - - const char* str; - LengthType utf8Length; - LengthType byteLength; -}; - -typedef UTF8StringSliceBase UTF8StringSlice; - -template -std::ostream& operator<<(::std::ostream& os, - const UTF8StringSliceBase& str) { - return os << str.ToString(); -} - -} // namespace opencc diff --git a/opencc/include/opencc/UTF8Util.hpp b/opencc/include/opencc/UTF8Util.hpp deleted file mode 100644 index a04a6fcc..00000000 --- a/opencc/include/opencc/UTF8Util.hpp +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2013 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#ifdef _MSC_VER -#define NOMINMAX -#include -#undef NOMINMAX -#endif // _MSC_VER - -#include - -#include "Common.hpp" -#include "Exception.hpp" - -namespace opencc { -/** - * UTF8 std::string utilities - * @ingroup opencc_cpp_api - */ -class OPENCC_EXPORT UTF8Util { -public: - /** - * Detect UTF8 BOM and skip it. - */ - static void SkipUtf8Bom(FILE* fp); - - /** - * Returns the length in byte for the next UTF8 character. - * On error returns 0. - */ - static size_t NextCharLengthNoException(const char* str) { - char ch = *str; - if ((ch & 0xF0) == 0xE0) { - return 3; - } else if ((ch & 0x80) == 0x00) { - return 1; - } else if ((ch & 0xE0) == 0xC0) { - return 2; - } else if ((ch & 0xF8) == 0xF0) { - return 4; - } else if ((ch & 0xFC) == 0xF8) { - return 5; - } else if ((ch & 0xFE) == 0xFC) { - return 6; - } - return 0; - } - - /** - * Returns the length in byte for the next UTF8 character. - */ - static size_t NextCharLength(const char* str) { - size_t length = NextCharLengthNoException(str); - if (length == 0) { - throw InvalidUTF8(str); - } - return length; - } - - /** - * Returns the length in byte for the previous UTF8 character. - */ - static size_t PrevCharLength(const char* str) { - { - const size_t length = NextCharLengthNoException(str - 3); - if (length == 3) { - return length; - } - } - { - const size_t length = NextCharLengthNoException(str - 1); - if (length == 1) { - return length; - } - } - { - const size_t length = NextCharLengthNoException(str - 2); - if (length == 2) { - return length; - } - } - for (size_t i = 4; i <= 6; i++) { - const size_t length = NextCharLengthNoException(str - i); - if (length == i) { - return length; - } - } - throw InvalidUTF8(str); - } - - /** - * Returns the char* pointer over the next UTF8 character. - */ - static const char* NextChar(const char* str) { - return str + NextCharLength(str); - } - - /** - * Move the char* pointer before the previous UTF8 character. - */ - static const char* PrevChar(const char* str) { - return str - PrevCharLength(str); - } - - /** - * Returns the UTF8 length of a valid UTF8 std::string. - */ - static size_t Length(const char* str) { - size_t length = 0; - while (*str != '\0') { - str = NextChar(str); - length++; - } - return length; - } - - /** - * Finds a character in the same line. - * @param str The text to be searched in. - * @param ch The character to find. - * @return The pointer that points to the found chacter in str or EOL/EOF. - */ - static const char* FindNextInline(const char* str, const char ch) { - while (!IsLineEndingOrFileEnding(*str) && *str != ch) { - str = NextChar(str); - } - return str; - } - - /** - * Returns ture if the character is a line ending or end of file. - */ - static bool IsLineEndingOrFileEnding(const char ch) { - return ch == '\0' || ch == '\n' || ch == '\r'; - } - - /** - * Copies a substring with given length to a new string. - */ - static std::string FromSubstr(const char* str, size_t length) { - std::string newStr; - newStr.resize(length); - strncpy(const_cast(newStr.c_str()), str, length); - return newStr; - } - - /** - * Returns true if the given std::string is longer or as long as the given - * length. - */ - static bool NotShorterThan(const char* str, size_t byteLength) { - while (byteLength > 0) { - if (*str == '\0') { - return false; - } - byteLength--; - str++; - } - return true; - } - - /** - * Truncates a std::string with a maximal length in byte. - * No UTF8 character will be broken. - */ - static std::string TruncateUTF8(const char* str, size_t maxByteLength) { - std::string wordTrunc; - if (NotShorterThan(str, maxByteLength)) { - size_t len = 0; - const char* pStr = str; - for (;;) { - const size_t charLength = NextCharLength(pStr); - if (len + charLength > maxByteLength) { - break; - } - pStr += charLength; - len += charLength; - } - wordTrunc = FromSubstr(str, len); - } else { - wordTrunc = str; - } - return wordTrunc; - } - - /** - * Replaces all patterns in a std::string in place. - */ - static void ReplaceAll(std::string& str, const char* from, const char* to) { - std::string::size_type pos = 0; - std::string::size_type fromLen = strlen(from); - std::string::size_type toLen = strlen(to); - while ((pos = str.find(from, pos)) != std::string::npos) { - str.replace(pos, fromLen, to); - pos += toLen; - } - } - - /** - * Joins a std::string vector in to a std::string with a separator. - */ - static std::string Join(const std::vector& strings, - const std::string& separator) { - std::ostringstream buffer; - bool first = true; - for (const auto& str : strings) { - if (!first) { - buffer << separator; - } - buffer << str; - first = false; - } - return buffer.str(); - } - - /** - * Joins a std::string vector in to a std::string. - */ - static std::string Join(const std::vector& strings) { - std::ostringstream buffer; - for (const auto& str : strings) { - buffer << str; - } - return buffer.str(); - } - - static void GetByteMap(const char* str, const size_t utf8Length, - std::vector* byteMap) { - if (byteMap->size() < utf8Length) { - byteMap->resize(utf8Length); - } - const char* pstr = str; - for (size_t i = 0; i < utf8Length; i++) { - (*byteMap)[i] = pstr - str; - pstr = NextChar(pstr); - } - } - -#ifdef _MSC_VER - static std::wstring GetPlatformString(const std::string& str) { - return U8ToU16(str); - } -#else - static std::string GetPlatformString(const std::string& str) { return str; } -#endif // _MSC_VER - -#ifdef _MSC_VER - static std::string U16ToU8(const std::wstring& wstr) { - std::string ret; - int length = static_cast(wstr.length()); - int convcnt = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), length, NULL, 0, - NULL, NULL); - if (convcnt > 0) { - ret.resize(convcnt); - WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), length, &ret[0], convcnt, - NULL, NULL); - } - return ret; - } - - static std::wstring U8ToU16(const std::string& str) { - std::wstring ret; - int length = static_cast(str.length()); - int convcnt = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, NULL, 0); - if (convcnt > 0) { - ret.resize(convcnt); - MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, &ret[0], convcnt); - } - return ret; - } -#endif // _MSC_VER -}; -} // namespace opencc diff --git a/opencc/include/opencc/opencc.h b/opencc/include/opencc/opencc.h deleted file mode 100644 index bc3a9e97..00000000 --- a/opencc/include/opencc/opencc.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __OPENCC_H_ -#define __OPENCC_H_ - -#ifdef __cplusplus - -#include "Export.hpp" -#include "SimpleConverter.hpp" -#include - -extern "C" { -#else -#include -#endif - -#ifndef OPENCC_EXPORT -#define OPENCC_EXPORT -#endif - -/** - * @defgroup opencc_c_api OpenCC C API - * - * API in C language - */ - -/** - * Filename of default Simplified to Traditional configuration - * - * @ingroup opencc_c_api - */ -#define OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD "s2t.json" - -/** - * Filename of default Traditional to Simplified configuration - * - * @ingroup opencc_c_api - */ -#define OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP "t2s.json" - -/** - * Type of opencc descriptor - * - * @ingroup opencc_c_api - */ -typedef void* opencc_t; - -/** - * Makes an instance of opencc - * - * @param configFileName Location of configuration file. If this is set to NULL, - * OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD will be loaded. - * @return A description pointer of the newly allocated instance of - * opencc. On error the return value will be (opencc_t) -1. - * @ingroup opencc_c_api - */ -OPENCC_EXPORT opencc_t opencc_open(const char* configFileName); -#ifdef _MSC_VER -/** - * Makes an instance of opencc (wide char / Unicode) - * - * @param configFileName Location of configuration file. If this is set to NULL, - * OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD will be loaded. - * @return A description pointer of the newly allocated instance of - * opencc. On error the return value will be (opencc_t) -1. - * @ingroup opencc_c_api - */ -OPENCC_EXPORT opencc_t opencc_open_w(const wchar_t* configFileName); -#endif /* _MSC_VER */ - -/** - * Destroys an instance of opencc - * - * @param opencc The description pointer. - * @return 0 on success or non-zero number on failure. - * @ingroup opencc_c_api - */ -OPENCC_EXPORT int opencc_close(opencc_t opencc); - -/** - * Converts UTF-8 std::string - * - * @param opencc The opencc description pointer. - * @param input The UTF-8 encoded std::string. - * @param length The maximum length in byte to convert. If length is (size_t)-1, - * the whole std::string (terminated by '\0') will be converted. - * @param output The buffer to store converted text. You MUST make sure this - * buffer has sufficient space. - * - * @return The length of converted std::string or (size_t)-1 on error. - * - * @ingroup opencc_c_api - */ -OPENCC_EXPORT size_t opencc_convert_utf8_to_buffer(opencc_t opencc, - const char* input, - size_t length, char* output); - -/** - * Converts UTF-8 std::string - * This function returns an allocated C-Style std::string, which stores - * the converted std::string. - * You MUST call opencc_convert_utf8_free() to release allocated memory. - * - * @param opencc The opencc description pointer. - * @param input The UTF-8 encoded std::string. - * @param length The maximum length in byte to convert. If length is (size_t)-1, - * the whole std::string (terminated by '\0') will be converted. - * - * @return The newly allocated UTF-8 std::string that stores text - * converted, or NULL on error. - * @ingroup opencc_c_api - */ -OPENCC_EXPORT char* opencc_convert_utf8(opencc_t opencc, const char* input, - size_t length); - -/** - * Releases allocated buffer by opencc_convert_utf8 - * - * @param str Pointer to the allocated std::string buffer by - * opencc_convert_utf8. - * - * @ingroup opencc_c_api - */ -OPENCC_EXPORT void opencc_convert_utf8_free(char* str); - -/** - * Returns the last error message - * - * Note that this function is the only one which is NOT thread-safe. - * - * @ingroup opencc_c_api - */ -OPENCC_EXPORT const char* opencc_error(void); - -#ifdef __cplusplus -} // extern "C" -#endif - -/** - * @defgroup opencc_cpp_api OpenCC C++ Comprehensive API - * - * Comprehensive API in C++ language - */ - -#endif diff --git a/opencc/include/opencc/opencc_config.h b/opencc/include/opencc/opencc_config.h deleted file mode 100644 index 711f432c..00000000 --- a/opencc/include/opencc/opencc_config.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2021 Carbo Kuo - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#define OPENCC_ENABLE_DARTS diff --git a/opencc/lib/benchmark.lib b/opencc/lib/benchmark.lib deleted file mode 100644 index 366518f4..00000000 Binary files a/opencc/lib/benchmark.lib and /dev/null differ diff --git a/opencc/lib/benchmark_main.lib b/opencc/lib/benchmark_main.lib deleted file mode 100644 index 1d0bcaca..00000000 Binary files a/opencc/lib/benchmark_main.lib and /dev/null differ diff --git a/opencc/lib/cmake/benchmark/benchmarkConfig.cmake b/opencc/lib/cmake/benchmark/benchmarkConfig.cmake deleted file mode 100644 index f9f75595..00000000 --- a/opencc/lib/cmake/benchmark/benchmarkConfig.cmake +++ /dev/null @@ -1 +0,0 @@ -include("${CMAKE_CURRENT_LIST_DIR}/benchmarkTargets.cmake") diff --git a/opencc/lib/cmake/benchmark/benchmarkConfigVersion.cmake b/opencc/lib/cmake/benchmark/benchmarkConfigVersion.cmake deleted file mode 100644 index e9ee9381..00000000 --- a/opencc/lib/cmake/benchmark/benchmarkConfigVersion.cmake +++ /dev/null @@ -1,70 +0,0 @@ -# This is a basic version file for the Config-mode of find_package(). -# It is used by write_basic_package_version_file() as input file for configure_file() -# to create a version-file which can be installed along a config.cmake file. -# -# The created file sets PACKAGE_VERSION_EXACT if the current version string and -# the requested version string are exactly the same and it sets -# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version, -# but only if the requested major version is the same as the current one. -# The variable CVF_VERSION must be set before calling configure_file(). - - -set(PACKAGE_VERSION "0.0.0") - -if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - - if("0.0.0" MATCHES "^([0-9]+)\\.") - set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") - if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0) - string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}") - endif() - else() - set(CVF_VERSION_MAJOR "0.0.0") - endif() - - if(PACKAGE_FIND_VERSION_RANGE) - # both endpoints of the range must have the expected major version - math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1") - if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR - OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR) - OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT))) - set(PACKAGE_VERSION_COMPATIBLE FALSE) - elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR - AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX) - OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX))) - set(PACKAGE_VERSION_COMPATIBLE TRUE) - else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) - endif() - else() - if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) - set(PACKAGE_VERSION_COMPATIBLE TRUE) - else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) - endif() - - if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) - set(PACKAGE_VERSION_EXACT TRUE) - endif() - endif() -endif() - - -# if the installed project requested no architecture check, don't perform the check -if("FALSE") - return() -endif() - -# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: -if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "4" STREQUAL "") - return() -endif() - -# check that the installed version has the same 32/64bit-ness as the one which is currently searching: -if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "4") - math(EXPR installedBits "4 * 8") - set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") - set(PACKAGE_VERSION_UNSUITABLE TRUE) -endif() diff --git a/opencc/lib/cmake/benchmark/benchmarkTargets-release.cmake b/opencc/lib/cmake/benchmark/benchmarkTargets-release.cmake deleted file mode 100644 index 54b60395..00000000 --- a/opencc/lib/cmake/benchmark/benchmarkTargets-release.cmake +++ /dev/null @@ -1,29 +0,0 @@ -#---------------------------------------------------------------- -# Generated CMake target import file for configuration "Release". -#---------------------------------------------------------------- - -# Commands may need to know the format version. -set(CMAKE_IMPORT_FILE_VERSION 1) - -# Import target "benchmark::benchmark" for configuration "Release" -set_property(TARGET benchmark::benchmark APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) -set_target_properties(benchmark::benchmark PROPERTIES - IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/benchmark.lib" - IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/benchmark.dll" - ) - -list(APPEND _IMPORT_CHECK_TARGETS benchmark::benchmark ) -list(APPEND _IMPORT_CHECK_FILES_FOR_benchmark::benchmark "${_IMPORT_PREFIX}/lib/benchmark.lib" "${_IMPORT_PREFIX}/bin/benchmark.dll" ) - -# Import target "benchmark::benchmark_main" for configuration "Release" -set_property(TARGET benchmark::benchmark_main APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) -set_target_properties(benchmark::benchmark_main PROPERTIES - IMPORTED_IMPLIB_RELEASE "${_IMPORT_PREFIX}/lib/benchmark_main.lib" - IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/benchmark_main.dll" - ) - -list(APPEND _IMPORT_CHECK_TARGETS benchmark::benchmark_main ) -list(APPEND _IMPORT_CHECK_FILES_FOR_benchmark::benchmark_main "${_IMPORT_PREFIX}/lib/benchmark_main.lib" "${_IMPORT_PREFIX}/bin/benchmark_main.dll" ) - -# Commands beyond this point should not need to know the version. -set(CMAKE_IMPORT_FILE_VERSION) diff --git a/opencc/lib/cmake/benchmark/benchmarkTargets.cmake b/opencc/lib/cmake/benchmark/benchmarkTargets.cmake deleted file mode 100644 index f74179a6..00000000 --- a/opencc/lib/cmake/benchmark/benchmarkTargets.cmake +++ /dev/null @@ -1,107 +0,0 @@ -# Generated by CMake - -if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6) - message(FATAL_ERROR "CMake >= 2.6.0 required") -endif() -cmake_policy(PUSH) -cmake_policy(VERSION 2.6...3.21) -#---------------------------------------------------------------- -# Generated CMake target import file. -#---------------------------------------------------------------- - -# Commands may need to know the format version. -set(CMAKE_IMPORT_FILE_VERSION 1) - -# Protect against multiple inclusion, which would fail when already imported targets are added once more. -set(_targetsDefined) -set(_targetsNotDefined) -set(_expectedTargets) -foreach(_expectedTarget benchmark::benchmark benchmark::benchmark_main) - list(APPEND _expectedTargets ${_expectedTarget}) - if(NOT TARGET ${_expectedTarget}) - list(APPEND _targetsNotDefined ${_expectedTarget}) - endif() - if(TARGET ${_expectedTarget}) - list(APPEND _targetsDefined ${_expectedTarget}) - endif() -endforeach() -if("${_targetsDefined}" STREQUAL "${_expectedTargets}") - unset(_targetsDefined) - unset(_targetsNotDefined) - unset(_expectedTargets) - set(CMAKE_IMPORT_FILE_VERSION) - cmake_policy(POP) - return() -endif() -if(NOT "${_targetsDefined}" STREQUAL "") - message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") -endif() -unset(_targetsDefined) -unset(_targetsNotDefined) -unset(_expectedTargets) - - -# Compute the installation prefix relative to this file. -get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) -get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) -get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) -get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) -if(_IMPORT_PREFIX STREQUAL "/") - set(_IMPORT_PREFIX "") -endif() - -# Create imported target benchmark::benchmark -add_library(benchmark::benchmark SHARED IMPORTED) - -set_target_properties(benchmark::benchmark PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" - INTERFACE_LINK_LIBRARIES "shlwapi" -) - -# Create imported target benchmark::benchmark_main -add_library(benchmark::benchmark_main SHARED IMPORTED) - -set_target_properties(benchmark::benchmark_main PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" - INTERFACE_LINK_LIBRARIES "benchmark::benchmark" -) - -if(CMAKE_VERSION VERSION_LESS 2.8.12) - message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.") -endif() - -# Load information for each installed configuration. -get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -file(GLOB CONFIG_FILES "${_DIR}/benchmarkTargets-*.cmake") -foreach(f ${CONFIG_FILES}) - include(${f}) -endforeach() - -# Cleanup temporary variables. -set(_IMPORT_PREFIX) - -# Loop over all imported files and verify that they actually exist -foreach(target ${_IMPORT_CHECK_TARGETS} ) - foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) - if(NOT EXISTS "${file}" ) - message(FATAL_ERROR "The imported target \"${target}\" references the file - \"${file}\" -but this file does not exist. Possible reasons include: -* The file was deleted, renamed, or moved to another location. -* An install or uninstall procedure did not complete successfully. -* The installation package was faulty and contained - \"${CMAKE_CURRENT_LIST_FILE}\" -but not all the files it references. -") - endif() - endforeach() - unset(_IMPORT_CHECK_FILES_FOR_${target}) -endforeach() -unset(_IMPORT_CHECK_TARGETS) - -# This file does not depend on other imported targets which have -# been exported from the same project but in a separate export set. - -# Commands beyond this point should not need to know the version. -set(CMAKE_IMPORT_FILE_VERSION) -cmake_policy(POP) diff --git a/opencc/lib/opencc.lib b/opencc/lib/opencc.lib deleted file mode 100644 index b8b62996..00000000 Binary files a/opencc/lib/opencc.lib and /dev/null differ diff --git a/opencc/lib/pkgconfig/benchmark.pc b/opencc/lib/pkgconfig/benchmark.pc deleted file mode 100644 index 6dd72e7b..00000000 --- a/opencc/lib/pkgconfig/benchmark.pc +++ /dev/null @@ -1,12 +0,0 @@ -prefix=. -exec_prefix=${prefix} -libdir=${prefix}/lib -includedir=${prefix}/include - -Name: benchmark -Description: Google microbenchmark framework -Version: 0.0.0 - -Libs: -L${libdir} -lbenchmark -Libs.private: -lpthread -Cflags: -I${includedir} diff --git a/opencc/lib/pkgconfig/opencc.pc b/opencc/lib/pkgconfig/opencc.pc deleted file mode 100644 index a6318736..00000000 --- a/opencc/lib/pkgconfig/opencc.pc +++ /dev/null @@ -1,11 +0,0 @@ -prefix=. -exec_prefix=${prefix} -libdir=./lib/ -includedir=./include/ - -Name: opencc -Description: Open Chinese Convert -Version: 1.1.3 -Requires: -Libs: -L${libdir} -lopencc -Cflags: -I${includedir}/opencc diff --git a/opencc/share/opencc/HKVariants.ocd2 b/opencc/share/opencc/HKVariants.ocd2 deleted file mode 100644 index 465b017a..00000000 Binary files a/opencc/share/opencc/HKVariants.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/HKVariantsRev.ocd2 b/opencc/share/opencc/HKVariantsRev.ocd2 deleted file mode 100644 index abc97a94..00000000 Binary files a/opencc/share/opencc/HKVariantsRev.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/HKVariantsRevPhrases.ocd2 b/opencc/share/opencc/HKVariantsRevPhrases.ocd2 deleted file mode 100644 index e1a474f8..00000000 Binary files a/opencc/share/opencc/HKVariantsRevPhrases.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/JPShinjitaiCharacters.ocd2 b/opencc/share/opencc/JPShinjitaiCharacters.ocd2 deleted file mode 100644 index 48a4c01f..00000000 Binary files a/opencc/share/opencc/JPShinjitaiCharacters.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/JPShinjitaiPhrases.ocd2 b/opencc/share/opencc/JPShinjitaiPhrases.ocd2 deleted file mode 100644 index b351c5f1..00000000 Binary files a/opencc/share/opencc/JPShinjitaiPhrases.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/JPVariants.ocd2 b/opencc/share/opencc/JPVariants.ocd2 deleted file mode 100644 index 41987af6..00000000 Binary files a/opencc/share/opencc/JPVariants.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/JPVariantsRev.ocd2 b/opencc/share/opencc/JPVariantsRev.ocd2 deleted file mode 100644 index b37005a9..00000000 Binary files a/opencc/share/opencc/JPVariantsRev.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/STCharacters.ocd2 b/opencc/share/opencc/STCharacters.ocd2 deleted file mode 100644 index d9333d54..00000000 Binary files a/opencc/share/opencc/STCharacters.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/STPhrases.ocd2 b/opencc/share/opencc/STPhrases.ocd2 deleted file mode 100644 index 0bdb0e4e..00000000 Binary files a/opencc/share/opencc/STPhrases.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/TSCharacters.ocd2 b/opencc/share/opencc/TSCharacters.ocd2 deleted file mode 100644 index 0b1e1885..00000000 Binary files a/opencc/share/opencc/TSCharacters.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/TSPhrases.ocd2 b/opencc/share/opencc/TSPhrases.ocd2 deleted file mode 100644 index 75b0da74..00000000 Binary files a/opencc/share/opencc/TSPhrases.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/TWPhrases.ocd2 b/opencc/share/opencc/TWPhrases.ocd2 deleted file mode 100644 index a6f78040..00000000 Binary files a/opencc/share/opencc/TWPhrases.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/TWPhrasesRev.ocd2 b/opencc/share/opencc/TWPhrasesRev.ocd2 deleted file mode 100644 index 1fabb047..00000000 Binary files a/opencc/share/opencc/TWPhrasesRev.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/TWVariants.ocd2 b/opencc/share/opencc/TWVariants.ocd2 deleted file mode 100644 index 8d743955..00000000 Binary files a/opencc/share/opencc/TWVariants.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/TWVariantsRev.ocd2 b/opencc/share/opencc/TWVariantsRev.ocd2 deleted file mode 100644 index a26548db..00000000 Binary files a/opencc/share/opencc/TWVariantsRev.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/TWVariantsRevPhrases.ocd2 b/opencc/share/opencc/TWVariantsRevPhrases.ocd2 deleted file mode 100644 index d47717a0..00000000 Binary files a/opencc/share/opencc/TWVariantsRevPhrases.ocd2 and /dev/null differ diff --git a/opencc/share/opencc/hk2s.json b/opencc/share/opencc/hk2s.json deleted file mode 100644 index cf0e9b97..00000000 --- a/opencc/share/opencc/hk2s.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "Traditional Chinese (Hong Kong variant) to Simplified Chinese", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "TSPhrases.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "HKVariantsRevPhrases.ocd2" - }, { - "type": "ocd2", - "file": "HKVariantsRev.ocd2" - }] - } - }, { - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "TSPhrases.ocd2" - }, { - "type": "ocd2", - "file": "TSCharacters.ocd2" - }] - } - }] -} diff --git a/opencc/share/opencc/hk2t.json b/opencc/share/opencc/hk2t.json deleted file mode 100644 index 0d47b917..00000000 --- a/opencc/share/opencc/hk2t.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "Traditional Chinese (Hong Kong variant) to Traditional Chinese", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "HKVariantsRevPhrases.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "HKVariantsRevPhrases.ocd2" - }, { - "type": "ocd2", - "file": "HKVariantsRev.ocd2" - }] - } - }] -} diff --git a/opencc/share/opencc/jp2t.json b/opencc/share/opencc/jp2t.json deleted file mode 100644 index 025d8919..00000000 --- a/opencc/share/opencc/jp2t.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai)", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "JPShinjitaiPhrases.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "JPShinjitaiPhrases.ocd2" - }, { - "type": "ocd2", - "file": "JPShinjitaiCharacters.ocd2" - }, { - "type": "ocd2", - "file": "JPVariantsRev.ocd2" - }] - } - }] -} diff --git a/opencc/share/opencc/s2hk.json b/opencc/share/opencc/s2hk.json deleted file mode 100644 index fcaa017e..00000000 --- a/opencc/share/opencc/s2hk.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "Simplified Chinese to Traditional Chinese (Hong Kong variant)", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "STPhrases.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "STPhrases.ocd2" - }, { - "type": "ocd2", - "file": "STCharacters.ocd2" - }] - } - }, { - "dict": { - "type": "ocd2", - "file": "HKVariants.ocd2" - } - }] -} diff --git a/opencc/share/opencc/s2t.json b/opencc/share/opencc/s2t.json deleted file mode 100644 index 87516acb..00000000 --- a/opencc/share/opencc/s2t.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "Simplified Chinese to Traditional Chinese", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "STPhrases.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "STPhrases.ocd2" - }, { - "type": "ocd2", - "file": "STCharacters.ocd2" - }] - } - }] -} diff --git a/opencc/share/opencc/s2tw.json b/opencc/share/opencc/s2tw.json deleted file mode 100644 index 2a3d7656..00000000 --- a/opencc/share/opencc/s2tw.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "Simplified Chinese to Traditional Chinese (Taiwan standard)", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "STPhrases.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "STPhrases.ocd2" - }, { - "type": "ocd2", - "file": "STCharacters.ocd2" - }] - } - }, { - "dict": { - "type": "ocd2", - "file": "TWVariants.ocd2" - } - }] -} diff --git a/opencc/share/opencc/s2twp.json b/opencc/share/opencc/s2twp.json deleted file mode 100644 index 2f36e935..00000000 --- a/opencc/share/opencc/s2twp.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "Simplified Chinese to Traditional Chinese (Taiwan standard, with phrases)", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "STPhrases.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "STPhrases.ocd2" - }, { - "type": "ocd2", - "file": "STCharacters.ocd2" - }] - } - }, { - "dict": { - "type": "ocd2", - "file": "TWPhrases.ocd2" - } - }, { - "dict": { - "type": "ocd2", - "file": "TWVariants.ocd2" - } - }] -} diff --git a/opencc/share/opencc/t2hk.json b/opencc/share/opencc/t2hk.json deleted file mode 100644 index 519d4a3f..00000000 --- a/opencc/share/opencc/t2hk.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "Traditional Chinese to Traditional Chinese (Hong Kong variant)", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "HKVariants.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "ocd2", - "file": "HKVariants.ocd2" - } - }] -} diff --git a/opencc/share/opencc/t2jp.json b/opencc/share/opencc/t2jp.json deleted file mode 100644 index 7a43217f..00000000 --- a/opencc/share/opencc/t2jp.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai)", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "JPVariants.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "ocd2", - "file": "JPVariants.ocd2" - } - }] -} diff --git a/opencc/share/opencc/t2s.json b/opencc/share/opencc/t2s.json deleted file mode 100644 index 06cf5f58..00000000 --- a/opencc/share/opencc/t2s.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "Traditional Chinese to Simplified Chinese", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "TSPhrases.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "TSPhrases.ocd2" - }, { - "type": "ocd2", - "file": "TSCharacters.ocd2" - }] - } - }] -} diff --git a/opencc/share/opencc/t2tw.json b/opencc/share/opencc/t2tw.json deleted file mode 100644 index 0394f600..00000000 --- a/opencc/share/opencc/t2tw.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "Traditional Chinese to Traditional Chinese (Taiwan standard)", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "TWVariants.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "ocd2", - "file": "TWVariants.ocd2" - } - }] -} diff --git a/opencc/share/opencc/tw2s.json b/opencc/share/opencc/tw2s.json deleted file mode 100644 index 4f554393..00000000 --- a/opencc/share/opencc/tw2s.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "Traditional Chinese (Taiwan standard) to Simplified Chinese", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "TSPhrases.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "TWVariantsRevPhrases.ocd2" - }, { - "type": "ocd2", - "file": "TWVariantsRev.ocd2" - }] - } - }, { - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "TSPhrases.ocd2" - }, { - "type": "ocd2", - "file": "TSCharacters.ocd2" - }] - } - }] -} diff --git a/opencc/share/opencc/tw2sp.json b/opencc/share/opencc/tw2sp.json deleted file mode 100644 index 64eb9d97..00000000 --- a/opencc/share/opencc/tw2sp.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "Traditional Chinese (Taiwan standard) to Simplified Chinese (with phrases)", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "TSPhrases.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "TWPhrasesRev.ocd2" - }, { - "type": "ocd2", - "file": "TWVariantsRevPhrases.ocd2" - }, { - "type": "ocd2", - "file": "TWVariantsRev.ocd2" - }] - } - }, { - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "TSPhrases.ocd2" - }, { - "type": "ocd2", - "file": "TSCharacters.ocd2" - }] - } - }] -} diff --git a/opencc/share/opencc/tw2t.json b/opencc/share/opencc/tw2t.json deleted file mode 100644 index ad5295b6..00000000 --- a/opencc/share/opencc/tw2t.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "Traditional Chinese (Taiwan standard) to Traditional Chinese", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd2", - "file": "TWVariantsRevPhrases.ocd2" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd2", - "file": "TWVariantsRevPhrases.ocd2" - }, { - "type": "ocd2", - "file": "TWVariantsRev.ocd2" - }] - } - }] -} diff --git a/stdutil/stdutil.h b/stdutil/stdutil.h index 410d229a..153692f2 100644 --- a/stdutil/stdutil.h +++ b/stdutil/stdutil.h @@ -8,6 +8,8 @@ #include #include +using namespace std; + #ifdef MEMDEBUG void* _cdecl operator new(size_t size);