From 3dbfd11b3e258b762261d520a02e27010eb5ea9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=90=E6=82=A6=E8=A7=A3=E8=AF=B4?= Date: Sun, 14 Aug 2022 22:12:39 +0800 Subject: [PATCH] Update to C++20 --- MultiLang/English.cpp | 432 ++--- MultiLang/MultiLang.vcxproj | 1 - MultiLang/MultiLang.vcxproj.filters | 3 - MultiLang/SimplifiedChinese.cpp | 432 ++--- MultiLang/sformat.h | 95 - .../commands/2d_commands/GetUserLanguage.htm | 4 +- bblaunch/bblaunch.vcxproj | 2 +- bbruntime/basic.cpp | 7 +- bbruntime/bbblitz3d.cpp | 14 +- bbruntime/bbruntime.cpp | 10 +- bbruntime/bbruntime.vcxproj | 2 +- bbruntime/bbsockets.cpp | 3 +- bbruntime/bbstring.cpp | 6 +- bbruntime_dll/bbruntime_dll.cpp | 3 +- bbruntime_dll/bbruntime_dll.vcxproj | 2 +- blitz/blitz.vcxproj | 2 +- blitz3d/blitz3d.vcxproj | 2 +- blitzide/blitzide.vcxproj | 2 +- blitzide/libs.cpp | 4 +- blitzide/mainframe.cpp | 10 +- compiler/compiler.vcxproj | 2 +- compiler/exprnode.cpp | 9 +- compiler/node.cpp | 4 +- compiler/parser.cpp | 4 +- compiler/prognode.cpp | 4 +- compiler/varnode.cpp | 4 +- config/config.vcxproj | 2 +- debugger/debugger.vcxproj | 2 +- freeimage/FreeImageLib/FreeImageLib.vcxproj | 2 +- freeimage/LibJPEG/LibJPEG.vcxproj | 2 +- freeimage/LibPNG/LibPNG.vcxproj | 2 +- freeimage/ZLib/ZLib.vcxproj | 2 +- .../builds/windows/vc2010/freetype.vcxproj | 2 +- gxruntime/gxutf8.h | 2 +- inipp/inipp.vcxproj | 1 + linker/linker.vcxproj | 2 +- linker_dll/linker_dll.vcxproj | 2 +- opencc/include/benchmark/benchmark.h | 1589 ----------------- opencc/include/opencc/BinaryDict.hpp | 53 - opencc/include/opencc/Common.hpp | 82 - opencc/include/opencc/Config.hpp | 42 - opencc/include/opencc/Conversion.hpp | 47 - opencc/include/opencc/ConversionChain.hpp | 43 - opencc/include/opencc/Converter.hpp | 51 - opencc/include/opencc/DartsDict.hpp | 60 - opencc/include/opencc/Dict.hpp | 92 - opencc/include/opencc/DictConverter.hpp | 32 - opencc/include/opencc/DictEntry.hpp | 173 -- opencc/include/opencc/DictGroup.hpp | 57 - opencc/include/opencc/Exception.hpp | 88 - opencc/include/opencc/Export.hpp | 40 - opencc/include/opencc/Lexicon.hpp | 68 - opencc/include/opencc/MarisaDict.hpp | 63 - .../include/opencc/MaxMatchSegmentation.hpp | 43 - opencc/include/opencc/Optional.hpp | 76 - opencc/include/opencc/PhraseExtract.hpp | 195 -- opencc/include/opencc/Segmentation.hpp | 32 - opencc/include/opencc/Segments.hpp | 114 -- opencc/include/opencc/SerializableDict.hpp | 77 - opencc/include/opencc/SerializedValues.hpp | 50 - opencc/include/opencc/SimpleConverter.hpp | 93 - opencc/include/opencc/TextDict.hpp | 60 - opencc/include/opencc/UTF8StringSlice.hpp | 246 --- opencc/include/opencc/UTF8Util.hpp | 290 --- opencc/include/opencc/opencc.h | 161 -- opencc/include/opencc/opencc_config.h | 21 - opencc/lib/benchmark.lib | Bin 365008 -> 0 bytes opencc/lib/benchmark_main.lib | Bin 1844 -> 0 bytes .../lib/cmake/benchmark/benchmarkConfig.cmake | 1 - .../benchmark/benchmarkConfigVersion.cmake | 70 - .../benchmark/benchmarkTargets-release.cmake | 29 - .../cmake/benchmark/benchmarkTargets.cmake | 107 -- opencc/lib/opencc.lib | Bin 151100 -> 0 bytes opencc/lib/pkgconfig/benchmark.pc | 12 - opencc/lib/pkgconfig/opencc.pc | 11 - opencc/share/opencc/HKVariants.ocd2 | Bin 4893 -> 0 bytes opencc/share/opencc/HKVariantsRev.ocd2 | Bin 4923 -> 0 bytes opencc/share/opencc/HKVariantsRevPhrases.ocd2 | Bin 7030 -> 0 bytes .../share/opencc/JPShinjitaiCharacters.ocd2 | Bin 4263 -> 0 bytes opencc/share/opencc/JPShinjitaiPhrases.ocd2 | Bin 7462 -> 0 bytes opencc/share/opencc/JPVariants.ocd2 | Bin 7993 -> 0 bytes opencc/share/opencc/JPVariantsRev.ocd2 | Bin 7983 -> 0 bytes opencc/share/opencc/STCharacters.ocd2 | Bin 45296 -> 0 bytes opencc/share/opencc/STPhrases.ocd2 | Bin 924965 -> 0 bytes opencc/share/opencc/TSCharacters.ocd2 | Bin 45078 -> 0 bytes opencc/share/opencc/TSPhrases.ocd2 | Bin 9742 -> 0 bytes opencc/share/opencc/TWPhrases.ocd2 | Bin 15591 -> 0 bytes opencc/share/opencc/TWPhrasesRev.ocd2 | Bin 15594 -> 0 bytes opencc/share/opencc/TWVariants.ocd2 | Bin 4595 -> 0 bytes opencc/share/opencc/TWVariantsRev.ocd2 | Bin 4627 -> 0 bytes opencc/share/opencc/TWVariantsRevPhrases.ocd2 | Bin 5333 -> 0 bytes opencc/share/opencc/hk2s.json | 33 - opencc/share/opencc/hk2t.json | 22 - opencc/share/opencc/jp2t.json | 25 - opencc/share/opencc/s2hk.json | 27 - opencc/share/opencc/s2t.json | 22 - opencc/share/opencc/s2tw.json | 27 - opencc/share/opencc/s2twp.json | 32 - opencc/share/opencc/t2hk.json | 16 - opencc/share/opencc/t2jp.json | 16 - opencc/share/opencc/t2s.json | 22 - opencc/share/opencc/t2tw.json | 16 - opencc/share/opencc/tw2s.json | 33 - opencc/share/opencc/tw2sp.json | 36 - opencc/share/opencc/tw2t.json | 22 - stdutil/stdutil.h | 2 + 106 files changed, 496 insertions(+), 5207 deletions(-) delete mode 100644 MultiLang/sformat.h delete mode 100644 opencc/include/benchmark/benchmark.h delete mode 100644 opencc/include/opencc/BinaryDict.hpp delete mode 100644 opencc/include/opencc/Common.hpp delete mode 100644 opencc/include/opencc/Config.hpp delete mode 100644 opencc/include/opencc/Conversion.hpp delete mode 100644 opencc/include/opencc/ConversionChain.hpp delete mode 100644 opencc/include/opencc/Converter.hpp delete mode 100644 opencc/include/opencc/DartsDict.hpp delete mode 100644 opencc/include/opencc/Dict.hpp delete mode 100644 opencc/include/opencc/DictConverter.hpp delete mode 100644 opencc/include/opencc/DictEntry.hpp delete mode 100644 opencc/include/opencc/DictGroup.hpp delete mode 100644 opencc/include/opencc/Exception.hpp delete mode 100644 opencc/include/opencc/Export.hpp delete mode 100644 opencc/include/opencc/Lexicon.hpp delete mode 100644 opencc/include/opencc/MarisaDict.hpp delete mode 100644 opencc/include/opencc/MaxMatchSegmentation.hpp delete mode 100644 opencc/include/opencc/Optional.hpp delete mode 100644 opencc/include/opencc/PhraseExtract.hpp delete mode 100644 opencc/include/opencc/Segmentation.hpp delete mode 100644 opencc/include/opencc/Segments.hpp delete mode 100644 opencc/include/opencc/SerializableDict.hpp delete mode 100644 opencc/include/opencc/SerializedValues.hpp delete mode 100644 opencc/include/opencc/SimpleConverter.hpp delete mode 100644 opencc/include/opencc/TextDict.hpp delete mode 100644 opencc/include/opencc/UTF8StringSlice.hpp delete mode 100644 opencc/include/opencc/UTF8Util.hpp delete mode 100644 opencc/include/opencc/opencc.h delete mode 100644 opencc/include/opencc/opencc_config.h delete mode 100644 opencc/lib/benchmark.lib delete mode 100644 opencc/lib/benchmark_main.lib delete mode 100644 opencc/lib/cmake/benchmark/benchmarkConfig.cmake delete mode 100644 opencc/lib/cmake/benchmark/benchmarkConfigVersion.cmake delete mode 100644 opencc/lib/cmake/benchmark/benchmarkTargets-release.cmake delete mode 100644 opencc/lib/cmake/benchmark/benchmarkTargets.cmake delete mode 100644 opencc/lib/opencc.lib delete mode 100644 opencc/lib/pkgconfig/benchmark.pc delete mode 100644 opencc/lib/pkgconfig/opencc.pc delete mode 100644 opencc/share/opencc/HKVariants.ocd2 delete mode 100644 opencc/share/opencc/HKVariantsRev.ocd2 delete mode 100644 opencc/share/opencc/HKVariantsRevPhrases.ocd2 delete mode 100644 opencc/share/opencc/JPShinjitaiCharacters.ocd2 delete mode 100644 opencc/share/opencc/JPShinjitaiPhrases.ocd2 delete mode 100644 opencc/share/opencc/JPVariants.ocd2 delete mode 100644 opencc/share/opencc/JPVariantsRev.ocd2 delete mode 100644 opencc/share/opencc/STCharacters.ocd2 delete mode 100644 opencc/share/opencc/STPhrases.ocd2 delete mode 100644 opencc/share/opencc/TSCharacters.ocd2 delete mode 100644 opencc/share/opencc/TSPhrases.ocd2 delete mode 100644 opencc/share/opencc/TWPhrases.ocd2 delete mode 100644 opencc/share/opencc/TWPhrasesRev.ocd2 delete mode 100644 opencc/share/opencc/TWVariants.ocd2 delete mode 100644 opencc/share/opencc/TWVariantsRev.ocd2 delete mode 100644 opencc/share/opencc/TWVariantsRevPhrases.ocd2 delete mode 100644 opencc/share/opencc/hk2s.json delete mode 100644 opencc/share/opencc/hk2t.json delete mode 100644 opencc/share/opencc/jp2t.json delete mode 100644 opencc/share/opencc/s2hk.json delete mode 100644 opencc/share/opencc/s2t.json delete mode 100644 opencc/share/opencc/s2tw.json delete mode 100644 opencc/share/opencc/s2twp.json delete mode 100644 opencc/share/opencc/t2hk.json delete mode 100644 opencc/share/opencc/t2jp.json delete mode 100644 opencc/share/opencc/t2s.json delete mode 100644 opencc/share/opencc/t2tw.json delete mode 100644 opencc/share/opencc/tw2s.json delete mode 100644 opencc/share/opencc/tw2sp.json delete mode 100644 opencc/share/opencc/tw2t.json 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 366518f49088c86c241ffcddb771e4d385fc30c3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 365008 zcmeEP3xK3WaqfS1#t=dXL4x=~#1oMy?mak8MP_Dq@7TS&-P_x}-Fv9~%+CJ1JKXHd zI5T@MQ4tjp5s?sM2r#R7-YM$;J$JSGv-MNI`H$6W*7mPoOFvw2G-KI! zu)YtsS>H!)V0|CGoArHc9pEmOeZwh$x3lc!CjxF_**BgJ_z=rpF%Gz&W#9Blmc0^x zyApqU^AO-cmc8m)mVL_!fa_TH>Qe#lWZ6GD4R9mNUW1>n0lq&z32-&bzV%qZ6)gKF zM*%JYJi@YXYXTl%**~2HfX1~K0KUSqf3^egNtXTlm$2;3z<)F7{KM&hdsz0}Z)4ei z1kQhaE6cuTE6e^9@cq+eEc@OQSnfslvD~>Av0VOiz-=sdUV-Ia&RFghH?Z6*#{rM9 z+^eo)eYd?*H`OzJMRCGT~-?0T0cY@MC-dKL&n+pBxhK(@R+&!Ot!i@W?f+kKpGI3;5-6 ztdHPV4+!}6+gKkU%P^h^w5ov2^(;%!hc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