├── .gitignore ├── .vscode ├── c_cpp_properties.json ├── launch.json └── tasks.json ├── LICENSE ├── Makefile ├── README.md ├── config ├── arrow.toml ├── curve.toml ├── lean.toml ├── pure.toml ├── test.toml └── warp.toml ├── external ├── argparse │ ├── Readme.md │ └── argparse.hpp ├── boost │ ├── README.md │ ├── regex.h │ ├── regex.hpp │ ├── regex │ │ ├── concepts.hpp │ │ ├── config.hpp │ │ ├── config │ │ │ ├── borland.hpp │ │ │ └── cwchar.hpp │ │ ├── icu.hpp │ │ ├── mfc.hpp │ │ ├── pattern_except.hpp │ │ ├── pending │ │ │ ├── object_cache.hpp │ │ │ ├── static_mutex.hpp │ │ │ └── unicode_iterator.hpp │ │ ├── regex_traits.hpp │ │ ├── user.hpp │ │ ├── v4 │ │ │ ├── basic_regex.hpp │ │ │ ├── basic_regex_creator.hpp │ │ │ ├── basic_regex_parser.hpp │ │ │ ├── c_regex_traits.hpp │ │ │ ├── char_regex_traits.hpp │ │ │ ├── cpp_regex_traits.hpp │ │ │ ├── cregex.hpp │ │ │ ├── error_type.hpp │ │ │ ├── icu.hpp │ │ │ ├── indexed_bit_flag.hpp │ │ │ ├── iterator_category.hpp │ │ │ ├── iterator_traits.hpp │ │ │ ├── match_flags.hpp │ │ │ ├── match_results.hpp │ │ │ ├── mem_block_cache.hpp │ │ │ ├── object_cache.hpp │ │ │ ├── pattern_except.hpp │ │ │ ├── perl_matcher.hpp │ │ │ ├── perl_matcher_common.hpp │ │ │ ├── perl_matcher_non_recursive.hpp │ │ │ ├── perl_matcher_recursive.hpp │ │ │ ├── primary_transform.hpp │ │ │ ├── protected_call.hpp │ │ │ ├── regbase.hpp │ │ │ ├── regex.hpp │ │ │ ├── regex_format.hpp │ │ │ ├── regex_fwd.hpp │ │ │ ├── regex_grep.hpp │ │ │ ├── regex_iterator.hpp │ │ │ ├── regex_match.hpp │ │ │ ├── regex_merge.hpp │ │ │ ├── regex_raw_buffer.hpp │ │ │ ├── regex_replace.hpp │ │ │ ├── regex_search.hpp │ │ │ ├── regex_split.hpp │ │ │ ├── regex_token_iterator.hpp │ │ │ ├── regex_traits.hpp │ │ │ ├── regex_traits_defaults.hpp │ │ │ ├── regex_workaround.hpp │ │ │ ├── states.hpp │ │ │ ├── sub_match.hpp │ │ │ ├── syntax_type.hpp │ │ │ ├── u32regex_iterator.hpp │ │ │ ├── u32regex_token_iterator.hpp │ │ │ ├── unicode_iterator.hpp │ │ │ └── w32_regex_traits.hpp │ │ └── v5 │ │ │ ├── basic_regex.hpp │ │ │ ├── basic_regex_creator.hpp │ │ │ ├── basic_regex_parser.hpp │ │ │ ├── c_regex_traits.hpp │ │ │ ├── char_regex_traits.hpp │ │ │ ├── cpp_regex_traits.hpp │ │ │ ├── cregex.hpp │ │ │ ├── error_type.hpp │ │ │ ├── icu.hpp │ │ │ ├── iterator_category.hpp │ │ │ ├── iterator_traits.hpp │ │ │ ├── match_flags.hpp │ │ │ ├── match_results.hpp │ │ │ ├── mem_block_cache.hpp │ │ │ ├── object_cache.hpp │ │ │ ├── pattern_except.hpp │ │ │ ├── perl_matcher.hpp │ │ │ ├── perl_matcher_common.hpp │ │ │ ├── perl_matcher_non_recursive.hpp │ │ │ ├── primary_transform.hpp │ │ │ ├── regbase.hpp │ │ │ ├── regex.hpp │ │ │ ├── regex_format.hpp │ │ │ ├── regex_fwd.hpp │ │ │ ├── regex_grep.hpp │ │ │ ├── regex_iterator.hpp │ │ │ ├── regex_match.hpp │ │ │ ├── regex_merge.hpp │ │ │ ├── regex_raw_buffer.hpp │ │ │ ├── regex_replace.hpp │ │ │ ├── regex_search.hpp │ │ │ ├── regex_split.hpp │ │ │ ├── regex_token_iterator.hpp │ │ │ ├── regex_traits.hpp │ │ │ ├── regex_traits_defaults.hpp │ │ │ ├── regex_workaround.hpp │ │ │ ├── states.hpp │ │ │ ├── sub_match.hpp │ │ │ ├── syntax_type.hpp │ │ │ ├── u32regex_iterator.hpp │ │ │ ├── u32regex_token_iterator.hpp │ │ │ ├── unicode_iterator.hpp │ │ │ └── w32_regex_traits.hpp │ └── regex_fwd.hpp ├── doctest │ ├── README.md │ ├── doc │ │ └── markdown │ │ │ ├── assertions.md │ │ │ ├── benchmarks.md │ │ │ ├── build-systems.md │ │ │ ├── commandline.md │ │ │ ├── configuration.md │ │ │ ├── extensions.md │ │ │ ├── faq.md │ │ │ ├── features.md │ │ │ ├── logging.md │ │ │ ├── main.md │ │ │ ├── parameterized-tests.md │ │ │ ├── readme.md │ │ │ ├── reporters.md │ │ │ ├── stringification.md │ │ │ ├── testcases.md │ │ │ └── tutorial.md │ └── doctest.h ├── thread-pool │ ├── BS_thread_pool.hpp │ └── README.md └── toml │ ├── README.md │ └── toml.hpp ├── media └── demo.png ├── src ├── arg.hpp ├── color.cpp ├── color.hpp ├── config.cpp ├── config.hpp ├── context.cpp ├── context.hpp ├── init.cpp ├── init.hpp ├── init │ ├── init.bash │ ├── init.fish │ ├── init.zsh │ └── util.bash ├── main.cpp ├── module.cpp ├── module.hpp ├── modules │ ├── date.hpp │ ├── directory.hpp │ ├── duration.hpp │ ├── git_branch.hpp │ ├── git_commit.hpp │ ├── git_status.hpp │ ├── host.hpp │ ├── shell.hpp │ ├── status.hpp │ ├── time.hpp │ └── user.hpp ├── pool.hpp ├── print.cpp ├── print.hpp ├── test.cpp ├── test.hpp ├── types.hpp ├── util.cpp └── util.hpp └── use_config /.gitignore: -------------------------------------------------------------------------------- 1 | # Build files 2 | /build 3 | 4 | # VS Code files 5 | /.vscode/settings.json 6 | 7 | # Clang tools 8 | /.cache 9 | /compile_commands.json 10 | 11 | # Other 12 | /TODO.md 13 | /benchmark.py 14 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "cppStandard": "c++17", 6 | "intelliSenseMode": "linux-gcc-x64", 7 | "compilerPath": "/usr/bin/g++", 8 | "includePath": [ 9 | "${workspaceFolder}/**" 10 | ], 11 | "defines": [ 12 | "TEST" 13 | ] 14 | } 15 | ], 16 | "version": 4 17 | } 18 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Debug", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${workspaceFolder}/build/debug/bin/blaze", 9 | // "args": ["bash", "--init"], 10 | "args": ["bash", "--prompt", "-s", "1669573672.173649637", "-f", "1669573895.264739827", "-e", "1", "-b", "0;0;0", "-p", "ls"], 11 | "cwd": "${workspaceFolder}", 12 | "MIMode": "gdb", 13 | "miDebuggerPath": "/usr/bin/gdb", 14 | "setupCommands": [ 15 | { 16 | "description": "Enable pretty-printing for gdb", 17 | "text": "-enable-pretty-printing", 18 | "ignoreFailures": true 19 | } 20 | ], 21 | "preLaunchTask": "make build project", 22 | "presentation": { 23 | "group": "project", 24 | "order": 1 25 | } 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "make build project", 6 | "type": "shell", 7 | "command": "make", 8 | "args": [], 9 | "group": { 10 | "kind": "build", 11 | "isDefault": true 12 | } 13 | }, 14 | { 15 | "label": "compiledb create compile_commands.json", 16 | "type": "shell", 17 | "options": { 18 | "shell": { 19 | "args": ["-i"] 20 | } 21 | }, 22 | "command": "compiledb", 23 | "args": ["--no-build", "make"], 24 | "group": { 25 | "kind": "build", 26 | "isDefault": false 27 | } 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Daniel Todor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | KERNEL = $(shell uname -s) 2 | 3 | # --- User flags --- 4 | # Echo commands 5 | verbose = 6 | # Create release build 7 | release = 8 | # Create analysis during/after compilation 9 | analyze = 10 | 11 | # --- Conditions --- 12 | # Make shell commands visible 13 | ifdef verbose 14 | CMD_PREFIX = 15 | else 16 | CMD_PREFIX = @ 17 | endif 18 | 19 | # Detect macOS 20 | ifeq "$(KERNEL)" "Darwin" 21 | MACOS = y 22 | endif 23 | 24 | # --- Project structure --- 25 | # Name of the generated binary 26 | BIN_NAME = blaze 27 | # Directories to search for header files 28 | INCLUDE_DIRS = src external 29 | # Suppress warnings for these directories 30 | SYSTEM_DIRS = external 31 | # Libraries to link 32 | LIBRARIES = 33 | # Directory for the main source code 34 | SRC_DIR = src 35 | BUILD_DIR = build 36 | ifdef release 37 | BUILD_TYPE = release 38 | else 39 | BUILD_TYPE = debug 40 | endif 41 | TYPE_DIR = $(BUILD_DIR)/$(BUILD_TYPE) 42 | BIN_DIR = $(TYPE_DIR)/bin 43 | OBJ_DIR = $(TYPE_DIR)/obj 44 | BINARY = $(BIN_DIR)/$(BIN_NAME) 45 | SRCS = $(shell find $(SRC_DIR) -name "*.cpp" -or -name "*.c" -or -name "*.s" | sort -k 1nr | cut -f2-) 46 | OBJS = $(patsubst $(SRC_DIR)/%, $(OBJ_DIR)/%.o, $(SRCS)) 47 | DEPS = $(patsubst %.o, %.d, $(OBJS)) 48 | INSTALL_DIR = ~/.local 49 | 50 | # --- Compiler attributes --- 51 | # Compiler 52 | COMPILER_FLAGS = g++ 53 | # Language standard 54 | COMPILER_FLAGS += -std=c++17 55 | # Optimisations 56 | ifdef release 57 | COMPILER_FLAGS += -Os -flto=auto 58 | else 59 | COMPILER_FLAGS += -O0 -g3 60 | endif 61 | # Warnings 62 | ifdef release 63 | COMPILER_FLAGS += -Wno-psabi -Wno-deprecated 64 | else 65 | COMPILER_FLAGS += -Wall -Wextra -Wpedantic -Wshadow -Wdouble-promotion -Wfloat-equal -Wcast-qual -Wimplicit-fallthrough \ 66 | -Wuseless-cast -Wredundant-decls -Wold-style-cast -Wcast-align -Woverloaded-virtual -Wformat=2 \ 67 | -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wnon-virtual-dtor 68 | endif 69 | # Instrumentation 70 | ifdef release 71 | COMPILER_FLAGS += 72 | else 73 | COMPILER_FLAGS += -fsanitize=address,undefined 74 | endif 75 | # Defines 76 | ifdef release 77 | COMPILER_FLAGS += $(addprefix -D, ) 78 | else 79 | COMPILER_FLAGS += $(addprefix -D, TEST) 80 | endif 81 | # Includes 82 | COMPILER_FLAGS += $(addprefix -I, $(INCLUDE_DIRS)) 83 | COMPILER_FLAGS += $(addprefix -isystem, $(SYSTEM_DIRS)) 84 | # Libraries 85 | COMPILER_FLAGS += $(addprefix -l, $(LIBRARIES)) 86 | # Generate dependency files 87 | COMPILER_FLAGS += -MMD -MP 88 | 89 | # --- Linker attributes --- 90 | LINKER_FLAGS = $(COMPILER_FLAGS) 91 | 92 | # --- Stripper attributes --- 93 | STRIPPER_FLAGS = strip --strip-all 94 | 95 | # --- Analysis attributes --- 96 | FILE_FLAGS = file 97 | LDD_FLAGS = ldd 98 | HEXDUMP_FLAGS = hexdump --canonical 99 | STRINGS_FLAGS = strings 100 | READELF_FLAGS = readelf --all 101 | NM_FLAGS = nm 102 | SIZE_FLAGS = size 103 | OBJDUMP_FLAGS = objdump --disassemble --demangle --source-comment --wide --visualize-jumps --decompress --no-addresses \ 104 | --no-show-raw-insn 105 | 106 | # --- Make attributes --- 107 | # Disable implicit variables and rules 108 | MAKE_FLAGS = -r -R 109 | # Use multiple threads for faster compilation 110 | MAKE_FLAGS += -j $(shell nproc 2>/dev/null || echo 4) 111 | MAKEFLAGS = $(MAKE_FLAGS) 112 | 113 | # --- Recipes --- 114 | all: $(BINARY) 115 | ifdef release 116 | @echo "Release build finished" 117 | else 118 | @echo "Debug build finished" 119 | endif 120 | ifdef analyze 121 | $(CMD_PREFIX)$(FILE_FLAGS) $< > $<.file 122 | $(CMD_PREFIX)$(LDD_FLAGS) $< > $<.ldd 123 | $(CMD_PREFIX)$(HEXDUMP_FLAGS) $< > $<.hexdump 124 | $(CMD_PREFIX)$(STRINGS_FLAGS) $< > $<.strings 125 | $(CMD_PREFIX)$(READELF_FLAGS) $< > $<.readelf 126 | $(CMD_PREFIX)$(NM_FLAGS) $< > $<.nm 127 | $(CMD_PREFIX)$(SIZE_FLAGS) $< > $<.size 128 | endif 129 | 130 | $(BINARY): $(OBJS) 131 | @echo "Linking..." 132 | $(CMD_PREFIX)mkdir -p $(@D) 133 | $(CMD_PREFIX)$(LINKER_FLAGS) $^ -o $@ 134 | ifdef release 135 | ifndef MACOS 136 | @echo "Stripping binary..." 137 | $(CMD_PREFIX)$(STRIPPER_FLAGS) $@ -o $@ 138 | endif 139 | endif 140 | 141 | $(OBJ_DIR)/%.o: $(SRC_DIR)/% 142 | @echo "Compiling: $<" 143 | $(CMD_PREFIX)mkdir -p $(@D) 144 | $(CMD_PREFIX)$(COMPILER_FLAGS) -o $@ -c $< 145 | ifdef analyze 146 | $(CMD_PREFIX)$(OBJDUMP_FLAGS) $@ > $@.objdump 147 | endif 148 | 149 | clean: 150 | @echo "Removing files and directories..." 151 | $(CMD_PREFIX)rm -rf $(BUILD_DIR) 152 | 153 | info: 154 | @echo "Source files:" 155 | @echo $(SRCS) 156 | @echo 157 | @echo "Object files:" 158 | @echo $(OBJS) 159 | @echo 160 | @echo "Dependencies:" 161 | @echo $(DEPS) 162 | 163 | install: all 164 | @echo "Installing binary to $(INSTALL_DIR)/bin" 165 | $(CMD_PREFIX)mkdir -p $(INSTALL_DIR)/bin 166 | $(CMD_PREFIX)cp $(BINARY) $(INSTALL_DIR)/bin 167 | @echo "Installing init scripts to $(INSTALL_DIR)/share/blaze" 168 | $(CMD_PREFIX)mkdir -p $(INSTALL_DIR)/share/blaze 169 | $(CMD_PREFIX)cp $(SRC_DIR)/init/* $(INSTALL_DIR)/share/blaze 170 | 171 | uninstall: 172 | @echo "Removing binary from $(INSTALL_DIR)/bin" 173 | $(CMD_PREFIX)rm -f $(INSTALL_DIR)/bin/$(BIN_NAME) 174 | @echo "Removing init scripts from $(INSTALL_DIR)/share/blaze" 175 | $(CMD_PREFIX)rm -rf $(INSTALL_DIR)/share/blaze 176 | 177 | test: all 178 | $(CMD_PREFIX)$(BINARY) --exit 179 | 180 | # --- Misc --- 181 | # Include dependencies to know which files need to be recompiled after modification 182 | -include $(DEPS) 183 | -------------------------------------------------------------------------------- /config/arrow.toml: -------------------------------------------------------------------------------- 1 | [global] 2 | padding = " " 3 | 4 | [prompt] 5 | string = "\n❯ " 6 | foreground = "#25c145" 7 | error_foreground = "#e83030" 8 | new_line = true 9 | separator = "─" 10 | transient = true 11 | 12 | # [[module]] 13 | # name = "user" 14 | # outer_suffix = "" 15 | # background = "#513559" 16 | # foreground = "#ffffff" 17 | 18 | [[module]] 19 | name = "separator" 20 | outer_suffix = "" 21 | background = "default" 22 | 23 | [[module]] 24 | name = "directory" 25 | inner_prefix = " " 26 | outer_suffix = "" 27 | background = "#007aff" 28 | foreground = "#ffffff" 29 | 30 | [[module]] 31 | name = "separator" 32 | outer_suffix = "" 33 | background = "default" 34 | 35 | [[module]] 36 | name = "git_branch" 37 | inner_prefix = " " 38 | background = "#25c145" 39 | foreground = "#ffffff" 40 | 41 | [[module]] 42 | name = "git_commit" 43 | inner_prefix = " " 44 | background = "#25c145" 45 | foreground = "#ffffff" 46 | 47 | [[module]] 48 | name = "git_status" 49 | inner_suffix = " " 50 | outer_suffix = "" 51 | background = "#25c145" 52 | foreground = "#ffffff" 53 | padding = "" 54 | 55 | [[module]] 56 | name = "separator" 57 | outer_suffix = "" 58 | background = "default" 59 | 60 | [[module]] 61 | name = "duration" 62 | inner_prefix = "⌛︎" 63 | outer_suffix = "" 64 | background = "#e38029" 65 | foreground = "#ffffff" 66 | 67 | [[module]] 68 | name = "separator" 69 | outer_suffix = "" 70 | background = "default" 71 | 72 | [[module]] 73 | name = "status" 74 | inner_prefix = "⚠ " 75 | outer_suffix = "" 76 | background = "#e83030" 77 | foreground = "#ffffff" 78 | 79 | [[module]] 80 | name = "separator" 81 | outer_suffix = "" 82 | background = "default" 83 | 84 | # [[module]] 85 | # name = "time" 86 | # inner_prefix = " " 87 | # outer_suffix = "" 88 | # background = "#868686" 89 | # foreground = "#ffffff" 90 | -------------------------------------------------------------------------------- /config/curve.toml: -------------------------------------------------------------------------------- 1 | [prompt] 2 | string = " ❯ " 3 | foreground = "#25c145" 4 | error_foreground = "#e83030" 5 | 6 | [connector] 7 | character = "─" 8 | foreground = "#ffffff" 9 | 10 | [date] 11 | format = "%F" 12 | 13 | [time] 14 | format = "%T" 15 | 16 | [git_status] 17 | clean = "" 18 | 19 | # [[module]] 20 | # name = "user" 21 | # inner_suffix = " " 22 | # foreground = "#513559" 23 | 24 | [[module]] 25 | name = "directory" 26 | inner_prefix = " " 27 | inner_suffix = " " 28 | foreground = "#007aff" 29 | 30 | [[module]] 31 | name = "git_branch" 32 | inner_prefix = " " 33 | inner_suffix = " " 34 | foreground = "#25c145" 35 | 36 | [[module]] 37 | name = "git_commit" 38 | inner_prefix = " " 39 | inner_suffix = " " 40 | foreground = "#25c145" 41 | 42 | [[module]] 43 | name = "git_status" 44 | inner_suffix = " " 45 | foreground = "#25c145" 46 | 47 | [[module]] 48 | name = "duration" 49 | inner_prefix = "⌛︎" 50 | inner_suffix = " " 51 | foreground = "#e38029" 52 | 53 | [[module]] 54 | name = "status" 55 | inner_prefix = "⚠ " 56 | inner_suffix = " " 57 | foreground = "#e83030" 58 | 59 | [[module]] 60 | name = "date" 61 | align = "right" 62 | padding = " " 63 | foreground = "#ffffff" 64 | 65 | [[module]] 66 | name = "time" 67 | align = "right_prompt" 68 | inner_suffix = " " 69 | foreground = "#ffffff" 70 | 71 | [[module]] 72 | name = "fixed" 73 | content = "╭─ " 74 | position = 0 75 | foreground = "#ffffff" 76 | 77 | [[module]] 78 | name = "fixed" 79 | content = "╰─" 80 | level = 2 81 | foreground = "#ffffff" 82 | 83 | [[module]] 84 | name = "fixed" 85 | content = "─╮" 86 | align = "right" 87 | foreground = "#ffffff" 88 | 89 | [[module]] 90 | name = "fixed" 91 | content = "─╯" 92 | align = "right_prompt" 93 | foreground = "#ffffff" 94 | -------------------------------------------------------------------------------- /config/lean.toml: -------------------------------------------------------------------------------- 1 | [prompt] 2 | string = "❯ " 3 | foreground = "#25c145" 4 | error_foreground = "#e83030" 5 | 6 | # [[module]] 7 | # name = "user" 8 | # inner_suffix = " " 9 | # foreground = "#513559" 10 | 11 | [[module]] 12 | name = "directory" 13 | inner_prefix = " " 14 | inner_suffix = " " 15 | foreground = "#007aff" 16 | 17 | [[module]] 18 | name = "git_branch" 19 | inner_prefix = " " 20 | inner_suffix = " " 21 | foreground = "#25c145" 22 | 23 | [[module]] 24 | name = "git_commit" 25 | inner_prefix = " " 26 | inner_suffix = " " 27 | foreground = "#25c145" 28 | 29 | [[module]] 30 | name = "git_status" 31 | inner_suffix = " " 32 | foreground = "#25c145" 33 | 34 | [[module]] 35 | name = "duration" 36 | align = "right_prompt" 37 | inner_prefix = " ⌛︎" 38 | foreground = "#e38029" 39 | 40 | [[module]] 41 | name = "status" 42 | align = "right_prompt" 43 | inner_prefix = " ⚠ " 44 | foreground = "#e83030" 45 | 46 | # [[module]] 47 | # name = "time" 48 | # align = "right_prompt" 49 | # inner_prefix = "  " 50 | # foreground = "#868686" 51 | -------------------------------------------------------------------------------- /config/pure.toml: -------------------------------------------------------------------------------- 1 | [prompt] 2 | string = "❯ " 3 | foreground = "#25c145" 4 | error_foreground = "#e83030" 5 | 6 | # [[module]] 7 | # name = "user" 8 | # inner_suffix = " " 9 | # foreground = "#513559" 10 | 11 | [[module]] 12 | name = "directory" 13 | inner_prefix = " " 14 | inner_suffix = " " 15 | foreground = "#007aff" 16 | 17 | [[module]] 18 | name = "git_branch" 19 | inner_prefix = " " 20 | inner_suffix = " " 21 | foreground = "#25c145" 22 | 23 | [[module]] 24 | name = "git_commit" 25 | inner_prefix = " " 26 | inner_suffix = " " 27 | foreground = "#25c145" 28 | 29 | [[module]] 30 | name = "git_status" 31 | inner_suffix = " " 32 | foreground = "#25c145" 33 | 34 | [[module]] 35 | name = "duration" 36 | inner_prefix = "⌛︎" 37 | inner_suffix = " " 38 | foreground = "#e38029" 39 | 40 | [[module]] 41 | name = "status" 42 | inner_prefix = "⚠ " 43 | inner_suffix = " " 44 | foreground = "#e83030" 45 | 46 | # [[module]] 47 | # name = "time" 48 | # inner_prefix = " " 49 | # inner_suffix = " " 50 | # foreground = "#868686" 51 | -------------------------------------------------------------------------------- /config/test.toml: -------------------------------------------------------------------------------- 1 | # This config is intended to be used for development only. 2 | # Makes it easier to spot visual artifacts. 3 | 4 | [prompt] 5 | string = "\n❯ " 6 | foreground = "green" 7 | error_foreground = "red" 8 | new_line = true 9 | 10 | [connector] 11 | character = "─" 12 | 13 | [[module]] 14 | execute = "echo 'development only config'" 15 | outer_suffix = "" 16 | background = "#513559" 17 | foreground = "#ffffff" 18 | 19 | [[module]] 20 | name = "directory" 21 | inner_prefix = " " 22 | outer_suffix = "" 23 | background = "#007aff" 24 | foreground = "#ffffff" 25 | 26 | [[module]] 27 | name = "separator" 28 | outer_suffix = "" 29 | background = "default" 30 | 31 | [[module]] 32 | name = "git_branch" 33 | inner_prefix = "  " 34 | outer_suffix = "" 35 | background = "#25c145" 36 | foreground = "#ffffff" 37 | padding = "" 38 | 39 | [[module]] 40 | name = "git_status" 41 | level = 2 42 | outer_suffix = "" 43 | background = "#25c145" 44 | foreground = "#ffffff" 45 | padding = "" 46 | 47 | [[module]] 48 | name = "fixed" 49 | outer_suffix = "" 50 | background = "15" 51 | 52 | [[module]] 53 | name = "fixed" 54 | outer_suffix = "" 55 | background = "30" 56 | 57 | [[module]] 58 | name = "fixed" 59 | outer_suffix = "" 60 | background = "180" 61 | 62 | [[module]] 63 | execute = "echo ---///---" 64 | align = "right" 65 | outer_prefix = "" 66 | background = "4" 67 | foreground = "#ffffff" 68 | 69 | [[module]] 70 | name = "user" 71 | align = "right" 72 | outer_prefix = "" 73 | background = "#25c145" 74 | foreground = "#ffffff" 75 | 76 | [[module]] 77 | name = "separator" 78 | align = "right" 79 | outer_prefix = "" 80 | background = "default" 81 | 82 | [[module]] 83 | name = "host" 84 | align = "right" 85 | outer_prefix = "" 86 | background = "#e38029" 87 | foreground = "#ffffff" 88 | 89 | [[module]] 90 | name = "status" 91 | align = "right" 92 | inner_prefix = "⚠ " 93 | outer_prefix = "" 94 | background = "#e83030" 95 | foreground = "#ffffff" 96 | 97 | [[module]] 98 | name = "date" 99 | align = "right_prompt" 100 | inner_suffix = " " 101 | outer_prefix = "" 102 | background = "81" 103 | foreground = "#ffffff" 104 | 105 | [[module]] 106 | name = "date" 107 | align = "right_prompt" 108 | background = "81" 109 | foreground = "#ffffff" 110 | 111 | [[module]] 112 | name = "time" 113 | align = "right_prompt" 114 | inner_prefix = " " 115 | background = "#868686" 116 | foreground = "#ffffff" 117 | -------------------------------------------------------------------------------- /config/warp.toml: -------------------------------------------------------------------------------- 1 | [prompt] 2 | string = "\n❯ " 3 | foreground = "#25c145" 4 | error_foreground = "#e83030" 5 | new_line = true 6 | separator = "─" 7 | transient = true 8 | 9 | [git_status] 10 | clean = "" 11 | 12 | # [[module]] 13 | # name = "user" 14 | # inner_prefix = " " 15 | # outer_suffix = "" 16 | # background = "#513559" 17 | # foreground = "#ffffff" 18 | 19 | [[module]] 20 | name = "directory" 21 | inner_prefix = "  " 22 | outer_suffix = "" 23 | background = "#007aff" 24 | foreground = "#ffffff" 25 | 26 | [[module]] 27 | name = "git_branch" 28 | inner_prefix = "  " 29 | outer_suffix = "" 30 | background = "#25c145" 31 | foreground = "#ffffff" 32 | 33 | [[module]] 34 | name = "git_commit" 35 | inner_prefix = "  " 36 | outer_suffix = "" 37 | background = "#25c145" 38 | foreground = "#ffffff" 39 | 40 | [[module]] 41 | name = "git_status" 42 | outer_suffix = "" 43 | background = "#25c145" 44 | foreground = "#ffffff" 45 | 46 | [[module]] 47 | name = "duration" 48 | inner_prefix = " ⌛︎" 49 | outer_suffix = "" 50 | background = "#e38029" 51 | foreground = "#ffffff" 52 | 53 | [[module]] 54 | name = "status" 55 | inner_prefix = " ⚠ " 56 | outer_suffix = "" 57 | background = "#e83030" 58 | foreground = "#ffffff" 59 | 60 | # [[module]] 61 | # name = "time" 62 | # inner_prefix = "  " 63 | # outer_suffix = "" 64 | # background = "#868686" 65 | # foreground = "#ffffff" 66 | -------------------------------------------------------------------------------- /external/boost/README.md: -------------------------------------------------------------------------------- 1 | # Boost C++ Libraries 2 | 3 | The Boost project provides free peer-reviewed portable C++ source libraries. 4 | 5 | We emphasize libraries that work well with the C++ Standard Library. Boost 6 | libraries are intended to be widely useful, and usable across a broad spectrum 7 | of applications. The Boost license encourages both commercial and non-commercial use 8 | and does not require attribution for binary use. 9 | 10 | The project website is www.boost.org, where you can obtain more information and 11 | [download](https://www.boost.org/users/download/) the current release. 12 | -------------------------------------------------------------------------------- /external/boost/regex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2000 4 | * Dr John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org/libs/regex for documentation. 14 | * FILE regex.h 15 | * VERSION 3.12 16 | * DESCRIPTION: Declares POSIX API functions 17 | */ 18 | 19 | #ifndef BOOST_RE_REGEX_H 20 | #define BOOST_RE_REGEX_H 21 | 22 | #include 23 | 24 | /* 25 | * add using declarations to bring POSIX API functions into 26 | * global scope, only if this is C++ (and not C). 27 | */ 28 | #ifdef __cplusplus 29 | 30 | using boost::regoff_t; 31 | using boost::regex_tA; 32 | using boost::regmatch_t; 33 | using boost::REG_BASIC; 34 | using boost::REG_EXTENDED; 35 | using boost::REG_ICASE; 36 | using boost::REG_NOSUB; 37 | using boost::REG_NEWLINE; 38 | using boost::REG_NOSPEC; 39 | using boost::REG_PEND; 40 | using boost::REG_DUMP; 41 | using boost::REG_NOCOLLATE; 42 | using boost::REG_ESCAPE_IN_LISTS; 43 | using boost::REG_NEWLINE_ALT; 44 | using boost::REG_PERL; 45 | using boost::REG_AWK; 46 | using boost::REG_GREP; 47 | using boost::REG_EGREP; 48 | using boost::REG_ASSERT; 49 | using boost::REG_INVARG; 50 | using boost::REG_ATOI; 51 | using boost::REG_ITOA; 52 | 53 | using boost::REG_NOTBOL; 54 | using boost::REG_NOTEOL; 55 | using boost::REG_STARTEND; 56 | 57 | using boost::reg_comp_flags; 58 | using boost::reg_exec_flags; 59 | using boost::regcompA; 60 | using boost::regerrorA; 61 | using boost::regexecA; 62 | using boost::regfreeA; 63 | 64 | #ifndef BOOST_NO_WREGEX 65 | using boost::regcompW; 66 | using boost::regerrorW; 67 | using boost::regexecW; 68 | using boost::regfreeW; 69 | using boost::regex_tW; 70 | #endif 71 | 72 | using boost::REG_NOERROR; 73 | using boost::REG_NOMATCH; 74 | using boost::REG_BADPAT; 75 | using boost::REG_ECOLLATE; 76 | using boost::REG_ECTYPE; 77 | using boost::REG_EESCAPE; 78 | using boost::REG_ESUBREG; 79 | using boost::REG_EBRACK; 80 | using boost::REG_EPAREN; 81 | using boost::REG_EBRACE; 82 | using boost::REG_BADBR; 83 | using boost::REG_ERANGE; 84 | using boost::REG_ESPACE; 85 | using boost::REG_BADRPT; 86 | using boost::REG_EEND; 87 | using boost::REG_ESIZE; 88 | using boost::REG_ERPAREN; 89 | using boost::REG_EMPTY; 90 | using boost::REG_E_MEMORY; 91 | using boost::REG_E_UNKNOWN; 92 | using boost::reg_errcode_t; 93 | 94 | #endif /* __cplusplus */ 95 | 96 | #endif /* BOOST_RE_REGEX_H */ 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /external/boost/regex.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org/libs/regex for documentation. 14 | * FILE regex.cpp 15 | * VERSION see 16 | * DESCRIPTION: Declares boost::basic_regex<> and associated 17 | * functions and classes. This header is the main 18 | * entry point for the template regex code. 19 | */ 20 | 21 | 22 | /* start with C compatibility API */ 23 | 24 | #ifndef BOOST_RE_REGEX_HPP 25 | #define BOOST_RE_REGEX_HPP 26 | 27 | #ifndef BOOST_REGEX_CONFIG_HPP 28 | #include 29 | #endif 30 | 31 | #ifdef BOOST_REGEX_CXX03 32 | #include 33 | #else 34 | #include 35 | #endif 36 | 37 | #endif // include 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /external/boost/regex/config/borland.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE boost/regex/config/borland.hpp 15 | * VERSION see 16 | * DESCRIPTION: regex borland-specific config setup. 17 | */ 18 | 19 | 20 | #if defined(__BORLANDC__) && !defined(__clang__) 21 | # if (__BORLANDC__ == 0x550) || (__BORLANDC__ == 0x551) 22 | // problems with std::basic_string and dll RTL: 23 | # if defined(_RTLDLL) && defined(_RWSTD_COMPILE_INSTANTIATE) 24 | # ifdef BOOST_REGEX_BUILD_DLL 25 | # error _RWSTD_COMPILE_INSTANTIATE must not be defined when building regex++ as a DLL 26 | # else 27 | # pragma message("Defining _RWSTD_COMPILE_INSTANTIATE when linking to the DLL version of the RTL may produce memory corruption problems in std::basic_string, as a result of separate versions of basic_string's static data in the RTL and you're exe/dll: be warned!!") 28 | # endif 29 | # endif 30 | # ifndef _RTLDLL 31 | // this is harmless for a staic link: 32 | # define _RWSTD_COMPILE_INSTANTIATE 33 | # endif 34 | // external templates cause problems for some reason: 35 | # define BOOST_REGEX_NO_EXTERNAL_TEMPLATES 36 | # endif 37 | # if (__BORLANDC__ <= 0x540) && !defined(BOOST_REGEX_NO_LIB) && !defined(_NO_VCL) 38 | // C++ Builder 4 and earlier, we can't tell whether we should be using 39 | // the VCL runtime or not, do a static link instead: 40 | # define BOOST_REGEX_STATIC_LINK 41 | # endif 42 | // 43 | // VCL support: 44 | // if we're building a console app then there can't be any VCL (can there?) 45 | # if !defined(__CONSOLE__) && !defined(_NO_VCL) 46 | # define BOOST_REGEX_USE_VCL 47 | # endif 48 | // 49 | // if this isn't Win32 then don't automatically select link 50 | // libraries: 51 | // 52 | # ifndef _Windows 53 | # ifndef BOOST_REGEX_NO_LIB 54 | # define BOOST_REGEX_NO_LIB 55 | # endif 56 | # ifndef BOOST_REGEX_STATIC_LINK 57 | # define BOOST_REGEX_STATIC_LINK 58 | # endif 59 | # endif 60 | 61 | #if __BORLANDC__ < 0x600 62 | // 63 | // string workarounds: 64 | // 65 | #include 66 | #undef strcmp 67 | #undef strcpy 68 | #endif 69 | 70 | #endif 71 | 72 | 73 | -------------------------------------------------------------------------------- /external/boost/regex/config/cwchar.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE boost/regex/config/cwchar.hpp 15 | * VERSION see 16 | * DESCRIPTION: regex wide character string fixes. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_CONFIG_CWCHAR_HPP 20 | #define BOOST_REGEX_CONFIG_CWCHAR_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #if defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER) 27 | // apparently this is required for the RW STL on Linux: 28 | #undef iswalnum 29 | #undef iswalpha 30 | #undef iswblank 31 | #undef iswcntrl 32 | #undef iswdigit 33 | #undef iswgraph 34 | #undef iswlower 35 | #undef iswprint 36 | #undef iswprint 37 | #undef iswpunct 38 | #undef iswspace 39 | #undef iswupper 40 | #undef iswxdigit 41 | #undef iswctype 42 | #undef towlower 43 | #undef towupper 44 | #undef towctrans 45 | #undef wctrans 46 | #undef wctype 47 | #endif 48 | 49 | namespace std{ 50 | 51 | #ifndef BOOST_NO_STDC_NAMESPACE 52 | extern "C"{ 53 | #endif 54 | 55 | #ifdef iswalnum 56 | inline int (iswalnum)(wint_t i) 57 | { return iswalnum(i); } 58 | #undef iswalnum 59 | #elif defined(BOOST_NO_STDC_NAMESPACE) 60 | using ::iswalnum; 61 | #endif 62 | 63 | #ifdef iswalpha 64 | inline int (iswalpha)(wint_t i) 65 | { return iswalpha(i); } 66 | #undef iswalpha 67 | #elif defined(BOOST_NO_STDC_NAMESPACE) 68 | using ::iswalpha; 69 | #endif 70 | 71 | #ifdef iswcntrl 72 | inline int (iswcntrl)(wint_t i) 73 | { return iswcntrl(i); } 74 | #undef iswcntrl 75 | #elif defined(BOOST_NO_STDC_NAMESPACE) 76 | using ::iswcntrl; 77 | #endif 78 | 79 | #ifdef iswdigit 80 | inline int (iswdigit)(wint_t i) 81 | { return iswdigit(i); } 82 | #undef iswdigit 83 | #elif defined(BOOST_NO_STDC_NAMESPACE) 84 | using ::iswdigit; 85 | #endif 86 | 87 | #ifdef iswgraph 88 | inline int (iswgraph)(wint_t i) 89 | { return iswgraph(i); } 90 | #undef iswgraph 91 | #elif defined(BOOST_NO_STDC_NAMESPACE) 92 | using ::iswgraph; 93 | #endif 94 | 95 | #ifdef iswlower 96 | inline int (iswlower)(wint_t i) 97 | { return iswlower(i); } 98 | #undef iswlower 99 | #elif defined(BOOST_NO_STDC_NAMESPACE) 100 | using ::iswlower; 101 | #endif 102 | 103 | #ifdef iswprint 104 | inline int (iswprint)(wint_t i) 105 | { return iswprint(i); } 106 | #undef iswprint 107 | #elif defined(BOOST_NO_STDC_NAMESPACE) 108 | using ::iswprint; 109 | #endif 110 | 111 | #ifdef iswpunct 112 | inline int (iswpunct)(wint_t i) 113 | { return iswpunct(i); } 114 | #undef iswpunct 115 | #elif defined(BOOST_NO_STDC_NAMESPACE) 116 | using ::iswpunct; 117 | #endif 118 | 119 | #ifdef iswspace 120 | inline int (iswspace)(wint_t i) 121 | { return iswspace(i); } 122 | #undef iswspace 123 | #elif defined(BOOST_NO_STDC_NAMESPACE) 124 | using ::iswspace; 125 | #endif 126 | 127 | #ifdef iswupper 128 | inline int (iswupper)(wint_t i) 129 | { return iswupper(i); } 130 | #undef iswupper 131 | #elif defined(BOOST_NO_STDC_NAMESPACE) 132 | using ::iswupper; 133 | #endif 134 | 135 | #ifdef iswxdigit 136 | inline int (iswxdigit)(wint_t i) 137 | { return iswxdigit(i); } 138 | #undef iswxdigit 139 | #elif defined(BOOST_NO_STDC_NAMESPACE) 140 | using ::iswxdigit; 141 | #endif 142 | 143 | #ifdef towlower 144 | inline wint_t (towlower)(wint_t i) 145 | { return towlower(i); } 146 | #undef towlower 147 | #elif defined(BOOST_NO_STDC_NAMESPACE) 148 | using ::towlower; 149 | #endif 150 | 151 | #ifdef towupper 152 | inline wint_t (towupper)(wint_t i) 153 | { return towupper(i); } 154 | #undef towupper 155 | #elif defined(BOOST_NO_STDC_NAMESPACE) 156 | using :: towupper; 157 | #endif 158 | 159 | #ifdef wcscmp 160 | inline int (wcscmp)(const wchar_t *p1, const wchar_t *p2) 161 | { return wcscmp(p1,p2); } 162 | #undef wcscmp 163 | #elif defined(BOOST_NO_STDC_NAMESPACE) 164 | using ::wcscmp; 165 | #endif 166 | 167 | #ifdef wcscoll 168 | inline int (wcscoll)(const wchar_t *p1, const wchar_t *p2) 169 | { return wcscoll(p1,p2); } 170 | #undef wcscoll 171 | #elif defined(BOOST_NO_STDC_NAMESPACE) && !defined(UNDER_CE) 172 | using ::wcscoll; 173 | #endif 174 | 175 | #ifdef wcscpy 176 | inline wchar_t *(wcscpy)(wchar_t *p1, const wchar_t *p2) 177 | { return wcscpy(p1,p2); } 178 | #undef wcscpy 179 | #elif defined(BOOST_NO_STDC_NAMESPACE) 180 | using ::wcscpy; 181 | #endif 182 | 183 | #ifdef wcslen 184 | inline size_t (wcslen)(const wchar_t *p) 185 | { return wcslen(p); } 186 | #undef wcslen 187 | #elif defined(BOOST_NO_STDC_NAMESPACE) 188 | using ::wcslen; 189 | #endif 190 | 191 | #ifdef wcsxfrm 192 | size_t wcsxfrm(wchar_t *p1, const wchar_t *p2, size_t s) 193 | { return wcsxfrm(p1,p2,s); } 194 | #undef wcsxfrm 195 | #elif defined(BOOST_NO_STDC_NAMESPACE) 196 | using ::wcsxfrm; 197 | #endif 198 | 199 | 200 | #ifndef BOOST_NO_STDC_NAMESPACE 201 | } // extern "C" 202 | #endif 203 | 204 | } // namespace std 205 | 206 | #endif 207 | 208 | -------------------------------------------------------------------------------- /external/boost/regex/icu.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2020 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE icu.hpp 15 | * VERSION see 16 | * DESCRIPTION: Unicode regular expressions on top of the ICU Library. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_ICU_HPP 20 | #define BOOST_REGEX_ICU_HPP 21 | 22 | #include 23 | 24 | #ifdef BOOST_REGEX_CXX03 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /external/boost/regex/pattern_except.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE pattern_except.hpp 15 | * VERSION see 16 | * DESCRIPTION: Declares pattern-matching exception classes. 17 | */ 18 | 19 | #ifndef BOOST_RE_PAT_EXCEPT_HPP 20 | #define BOOST_RE_PAT_EXCEPT_HPP 21 | 22 | #ifndef BOOST_REGEX_CONFIG_HPP 23 | #include 24 | #endif 25 | 26 | #ifdef BOOST_REGEX_CXX03 27 | #include 28 | #else 29 | #include 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /external/boost/regex/pending/object_cache.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2004 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE object_cache.hpp 15 | * VERSION see 16 | * DESCRIPTION: Implements a generic object cache. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_OBJECT_CACHE_HPP 20 | #define BOOST_REGEX_OBJECT_CACHE_HPP 21 | 22 | #include 23 | #ifdef BOOST_REGEX_CXX03 24 | #include 25 | #else 26 | #include 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /external/boost/regex/pending/static_mutex.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2004 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE static_mutex.hpp 15 | * VERSION see 16 | * DESCRIPTION: Declares static_mutex lock type, there are three different 17 | * implementations: POSIX pthreads, WIN32 threads, and portable, 18 | * these are described in more detail below. 19 | */ 20 | 21 | #ifndef BOOST_REGEX_STATIC_MUTEX_HPP 22 | #define BOOST_REGEX_STATIC_MUTEX_HPP 23 | 24 | #include 25 | #include // dll import/export options. 26 | 27 | #ifdef BOOST_HAS_PTHREADS 28 | #include 29 | #endif 30 | 31 | #if defined(BOOST_HAS_PTHREADS) && defined(PTHREAD_MUTEX_INITIALIZER) 32 | // 33 | // pthreads version: 34 | // simple wrap around a pthread_mutex_t initialized with 35 | // PTHREAD_MUTEX_INITIALIZER. 36 | // 37 | namespace boost{ 38 | 39 | class static_mutex; 40 | 41 | #define BOOST_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, } 42 | 43 | class BOOST_REGEX_DECL scoped_static_mutex_lock 44 | { 45 | public: 46 | scoped_static_mutex_lock(static_mutex& mut, bool lk = true); 47 | ~scoped_static_mutex_lock(); 48 | inline bool locked()const 49 | { 50 | return m_have_lock; 51 | } 52 | inline operator void const*()const 53 | { 54 | return locked() ? this : 0; 55 | } 56 | void lock(); 57 | void unlock(); 58 | private: 59 | static_mutex& m_mutex; 60 | bool m_have_lock; 61 | }; 62 | 63 | class static_mutex 64 | { 65 | public: 66 | typedef scoped_static_mutex_lock scoped_lock; 67 | pthread_mutex_t m_mutex; 68 | }; 69 | 70 | } // namespace boost 71 | #elif defined(BOOST_HAS_WINTHREADS) 72 | // 73 | // Win32 version: 74 | // Use a 32-bit int as a lock, along with a test-and-set 75 | // implementation using InterlockedCompareExchange. 76 | // 77 | 78 | #include 79 | 80 | namespace boost{ 81 | 82 | class BOOST_REGEX_DECL scoped_static_mutex_lock; 83 | 84 | class static_mutex 85 | { 86 | public: 87 | typedef scoped_static_mutex_lock scoped_lock; 88 | boost::int32_t m_mutex; 89 | }; 90 | 91 | #define BOOST_STATIC_MUTEX_INIT { 0, } 92 | 93 | class BOOST_REGEX_DECL scoped_static_mutex_lock 94 | { 95 | public: 96 | scoped_static_mutex_lock(static_mutex& mut, bool lk = true); 97 | ~scoped_static_mutex_lock(); 98 | operator void const*()const 99 | { 100 | return locked() ? this : 0; 101 | } 102 | bool locked()const 103 | { 104 | return m_have_lock; 105 | } 106 | void lock(); 107 | void unlock(); 108 | private: 109 | static_mutex& m_mutex; 110 | bool m_have_lock; 111 | scoped_static_mutex_lock(const scoped_static_mutex_lock&); 112 | scoped_static_mutex_lock& operator=(const scoped_static_mutex_lock&); 113 | }; 114 | 115 | } // namespace 116 | 117 | #else 118 | // 119 | // Portable version of a static mutex based on Boost.Thread library: 120 | // This has to use a single mutex shared by all instances of static_mutex 121 | // because boost::call_once doesn't alow us to pass instance information 122 | // down to the initialisation proceedure. In fact the initialisation routine 123 | // may need to be called more than once - but only once per instance. 124 | // 125 | // Since this preprocessor path is almost never taken, we hide these header 126 | // dependencies so that build tools don't find them. 127 | // 128 | #define BOOST_REGEX_H1 129 | #define BOOST_REGEX_H2 130 | #define BOOST_REGEX_H3 131 | #include BOOST_REGEX_H1 132 | #include BOOST_REGEX_H2 133 | #include BOOST_REGEX_H3 134 | #undef BOOST_REGEX_H1 135 | #undef BOOST_REGEX_H2 136 | #undef BOOST_REGEX_H3 137 | 138 | namespace boost{ 139 | 140 | class BOOST_REGEX_DECL scoped_static_mutex_lock; 141 | extern "C" BOOST_REGEX_DECL void boost_regex_free_static_mutex(); 142 | 143 | class BOOST_REGEX_DECL static_mutex 144 | { 145 | public: 146 | typedef scoped_static_mutex_lock scoped_lock; 147 | static void init(); 148 | static boost::recursive_mutex* m_pmutex; 149 | static boost::once_flag m_once; 150 | }; 151 | 152 | #define BOOST_STATIC_MUTEX_INIT { } 153 | 154 | class BOOST_REGEX_DECL scoped_static_mutex_lock 155 | { 156 | public: 157 | scoped_static_mutex_lock(static_mutex& mut, bool lk = true); 158 | ~scoped_static_mutex_lock(); 159 | operator void const*()const; 160 | bool locked()const; 161 | void lock(); 162 | void unlock(); 163 | private: 164 | boost::unique_lock* m_plock; 165 | bool m_have_lock; 166 | }; 167 | 168 | inline scoped_static_mutex_lock::operator void const*()const 169 | { 170 | return locked() ? this : 0; 171 | } 172 | 173 | inline bool scoped_static_mutex_lock::locked()const 174 | { 175 | return m_have_lock; 176 | } 177 | 178 | } // namespace 179 | 180 | #endif 181 | 182 | #endif 183 | -------------------------------------------------------------------------------- /external/boost/regex/pending/unicode_iterator.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2020 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE unicode_iterator.hpp 15 | * VERSION see 16 | * DESCRIPTION: Iterator adapters for converting between different Unicode encodings. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_PENDING_UNICODE_ITERATOR_HPP 20 | #define BOOST_REGEX_PENDING_UNICODE_ITERATOR_HPP 21 | 22 | #include 23 | 24 | #if defined(BOOST_REGEX_CXX03) 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | 31 | #endif // BOOST_REGEX_PENDING_UNICODE_ITERATOR_HPP 32 | 33 | -------------------------------------------------------------------------------- /external/boost/regex/regex_traits.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_traits.hpp 15 | * VERSION see 16 | * DESCRIPTION: Declares regular expression traits classes. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_TRAITS_HPP 20 | #define BOOST_REGEX_TRAITS_HPP 21 | 22 | #ifndef BOOST_REGEX_CONFIG_HPP 23 | # include 24 | #endif 25 | 26 | # ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED 27 | #ifdef BOOST_REGEX_CXX03 28 | # include 29 | #else 30 | # include 31 | #endif 32 | # endif 33 | 34 | #endif // include 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /external/boost/regex/user.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE user.hpp 15 | * VERSION see 16 | * DESCRIPTION: User settable options. 17 | */ 18 | 19 | // define if you want the regex library to use the C locale 20 | // even on Win32: 21 | // #define BOOST_REGEX_USE_C_LOCALE 22 | 23 | // define this is you want the regex library to use the C++ 24 | // locale: 25 | // #define BOOST_REGEX_USE_CPP_LOCALE 26 | 27 | // define this if the runtime library is a dll, and you 28 | // want BOOST_REGEX_DYN_LINK to set up dll exports/imports 29 | // with __declspec(dllexport)/__declspec(dllimport.) 30 | // #define BOOST_REGEX_HAS_DLL_RUNTIME 31 | 32 | // define this if you want to dynamically link to regex, 33 | // if the runtime library is also a dll (Probably Win32 specific, 34 | // and has no effect unless BOOST_REGEX_HAS_DLL_RUNTIME is set): 35 | // #define BOOST_REGEX_DYN_LINK 36 | 37 | // define this if you don't want the lib to automatically 38 | // select its link libraries: 39 | // #define BOOST_REGEX_NO_LIB 40 | 41 | // define this if templates with switch statements cause problems: 42 | // #define BOOST_REGEX_NO_TEMPLATE_SWITCH_MERGE 43 | 44 | // define this to disable Win32 support when available: 45 | // #define BOOST_REGEX_NO_W32 46 | 47 | // define this if bool is not a real type: 48 | // #define BOOST_REGEX_NO_BOOL 49 | 50 | // define this if no template instances are to be placed in 51 | // the library rather than users object files: 52 | // #define BOOST_REGEX_NO_EXTERNAL_TEMPLATES 53 | 54 | // define this if the forward declarations in regex_fwd.hpp 55 | // cause more problems than they are worth: 56 | // #define BOOST_REGEX_NO_FWD 57 | 58 | // define this if your compiler supports MS Windows structured 59 | // exception handling. 60 | // #define BOOST_REGEX_HAS_MS_STACK_GUARD 61 | 62 | // define this if you want to use the recursive algorithm 63 | // even if BOOST_REGEX_HAS_MS_STACK_GUARD is not defined. 64 | // NOTE: OBSOLETE!! 65 | // #define BOOST_REGEX_RECURSIVE 66 | 67 | // define this if you want to use the non-recursive 68 | // algorithm, even if the recursive version would be the default. 69 | // NOTE: OBSOLETE!! 70 | // #define BOOST_REGEX_NON_RECURSIVE 71 | 72 | // define this if you want to set the size of the memory blocks 73 | // used by the non-recursive algorithm. 74 | // #define BOOST_REGEX_BLOCKSIZE 4096 75 | 76 | // define this if you want to set the maximum number of memory blocks 77 | // used by the non-recursive algorithm. 78 | // #define BOOST_REGEX_MAX_BLOCKS 1024 79 | 80 | // define this if you want to set the maximum number of memory blocks 81 | // cached by the non-recursive algorithm: Normally this is 16, but can be 82 | // higher if you have multiple threads all using boost.regex, or lower 83 | // if you don't want boost.regex to cache memory. 84 | // #define BOOST_REGEX_MAX_CACHE_BLOCKS 16 85 | 86 | // define this if you want to be able to access extended capture 87 | // information in your sub_match's (caution this will slow things 88 | // down quite a bit). 89 | // #define BOOST_REGEX_MATCH_EXTRA 90 | 91 | // define this if you want to enable support for Unicode via ICU. 92 | // #define BOOST_HAS_ICU 93 | 94 | // define this if you want regex to use __cdecl calling convensions, even when __fastcall is available: 95 | // #define BOOST_REGEX_NO_FASTCALL 96 | -------------------------------------------------------------------------------- /external/boost/regex/v4/char_regex_traits.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE char_regex_traits.cpp 15 | * VERSION see 16 | * DESCRIPTION: Declares deprecated traits classes char_regex_traits<>. 17 | */ 18 | 19 | 20 | #ifndef BOOST_REGEX_V4_CHAR_REGEX_TRAITS_HPP 21 | #define BOOST_REGEX_V4_CHAR_REGEX_TRAITS_HPP 22 | 23 | #ifdef BOOST_MSVC 24 | #pragma warning(push) 25 | #pragma warning(disable: 4103) 26 | #endif 27 | #ifdef BOOST_HAS_ABI_HEADERS 28 | # include BOOST_ABI_PREFIX 29 | #endif 30 | #ifdef BOOST_MSVC 31 | #pragma warning(pop) 32 | #endif 33 | 34 | namespace boost{ 35 | 36 | namespace deprecated{ 37 | // 38 | // class char_regex_traits_i 39 | // provides case insensitive traits classes (deprecated): 40 | template 41 | class char_regex_traits_i : public regex_traits {}; 42 | 43 | template<> 44 | class char_regex_traits_i : public regex_traits 45 | { 46 | public: 47 | typedef char char_type; 48 | typedef unsigned char uchar_type; 49 | typedef unsigned int size_type; 50 | typedef regex_traits base_type; 51 | 52 | }; 53 | 54 | #ifndef BOOST_NO_WREGEX 55 | template<> 56 | class char_regex_traits_i : public regex_traits 57 | { 58 | public: 59 | typedef wchar_t char_type; 60 | typedef unsigned short uchar_type; 61 | typedef unsigned int size_type; 62 | typedef regex_traits base_type; 63 | 64 | }; 65 | #endif 66 | } // namespace deprecated 67 | } // namespace boost 68 | 69 | #ifdef BOOST_MSVC 70 | #pragma warning(push) 71 | #pragma warning(disable: 4103) 72 | #endif 73 | #ifdef BOOST_HAS_ABI_HEADERS 74 | # include BOOST_ABI_SUFFIX 75 | #endif 76 | #ifdef BOOST_MSVC 77 | #pragma warning(pop) 78 | #endif 79 | 80 | #endif // include 81 | 82 | -------------------------------------------------------------------------------- /external/boost/regex/v4/error_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2003-2005 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE error_type.hpp 15 | * VERSION see 16 | * DESCRIPTION: Declares regular expression error type enumerator. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_ERROR_TYPE_HPP 20 | #define BOOST_REGEX_ERROR_TYPE_HPP 21 | 22 | #ifdef __cplusplus 23 | namespace boost{ 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | namespace regex_constants{ 28 | 29 | enum error_type{ 30 | 31 | error_ok = 0, /* not used */ 32 | error_no_match = 1, /* not used */ 33 | error_bad_pattern = 2, 34 | error_collate = 3, 35 | error_ctype = 4, 36 | error_escape = 5, 37 | error_backref = 6, 38 | error_brack = 7, 39 | error_paren = 8, 40 | error_brace = 9, 41 | error_badbrace = 10, 42 | error_range = 11, 43 | error_space = 12, 44 | error_badrepeat = 13, 45 | error_end = 14, /* not used */ 46 | error_size = 15, 47 | error_right_paren = 16, /* not used */ 48 | error_empty = 17, 49 | error_complexity = 18, 50 | error_stack = 19, 51 | error_perl_extension = 20, 52 | error_unknown = 21 53 | }; 54 | 55 | } 56 | } 57 | #endif /* __cplusplus */ 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /external/boost/regex/v4/indexed_bit_flag.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2020 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE basic_regex_parser.cpp 15 | * VERSION see 16 | * DESCRIPTION: Declares template class basic_regex_parser. 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | #ifndef BOOST_REGEX_V4_INDEXED_BIT_FLAG_HPP 23 | #define BOOST_REGEX_V4_INDEXED_BIT_FLAG_HPP 24 | 25 | namespace boost{ 26 | namespace BOOST_REGEX_DETAIL_NS{ 27 | 28 | class indexed_bit_flag 29 | { 30 | boost::uint64_t low_mask; 31 | std::set mask_set; 32 | public: 33 | indexed_bit_flag() : low_mask(0) {} 34 | void set(std::size_t i) 35 | { 36 | if (i < std::numeric_limits::digits - 1) 37 | low_mask |= static_cast(1u) << i; 38 | else 39 | mask_set.insert(i); 40 | } 41 | bool test(std::size_t i) 42 | { 43 | if (i < std::numeric_limits::digits - 1) 44 | return low_mask & static_cast(1u) << i ? true : false; 45 | else 46 | return mask_set.find(i) != mask_set.end(); 47 | } 48 | }; 49 | 50 | } // namespace BOOST_REGEX_DETAIL_NS 51 | } // namespace boost 52 | 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /external/boost/regex/v4/iterator_category.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_match.hpp 15 | * VERSION see 16 | * DESCRIPTION: Iterator traits for selecting an iterator type as 17 | * an integral constant expression. 18 | */ 19 | 20 | 21 | #ifndef BOOST_REGEX_ITERATOR_CATEGORY_HPP 22 | #define BOOST_REGEX_ITERATOR_CATEGORY_HPP 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace boost{ 29 | namespace detail{ 30 | 31 | template 32 | struct is_random_imp 33 | { 34 | #ifndef BOOST_NO_STD_ITERATOR_TRAITS 35 | private: 36 | typedef typename std::iterator_traits::iterator_category cat; 37 | public: 38 | BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible::value)); 39 | #else 40 | BOOST_STATIC_CONSTANT(bool, value = false); 41 | #endif 42 | }; 43 | 44 | template 45 | struct is_random_pointer_imp 46 | { 47 | BOOST_STATIC_CONSTANT(bool, value = true); 48 | }; 49 | 50 | template 51 | struct is_random_imp_selector 52 | { 53 | template 54 | struct rebind 55 | { 56 | typedef is_random_imp type; 57 | }; 58 | }; 59 | 60 | template <> 61 | struct is_random_imp_selector 62 | { 63 | template 64 | struct rebind 65 | { 66 | typedef is_random_pointer_imp type; 67 | }; 68 | }; 69 | 70 | } 71 | 72 | template 73 | struct is_random_access_iterator 74 | { 75 | private: 76 | typedef detail::is_random_imp_selector< ::boost::is_pointer::value> selector; 77 | typedef typename selector::template rebind bound_type; 78 | typedef typename bound_type::type answer; 79 | public: 80 | BOOST_STATIC_CONSTANT(bool, value = answer::value); 81 | }; 82 | 83 | #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION 84 | template 85 | const bool is_random_access_iterator::value; 86 | #endif 87 | 88 | } 89 | 90 | #endif 91 | 92 | -------------------------------------------------------------------------------- /external/boost/regex/v4/iterator_traits.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE iterator_traits.cpp 15 | * VERSION see 16 | * DESCRIPTION: Declares iterator traits workarounds. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_V4_ITERATOR_TRAITS_HPP 20 | #define BOOST_REGEX_V4_ITERATOR_TRAITS_HPP 21 | 22 | #ifdef BOOST_MSVC 23 | #pragma warning(push) 24 | #pragma warning(disable: 4103) 25 | #endif 26 | #ifdef BOOST_HAS_ABI_HEADERS 27 | # include BOOST_ABI_PREFIX 28 | #endif 29 | #ifdef BOOST_MSVC 30 | #pragma warning(pop) 31 | #endif 32 | 33 | namespace boost{ 34 | namespace BOOST_REGEX_DETAIL_NS{ 35 | 36 | #if defined(BOOST_NO_STD_ITERATOR_TRAITS) 37 | 38 | template 39 | struct regex_iterator_traits 40 | { 41 | typedef typename T::iterator_category iterator_category; 42 | typedef typename T::value_type value_type; 43 | #if !defined(BOOST_NO_STD_ITERATOR) 44 | typedef typename T::difference_type difference_type; 45 | typedef typename T::pointer pointer; 46 | typedef typename T::reference reference; 47 | #else 48 | typedef std::ptrdiff_t difference_type; 49 | typedef value_type* pointer; 50 | typedef value_type& reference; 51 | #endif 52 | }; 53 | 54 | template 55 | struct pointer_iterator_traits 56 | { 57 | typedef std::ptrdiff_t difference_type; 58 | typedef T value_type; 59 | typedef T* pointer; 60 | typedef T& reference; 61 | typedef std::random_access_iterator_tag iterator_category; 62 | }; 63 | template 64 | struct const_pointer_iterator_traits 65 | { 66 | typedef std::ptrdiff_t difference_type; 67 | typedef T value_type; 68 | typedef const T* pointer; 69 | typedef const T& reference; 70 | typedef std::random_access_iterator_tag iterator_category; 71 | }; 72 | 73 | template<> 74 | struct regex_iterator_traits : pointer_iterator_traits{}; 75 | template<> 76 | struct regex_iterator_traits : const_pointer_iterator_traits{}; 77 | template<> 78 | struct regex_iterator_traits : pointer_iterator_traits{}; 79 | template<> 80 | struct regex_iterator_traits : const_pointer_iterator_traits{}; 81 | // 82 | // the follwoing are needed for ICU support: 83 | // 84 | template<> 85 | struct regex_iterator_traits : pointer_iterator_traits{}; 86 | template<> 87 | struct regex_iterator_traits : const_pointer_iterator_traits{}; 88 | template<> 89 | struct regex_iterator_traits : pointer_iterator_traits{}; 90 | template<> 91 | struct regex_iterator_traits : const_pointer_iterator_traits{}; 92 | 93 | #ifdef BOOST_REGEX_HAS_OTHER_WCHAR_T 94 | template<> 95 | struct regex_iterator_traits : pointer_iterator_traits{}; 96 | template<> 97 | struct regex_iterator_traits : const_pointer_iterator_traits{}; 98 | #endif 99 | 100 | #if defined(__SGI_STL_PORT) && defined(__STL_DEBUG) 101 | template<> 102 | struct regex_iterator_traits : pointer_iterator_traits{}; 103 | template<> 104 | struct regex_iterator_traits : const_pointer_iterator_traits{}; 105 | #ifndef BOOST_NO_STD_WSTRING 106 | template<> 107 | struct regex_iterator_traits : pointer_iterator_traits{}; 108 | template<> 109 | struct regex_iterator_traits : const_pointer_iterator_traits{}; 110 | #endif // BOOST_NO_WSTRING 111 | #endif // stport 112 | 113 | #else 114 | 115 | template 116 | struct regex_iterator_traits : public std::iterator_traits {}; 117 | 118 | #endif 119 | 120 | } // namespace BOOST_REGEX_DETAIL_NS 121 | } // namespace boost 122 | 123 | #ifdef BOOST_MSVC 124 | #pragma warning(push) 125 | #pragma warning(disable: 4103) 126 | #endif 127 | #ifdef BOOST_HAS_ABI_HEADERS 128 | # include BOOST_ABI_SUFFIX 129 | #endif 130 | #ifdef BOOST_MSVC 131 | #pragma warning(pop) 132 | #endif 133 | 134 | #endif 135 | 136 | -------------------------------------------------------------------------------- /external/boost/regex/v4/mem_block_cache.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 3 | * John Maddock 4 | * 5 | * Use, modification and distribution are subject to the 6 | * Boost Software License, Version 1.0. (See accompanying file 7 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | */ 10 | 11 | /* 12 | * LOCATION: see http://www.boost.org for most recent version. 13 | * FILE mem_block_cache.hpp 14 | * VERSION see 15 | * DESCRIPTION: memory block cache used by the non-recursive matcher. 16 | */ 17 | 18 | #ifndef BOOST_REGEX_V4_MEM_BLOCK_CACHE_HPP 19 | #define BOOST_REGEX_V4_MEM_BLOCK_CACHE_HPP 20 | 21 | #include 22 | #ifdef BOOST_HAS_THREADS 23 | #include 24 | #endif 25 | 26 | #ifdef BOOST_HAS_ABI_HEADERS 27 | # include BOOST_ABI_PREFIX 28 | #endif 29 | 30 | #ifndef BOOST_NO_CXX11_HDR_ATOMIC 31 | #include 32 | #if ATOMIC_POINTER_LOCK_FREE == 2 33 | #define BOOST_REGEX_MEM_BLOCK_CACHE_LOCK_FREE 34 | #define BOOST_REGEX_ATOMIC_POINTER std::atomic 35 | #endif 36 | #endif 37 | 38 | namespace boost{ 39 | namespace BOOST_REGEX_DETAIL_NS{ 40 | 41 | #ifdef BOOST_REGEX_MEM_BLOCK_CACHE_LOCK_FREE /* lock free implementation */ 42 | struct mem_block_cache 43 | { 44 | std::atomic cache[BOOST_REGEX_MAX_CACHE_BLOCKS]; 45 | 46 | ~mem_block_cache() 47 | { 48 | for (size_t i = 0;i < BOOST_REGEX_MAX_CACHE_BLOCKS; ++i) { 49 | if (cache[i].load()) ::operator delete(cache[i].load()); 50 | } 51 | } 52 | void* get() 53 | { 54 | for (size_t i = 0;i < BOOST_REGEX_MAX_CACHE_BLOCKS; ++i) { 55 | void* p = cache[i].load(); 56 | if (p != NULL) { 57 | if (cache[i].compare_exchange_strong(p, NULL)) return p; 58 | } 59 | } 60 | return ::operator new(BOOST_REGEX_BLOCKSIZE); 61 | } 62 | void put(void* ptr) 63 | { 64 | for (size_t i = 0;i < BOOST_REGEX_MAX_CACHE_BLOCKS; ++i) { 65 | void* p = cache[i].load(); 66 | if (p == NULL) { 67 | if (cache[i].compare_exchange_strong(p, ptr)) return; 68 | } 69 | } 70 | ::operator delete(ptr); 71 | } 72 | 73 | static mem_block_cache& instance() 74 | { 75 | static mem_block_cache block_cache = { { {nullptr} } }; 76 | return block_cache; 77 | } 78 | }; 79 | 80 | 81 | #else /* lock-based implementation */ 82 | 83 | 84 | struct mem_block_node 85 | { 86 | mem_block_node* next; 87 | }; 88 | 89 | struct mem_block_cache 90 | { 91 | // this member has to be statically initialsed: 92 | mem_block_node* next; 93 | unsigned cached_blocks; 94 | #ifdef BOOST_HAS_THREADS 95 | boost::static_mutex mut; 96 | #endif 97 | 98 | ~mem_block_cache() 99 | { 100 | while(next) 101 | { 102 | mem_block_node* old = next; 103 | next = next->next; 104 | ::operator delete(old); 105 | } 106 | } 107 | void* get() 108 | { 109 | #ifdef BOOST_HAS_THREADS 110 | boost::static_mutex::scoped_lock g(mut); 111 | #endif 112 | if(next) 113 | { 114 | mem_block_node* result = next; 115 | next = next->next; 116 | --cached_blocks; 117 | return result; 118 | } 119 | return ::operator new(BOOST_REGEX_BLOCKSIZE); 120 | } 121 | void put(void* p) 122 | { 123 | #ifdef BOOST_HAS_THREADS 124 | boost::static_mutex::scoped_lock g(mut); 125 | #endif 126 | if(cached_blocks >= BOOST_REGEX_MAX_CACHE_BLOCKS) 127 | { 128 | ::operator delete(p); 129 | } 130 | else 131 | { 132 | mem_block_node* old = static_cast(p); 133 | old->next = next; 134 | next = old; 135 | ++cached_blocks; 136 | } 137 | } 138 | static mem_block_cache& instance() 139 | { 140 | #ifdef BOOST_HAS_THREADS 141 | static mem_block_cache block_cache = { 0, 0, BOOST_STATIC_MUTEX_INIT, }; 142 | #else 143 | static mem_block_cache block_cache = { 0, 0, }; 144 | #endif 145 | return block_cache; 146 | } 147 | }; 148 | #endif 149 | 150 | #if BOOST_REGEX_MAX_CACHE_BLOCKS == 0 151 | 152 | inline void* BOOST_REGEX_CALL get_mem_block() 153 | { 154 | return ::operator new(BOOST_REGEX_BLOCKSIZE); 155 | } 156 | 157 | inline void BOOST_REGEX_CALL put_mem_block(void* p) 158 | { 159 | ::operator delete(p); 160 | } 161 | 162 | #else 163 | 164 | inline void* BOOST_REGEX_CALL get_mem_block() 165 | { 166 | return mem_block_cache::instance().get(); 167 | } 168 | 169 | inline void BOOST_REGEX_CALL put_mem_block(void* p) 170 | { 171 | mem_block_cache::instance().put(p); 172 | } 173 | 174 | #endif 175 | } 176 | } // namespace boost 177 | 178 | #ifdef BOOST_HAS_ABI_HEADERS 179 | # include BOOST_ABI_SUFFIX 180 | #endif 181 | 182 | #endif 183 | 184 | -------------------------------------------------------------------------------- /external/boost/regex/v4/pattern_except.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE pattern_except.hpp 15 | * VERSION see 16 | * DESCRIPTION: Declares pattern-matching exception classes. 17 | */ 18 | 19 | #ifndef BOOST_RE_V4_PAT_EXCEPT_HPP 20 | #define BOOST_RE_V4_PAT_EXCEPT_HPP 21 | 22 | #ifndef BOOST_REGEX_CONFIG_HPP 23 | #include 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace boost{ 32 | 33 | #ifdef BOOST_MSVC 34 | #pragma warning(push) 35 | #pragma warning(disable: 4103) 36 | #endif 37 | #ifdef BOOST_HAS_ABI_HEADERS 38 | # include BOOST_ABI_PREFIX 39 | #endif 40 | #ifdef BOOST_MSVC 41 | #pragma warning(pop) 42 | #endif 43 | 44 | #ifdef BOOST_MSVC 45 | #pragma warning(push) 46 | #pragma warning(disable : 4275) 47 | #if BOOST_MSVC >= 1800 48 | #pragma warning(disable : 26812) 49 | #endif 50 | #endif 51 | class regex_error : public std::runtime_error 52 | { 53 | public: 54 | explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0) 55 | : std::runtime_error(s) 56 | , m_error_code(err) 57 | , m_position(pos) 58 | { 59 | } 60 | explicit regex_error(regex_constants::error_type err) 61 | : std::runtime_error(::boost::BOOST_REGEX_DETAIL_NS::get_default_error_string(err)) 62 | , m_error_code(err) 63 | , m_position(0) 64 | { 65 | } 66 | ~regex_error() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {} 67 | regex_constants::error_type code()const 68 | { return m_error_code; } 69 | std::ptrdiff_t position()const 70 | { return m_position; } 71 | void raise()const 72 | { 73 | #ifndef BOOST_NO_EXCEPTIONS 74 | #ifndef BOOST_REGEX_STANDALONE 75 | ::boost::throw_exception(*this); 76 | #else 77 | throw* this; 78 | #endif 79 | #endif 80 | } 81 | private: 82 | regex_constants::error_type m_error_code; 83 | std::ptrdiff_t m_position; 84 | }; 85 | 86 | typedef regex_error bad_pattern; 87 | typedef regex_error bad_expression; 88 | 89 | namespace BOOST_REGEX_DETAIL_NS{ 90 | 91 | template 92 | inline void raise_runtime_error(const E& ex) 93 | { 94 | #ifndef BOOST_REGEX_STANDALONE 95 | ::boost::throw_exception(ex); 96 | #else 97 | throw ex; 98 | #endif 99 | } 100 | 101 | template 102 | void raise_error(const traits& t, regex_constants::error_type code) 103 | { 104 | (void)t; // warning suppression 105 | regex_error e(t.error_string(code), code, 0); 106 | ::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(e); 107 | } 108 | 109 | } 110 | 111 | #ifdef BOOST_MSVC 112 | #pragma warning(pop) 113 | #endif 114 | 115 | #ifdef BOOST_MSVC 116 | #pragma warning(push) 117 | #pragma warning(disable: 4103) 118 | #endif 119 | #ifdef BOOST_HAS_ABI_HEADERS 120 | # include BOOST_ABI_SUFFIX 121 | #endif 122 | #ifdef BOOST_MSVC 123 | #pragma warning(pop) 124 | #endif 125 | 126 | } // namespace boost 127 | 128 | #endif 129 | -------------------------------------------------------------------------------- /external/boost/regex/v4/primary_transform.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE: primary_transform.hpp 15 | * VERSION: see 16 | * DESCRIPTION: Heuristically determines the sort string format in use 17 | * by the current locale. 18 | */ 19 | 20 | #ifndef BOOST_REGEX_PRIMARY_TRANSFORM 21 | #define BOOST_REGEX_PRIMARY_TRANSFORM 22 | 23 | #ifdef BOOST_MSVC 24 | #pragma warning(push) 25 | #pragma warning(disable: 4103) 26 | #endif 27 | #ifdef BOOST_HAS_ABI_HEADERS 28 | # include BOOST_ABI_PREFIX 29 | #endif 30 | #ifdef BOOST_MSVC 31 | #pragma warning(pop) 32 | #endif 33 | 34 | namespace boost{ 35 | namespace BOOST_REGEX_DETAIL_NS{ 36 | 37 | 38 | enum{ 39 | sort_C, 40 | sort_fixed, 41 | sort_delim, 42 | sort_unknown 43 | }; 44 | 45 | template 46 | unsigned count_chars(const S& s, charT c) 47 | { 48 | // 49 | // Count how many occurrences of character c occur 50 | // in string s: if c is a delimeter between collation 51 | // fields, then this should be the same value for all 52 | // sort keys: 53 | // 54 | unsigned int count = 0; 55 | for(unsigned pos = 0; pos < s.size(); ++pos) 56 | { 57 | if(s[pos] == c) ++count; 58 | } 59 | return count; 60 | } 61 | 62 | 63 | template 64 | unsigned find_sort_syntax(const traits* pt, charT* delim) 65 | { 66 | // 67 | // compare 'a' with 'A' to see how similar they are, 68 | // should really use a-accute but we can't portably do that, 69 | // 70 | typedef typename traits::string_type string_type; 71 | typedef typename traits::char_type char_type; 72 | 73 | // Suppress incorrect warning for MSVC 74 | (void)pt; 75 | 76 | char_type a[2] = {'a', '\0', }; 77 | string_type sa(pt->transform(a, a+1)); 78 | if(sa == a) 79 | { 80 | *delim = 0; 81 | return sort_C; 82 | } 83 | char_type A[2] = { 'A', '\0', }; 84 | string_type sA(pt->transform(A, A+1)); 85 | char_type c[2] = { ';', '\0', }; 86 | string_type sc(pt->transform(c, c+1)); 87 | 88 | int pos = 0; 89 | while((pos <= static_cast(sa.size())) && (pos <= static_cast(sA.size())) && (sa[pos] == sA[pos])) ++pos; 90 | --pos; 91 | if(pos < 0) 92 | { 93 | *delim = 0; 94 | return sort_unknown; 95 | } 96 | // 97 | // at this point sa[pos] is either the end of a fixed width field 98 | // or the character that acts as a delimiter: 99 | // 100 | charT maybe_delim = sa[pos]; 101 | if((pos != 0) && (count_chars(sa, maybe_delim) == count_chars(sA, maybe_delim)) && (count_chars(sa, maybe_delim) == count_chars(sc, maybe_delim))) 102 | { 103 | *delim = maybe_delim; 104 | return sort_delim; 105 | } 106 | // 107 | // OK doen't look like a delimiter, try for fixed width field: 108 | // 109 | if((sa.size() == sA.size()) && (sa.size() == sc.size())) 110 | { 111 | // note assumes that the fixed width field is less than 112 | // (numeric_limits::max)(), should be true for all types 113 | // I can't imagine 127 character fields... 114 | *delim = static_cast(++pos); 115 | return sort_fixed; 116 | } 117 | // 118 | // don't know what it is: 119 | // 120 | *delim = 0; 121 | return sort_unknown; 122 | } 123 | 124 | 125 | } // namespace BOOST_REGEX_DETAIL_NS 126 | } // namespace boost 127 | 128 | #ifdef BOOST_MSVC 129 | #pragma warning(push) 130 | #pragma warning(disable: 4103) 131 | #endif 132 | #ifdef BOOST_HAS_ABI_HEADERS 133 | # include BOOST_ABI_SUFFIX 134 | #endif 135 | #ifdef BOOST_MSVC 136 | #pragma warning(pop) 137 | #endif 138 | 139 | #endif 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /external/boost/regex/v4/protected_call.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2004 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE basic_regex_creator.cpp 15 | * VERSION see 16 | * DESCRIPTION: Declares template class basic_regex_creator which fills in 17 | * the data members of a regex_data object. 18 | */ 19 | 20 | #ifndef BOOST_REGEX_V4_PROTECTED_CALL_HPP 21 | #define BOOST_REGEX_V4_PROTECTED_CALL_HPP 22 | 23 | #include 24 | 25 | #ifdef BOOST_MSVC 26 | #pragma warning(push) 27 | #pragma warning(disable: 4103) 28 | #endif 29 | #ifdef BOOST_HAS_ABI_HEADERS 30 | # include BOOST_ABI_PREFIX 31 | #endif 32 | #ifdef BOOST_MSVC 33 | #pragma warning(pop) 34 | #endif 35 | 36 | namespace boost{ 37 | namespace BOOST_REGEX_DETAIL_NS{ 38 | 39 | class BOOST_REGEX_DECL abstract_protected_call 40 | { 41 | public: 42 | bool BOOST_REGEX_CALL execute()const; 43 | // this stops gcc-4 from complaining: 44 | virtual ~abstract_protected_call(){} 45 | private: 46 | virtual bool call()const = 0; 47 | }; 48 | 49 | template 50 | class concrete_protected_call 51 | : public abstract_protected_call 52 | { 53 | public: 54 | typedef bool (T::*proc_type)(); 55 | concrete_protected_call(T* o, proc_type p) 56 | : obj(o), proc(p) {} 57 | private: 58 | bool call()const BOOST_OVERRIDE; 59 | T* obj; 60 | proc_type proc; 61 | }; 62 | 63 | template 64 | bool concrete_protected_call::call()const 65 | { 66 | return (obj->*proc)(); 67 | } 68 | 69 | } 70 | } // namespace boost 71 | 72 | #ifdef BOOST_MSVC 73 | #pragma warning(push) 74 | #pragma warning(disable: 4103) 75 | #endif 76 | #ifdef BOOST_HAS_ABI_HEADERS 77 | # include BOOST_ABI_SUFFIX 78 | #endif 79 | #ifdef BOOST_MSVC 80 | #pragma warning(pop) 81 | #endif 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /external/boost/regex/v4/regex.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex.cpp 15 | * VERSION see 16 | * DESCRIPTION: Declares boost::basic_regex<> and associated 17 | * functions and classes. This header is the main 18 | * entry point for the template regex code. 19 | */ 20 | 21 | #ifndef BOOST_RE_REGEX_HPP_INCLUDED 22 | #define BOOST_RE_REGEX_HPP_INCLUDED 23 | 24 | #ifdef __cplusplus 25 | 26 | // what follows is all C++ don't include in C builds!! 27 | 28 | #ifndef BOOST_REGEX_CONFIG_HPP 29 | #include 30 | #endif 31 | #ifndef BOOST_REGEX_WORKAROUND_HPP 32 | #include 33 | #endif 34 | 35 | #ifndef BOOST_REGEX_FWD_HPP 36 | #include 37 | #endif 38 | #ifndef BOOST_REGEX_TRAITS_HPP 39 | #include 40 | #endif 41 | #ifndef BOOST_REGEX_RAW_BUFFER_HPP 42 | #include 43 | #endif 44 | #ifndef BOOST_REGEX_V4_MATCH_FLAGS 45 | #include 46 | #endif 47 | #ifndef BOOST_REGEX_RAW_BUFFER_HPP 48 | #include 49 | #endif 50 | #ifndef BOOST_RE_PAT_EXCEPT_HPP 51 | #include 52 | #endif 53 | 54 | #ifndef BOOST_REGEX_V4_CHAR_REGEX_TRAITS_HPP 55 | #include 56 | #endif 57 | #ifndef BOOST_REGEX_V4_STATES_HPP 58 | #include 59 | #endif 60 | #ifndef BOOST_REGEX_V4_REGBASE_HPP 61 | #include 62 | #endif 63 | #ifndef BOOST_REGEX_V4_ITERATOR_TRAITS_HPP 64 | #include 65 | #endif 66 | #ifndef BOOST_REGEX_V4_BASIC_REGEX_HPP 67 | #include 68 | #endif 69 | #ifndef BOOST_REGEX_V4_BASIC_REGEX_CREATOR_HPP 70 | #include 71 | #endif 72 | #ifndef BOOST_REGEX_V4_BASIC_REGEX_PARSER_HPP 73 | #include 74 | #endif 75 | #ifndef BOOST_REGEX_V4_SUB_MATCH_HPP 76 | #include 77 | #endif 78 | #ifndef BOOST_REGEX_FORMAT_HPP 79 | #include 80 | #endif 81 | #ifndef BOOST_REGEX_V4_MATCH_RESULTS_HPP 82 | #include 83 | #endif 84 | #ifndef BOOST_REGEX_V4_PROTECTED_CALL_HPP 85 | #include 86 | #endif 87 | #ifndef BOOST_REGEX_MATCHER_HPP 88 | #include 89 | #endif 90 | 91 | 92 | namespace boost{ 93 | #ifdef BOOST_REGEX_NO_FWD 94 | typedef basic_regex > regex; 95 | #ifndef BOOST_NO_WREGEX 96 | typedef basic_regex > wregex; 97 | #endif 98 | #endif 99 | 100 | typedef match_results cmatch; 101 | typedef match_results smatch; 102 | #ifndef BOOST_NO_WREGEX 103 | typedef match_results wcmatch; 104 | typedef match_results wsmatch; 105 | #endif 106 | 107 | } // namespace boost 108 | #ifndef BOOST_REGEX_MATCH_HPP 109 | #include 110 | #endif 111 | #ifndef BOOST_REGEX_V4_REGEX_SEARCH_HPP 112 | #include 113 | #endif 114 | #ifndef BOOST_REGEX_ITERATOR_HPP 115 | #include 116 | #endif 117 | #ifndef BOOST_REGEX_TOKEN_ITERATOR_HPP 118 | #include 119 | #endif 120 | #ifndef BOOST_REGEX_V4_REGEX_GREP_HPP 121 | #include 122 | #endif 123 | #ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP 124 | #include 125 | #endif 126 | #ifndef BOOST_REGEX_V4_REGEX_MERGE_HPP 127 | #include 128 | #endif 129 | #ifndef BOOST_REGEX_SPLIT_HPP 130 | #include 131 | #endif 132 | 133 | #endif // __cplusplus 134 | 135 | #endif // include 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /external/boost/regex/v4/regex_fwd.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_fwd.cpp 15 | * VERSION see 16 | * DESCRIPTION: Forward declares boost::basic_regex<> and 17 | * associated typedefs. 18 | */ 19 | 20 | #ifndef BOOST_REGEX_FWD_HPP_INCLUDED 21 | #define BOOST_REGEX_FWD_HPP_INCLUDED 22 | 23 | #ifndef BOOST_REGEX_CONFIG_HPP 24 | #include 25 | #endif 26 | 27 | // 28 | // define BOOST_REGEX_NO_FWD if this 29 | // header doesn't work! 30 | // 31 | #ifdef BOOST_REGEX_NO_FWD 32 | # ifndef BOOST_RE_REGEX_HPP 33 | # include 34 | # endif 35 | #else 36 | 37 | namespace boost{ 38 | 39 | template 40 | class cpp_regex_traits; 41 | template 42 | struct c_regex_traits; 43 | template 44 | class w32_regex_traits; 45 | 46 | #ifdef BOOST_REGEX_USE_WIN32_LOCALE 47 | template > 48 | struct regex_traits; 49 | #elif defined(BOOST_REGEX_USE_CPP_LOCALE) 50 | template > 51 | struct regex_traits; 52 | #else 53 | template > 54 | struct regex_traits; 55 | #endif 56 | 57 | template > 58 | class basic_regex; 59 | 60 | typedef basic_regex > regex; 61 | #ifndef BOOST_NO_WREGEX 62 | typedef basic_regex > wregex; 63 | #endif 64 | 65 | } // namespace boost 66 | 67 | #endif // BOOST_REGEX_NO_FWD 68 | 69 | #endif 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /external/boost/regex/v4/regex_merge.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_format.hpp 15 | * VERSION see 16 | * DESCRIPTION: Provides formatting output routines for search and replace 17 | * operations. Note this is an internal header file included 18 | * by regex.hpp, do not include on its own. 19 | */ 20 | 21 | #ifndef BOOST_REGEX_V4_REGEX_MERGE_HPP 22 | #define BOOST_REGEX_V4_REGEX_MERGE_HPP 23 | 24 | 25 | namespace boost{ 26 | 27 | #ifdef BOOST_MSVC 28 | #pragma warning(push) 29 | #pragma warning(disable: 4103) 30 | #endif 31 | #ifdef BOOST_HAS_ABI_HEADERS 32 | # include BOOST_ABI_PREFIX 33 | #endif 34 | #ifdef BOOST_MSVC 35 | #pragma warning(pop) 36 | #endif 37 | 38 | template 39 | inline OutputIterator regex_merge(OutputIterator out, 40 | Iterator first, 41 | Iterator last, 42 | const basic_regex& e, 43 | const charT* fmt, 44 | match_flag_type flags = match_default) 45 | { 46 | return regex_replace(out, first, last, e, fmt, flags); 47 | } 48 | 49 | template 50 | inline OutputIterator regex_merge(OutputIterator out, 51 | Iterator first, 52 | Iterator last, 53 | const basic_regex& e, 54 | const std::basic_string& fmt, 55 | match_flag_type flags = match_default) 56 | { 57 | return regex_merge(out, first, last, e, fmt.c_str(), flags); 58 | } 59 | 60 | template 61 | inline std::basic_string regex_merge(const std::basic_string& s, 62 | const basic_regex& e, 63 | const charT* fmt, 64 | match_flag_type flags = match_default) 65 | { 66 | return regex_replace(s, e, fmt, flags); 67 | } 68 | 69 | template 70 | inline std::basic_string regex_merge(const std::basic_string& s, 71 | const basic_regex& e, 72 | const std::basic_string& fmt, 73 | match_flag_type flags = match_default) 74 | { 75 | return regex_replace(s, e, fmt, flags); 76 | } 77 | 78 | #ifdef BOOST_MSVC 79 | #pragma warning(push) 80 | #pragma warning(disable: 4103) 81 | #endif 82 | #ifdef BOOST_HAS_ABI_HEADERS 83 | # include BOOST_ABI_SUFFIX 84 | #endif 85 | #ifdef BOOST_MSVC 86 | #pragma warning(pop) 87 | #endif 88 | 89 | } // namespace boost 90 | 91 | #endif // BOOST_REGEX_V4_REGEX_MERGE_HPP 92 | 93 | 94 | -------------------------------------------------------------------------------- /external/boost/regex/v4/regex_replace.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2009 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_format.hpp 15 | * VERSION see 16 | * DESCRIPTION: Provides formatting output routines for search and replace 17 | * operations. Note this is an internal header file included 18 | * by regex.hpp, do not include on its own. 19 | */ 20 | 21 | #ifndef BOOST_REGEX_V4_REGEX_REPLACE_HPP 22 | #define BOOST_REGEX_V4_REGEX_REPLACE_HPP 23 | 24 | 25 | namespace boost{ 26 | 27 | #ifdef BOOST_MSVC 28 | #pragma warning(push) 29 | #pragma warning(disable: 4103) 30 | #endif 31 | #ifdef BOOST_HAS_ABI_HEADERS 32 | # include BOOST_ABI_PREFIX 33 | #endif 34 | #ifdef BOOST_MSVC 35 | #pragma warning(pop) 36 | #endif 37 | 38 | template 39 | OutputIterator regex_replace(OutputIterator out, 40 | BidirectionalIterator first, 41 | BidirectionalIterator last, 42 | const basic_regex& e, 43 | Formatter fmt, 44 | match_flag_type flags = match_default) 45 | { 46 | regex_iterator i(first, last, e, flags); 47 | regex_iterator j; 48 | if(i == j) 49 | { 50 | if(!(flags & regex_constants::format_no_copy)) 51 | out = BOOST_REGEX_DETAIL_NS::copy(first, last, out); 52 | } 53 | else 54 | { 55 | BidirectionalIterator last_m(first); 56 | while(i != j) 57 | { 58 | if(!(flags & regex_constants::format_no_copy)) 59 | out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out); 60 | out = i->format(out, fmt, flags, e); 61 | last_m = (*i)[0].second; 62 | if(flags & regex_constants::format_first_only) 63 | break; 64 | ++i; 65 | } 66 | if(!(flags & regex_constants::format_no_copy)) 67 | out = BOOST_REGEX_DETAIL_NS::copy(last_m, last, out); 68 | } 69 | return out; 70 | } 71 | 72 | template 73 | std::basic_string regex_replace(const std::basic_string& s, 74 | const basic_regex& e, 75 | Formatter fmt, 76 | match_flag_type flags = match_default) 77 | { 78 | std::basic_string result; 79 | BOOST_REGEX_DETAIL_NS::string_out_iterator > i(result); 80 | regex_replace(i, s.begin(), s.end(), e, fmt, flags); 81 | return result; 82 | } 83 | 84 | #ifdef BOOST_MSVC 85 | #pragma warning(push) 86 | #pragma warning(disable: 4103) 87 | #endif 88 | #ifdef BOOST_HAS_ABI_HEADERS 89 | # include BOOST_ABI_SUFFIX 90 | #endif 91 | #ifdef BOOST_MSVC 92 | #pragma warning(pop) 93 | #endif 94 | 95 | } // namespace boost 96 | 97 | #endif // BOOST_REGEX_V4_REGEX_REPLACE_HPP 98 | 99 | 100 | -------------------------------------------------------------------------------- /external/boost/regex/v4/syntax_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2003 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE syntax_type.hpp 15 | * VERSION see 16 | * DESCRIPTION: Declares regular expression synatx type enumerator. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_SYNTAX_TYPE_HPP 20 | #define BOOST_REGEX_SYNTAX_TYPE_HPP 21 | 22 | namespace boost{ 23 | namespace regex_constants{ 24 | 25 | typedef unsigned char syntax_type; 26 | 27 | // 28 | // values chosen are binary compatible with previous version: 29 | // 30 | static const syntax_type syntax_char = 0; 31 | static const syntax_type syntax_open_mark = 1; 32 | static const syntax_type syntax_close_mark = 2; 33 | static const syntax_type syntax_dollar = 3; 34 | static const syntax_type syntax_caret = 4; 35 | static const syntax_type syntax_dot = 5; 36 | static const syntax_type syntax_star = 6; 37 | static const syntax_type syntax_plus = 7; 38 | static const syntax_type syntax_question = 8; 39 | static const syntax_type syntax_open_set = 9; 40 | static const syntax_type syntax_close_set = 10; 41 | static const syntax_type syntax_or = 11; 42 | static const syntax_type syntax_escape = 12; 43 | static const syntax_type syntax_dash = 14; 44 | static const syntax_type syntax_open_brace = 15; 45 | static const syntax_type syntax_close_brace = 16; 46 | static const syntax_type syntax_digit = 17; 47 | static const syntax_type syntax_comma = 27; 48 | static const syntax_type syntax_equal = 37; 49 | static const syntax_type syntax_colon = 36; 50 | static const syntax_type syntax_not = 53; 51 | 52 | // extensions: 53 | 54 | static const syntax_type syntax_hash = 13; 55 | static const syntax_type syntax_newline = 26; 56 | 57 | // escapes: 58 | 59 | typedef syntax_type escape_syntax_type; 60 | 61 | static const escape_syntax_type escape_type_word_assert = 18; 62 | static const escape_syntax_type escape_type_not_word_assert = 19; 63 | static const escape_syntax_type escape_type_control_f = 29; 64 | static const escape_syntax_type escape_type_control_n = 30; 65 | static const escape_syntax_type escape_type_control_r = 31; 66 | static const escape_syntax_type escape_type_control_t = 32; 67 | static const escape_syntax_type escape_type_control_v = 33; 68 | static const escape_syntax_type escape_type_ascii_control = 35; 69 | static const escape_syntax_type escape_type_hex = 34; 70 | static const escape_syntax_type escape_type_unicode = 0; // not used 71 | static const escape_syntax_type escape_type_identity = 0; // not used 72 | static const escape_syntax_type escape_type_backref = syntax_digit; 73 | static const escape_syntax_type escape_type_decimal = syntax_digit; // not used 74 | static const escape_syntax_type escape_type_class = 22; 75 | static const escape_syntax_type escape_type_not_class = 23; 76 | 77 | // extensions: 78 | 79 | static const escape_syntax_type escape_type_left_word = 20; 80 | static const escape_syntax_type escape_type_right_word = 21; 81 | static const escape_syntax_type escape_type_start_buffer = 24; // for \` 82 | static const escape_syntax_type escape_type_end_buffer = 25; // for \' 83 | static const escape_syntax_type escape_type_control_a = 28; // for \a 84 | static const escape_syntax_type escape_type_e = 38; // for \e 85 | static const escape_syntax_type escape_type_E = 47; // for \Q\E 86 | static const escape_syntax_type escape_type_Q = 48; // for \Q\E 87 | static const escape_syntax_type escape_type_X = 49; // for \X 88 | static const escape_syntax_type escape_type_C = 50; // for \C 89 | static const escape_syntax_type escape_type_Z = 51; // for \Z 90 | static const escape_syntax_type escape_type_G = 52; // for \G 91 | 92 | static const escape_syntax_type escape_type_property = 54; // for \p 93 | static const escape_syntax_type escape_type_not_property = 55; // for \P 94 | static const escape_syntax_type escape_type_named_char = 56; // for \N 95 | static const escape_syntax_type escape_type_extended_backref = 57; // for \g 96 | static const escape_syntax_type escape_type_reset_start_mark = 58; // for \K 97 | static const escape_syntax_type escape_type_line_ending = 59; // for \R 98 | 99 | static const escape_syntax_type syntax_max = 60; 100 | 101 | } 102 | } 103 | 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /external/boost/regex/v5/char_regex_traits.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE char_regex_traits.cpp 15 | * VERSION see 16 | * DESCRIPTION: Declares deprecated traits classes char_regex_traits<>. 17 | */ 18 | 19 | 20 | #ifndef BOOST_REGEX_V5_CHAR_REGEX_TRAITS_HPP 21 | #define BOOST_REGEX_V5_CHAR_REGEX_TRAITS_HPP 22 | 23 | namespace boost{ 24 | 25 | namespace deprecated{ 26 | // 27 | // class char_regex_traits_i 28 | // provides case insensitive traits classes (deprecated): 29 | template 30 | class char_regex_traits_i : public regex_traits {}; 31 | 32 | template<> 33 | class char_regex_traits_i : public regex_traits 34 | { 35 | public: 36 | typedef char char_type; 37 | typedef unsigned char uchar_type; 38 | typedef unsigned int size_type; 39 | typedef regex_traits base_type; 40 | 41 | }; 42 | 43 | #ifndef BOOST_NO_WREGEX 44 | template<> 45 | class char_regex_traits_i : public regex_traits 46 | { 47 | public: 48 | typedef wchar_t char_type; 49 | typedef unsigned short uchar_type; 50 | typedef unsigned int size_type; 51 | typedef regex_traits base_type; 52 | 53 | }; 54 | #endif 55 | } // namespace deprecated 56 | } // namespace boost 57 | 58 | #endif // include 59 | 60 | -------------------------------------------------------------------------------- /external/boost/regex/v5/error_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2003-2005 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE error_type.hpp 15 | * VERSION see 16 | * DESCRIPTION: Declares regular expression error type enumerator. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_ERROR_TYPE_HPP 20 | #define BOOST_REGEX_ERROR_TYPE_HPP 21 | 22 | #ifdef __cplusplus 23 | namespace boost{ 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | namespace regex_constants{ 28 | 29 | enum error_type{ 30 | 31 | error_ok = 0, /* not used */ 32 | error_no_match = 1, /* not used */ 33 | error_bad_pattern = 2, 34 | error_collate = 3, 35 | error_ctype = 4, 36 | error_escape = 5, 37 | error_backref = 6, 38 | error_brack = 7, 39 | error_paren = 8, 40 | error_brace = 9, 41 | error_badbrace = 10, 42 | error_range = 11, 43 | error_space = 12, 44 | error_badrepeat = 13, 45 | error_end = 14, /* not used */ 46 | error_size = 15, 47 | error_right_paren = 16, /* not used */ 48 | error_empty = 17, 49 | error_complexity = 18, 50 | error_stack = 19, 51 | error_perl_extension = 20, 52 | error_unknown = 21 53 | }; 54 | 55 | } 56 | } 57 | #endif /* __cplusplus */ 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /external/boost/regex/v5/iterator_category.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_match.hpp 15 | * VERSION see 16 | * DESCRIPTION: Iterator traits for selecting an iterator type as 17 | * an integral constant expression. 18 | */ 19 | 20 | 21 | #ifndef BOOST_REGEX_ITERATOR_CATEGORY_HPP 22 | #define BOOST_REGEX_ITERATOR_CATEGORY_HPP 23 | 24 | #include 25 | #include 26 | 27 | namespace boost{ 28 | namespace detail{ 29 | 30 | template 31 | struct is_random_imp 32 | { 33 | private: 34 | typedef typename std::iterator_traits::iterator_category cat; 35 | public: 36 | static const bool value = (std::is_convertible::value); 37 | }; 38 | 39 | template 40 | struct is_random_pointer_imp 41 | { 42 | static const bool value = true; 43 | }; 44 | 45 | template 46 | struct is_random_imp_selector 47 | { 48 | template 49 | struct rebind 50 | { 51 | typedef is_random_imp type; 52 | }; 53 | }; 54 | 55 | template <> 56 | struct is_random_imp_selector 57 | { 58 | template 59 | struct rebind 60 | { 61 | typedef is_random_pointer_imp type; 62 | }; 63 | }; 64 | 65 | } 66 | 67 | template 68 | struct is_random_access_iterator 69 | { 70 | private: 71 | typedef detail::is_random_imp_selector< std::is_pointer::value> selector; 72 | typedef typename selector::template rebind bound_type; 73 | typedef typename bound_type::type answer; 74 | public: 75 | static const bool value = answer::value; 76 | }; 77 | 78 | template 79 | const bool is_random_access_iterator::value; 80 | 81 | } 82 | 83 | #endif 84 | 85 | -------------------------------------------------------------------------------- /external/boost/regex/v5/iterator_traits.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE iterator_traits.cpp 15 | * VERSION see 16 | * DESCRIPTION: Declares iterator traits workarounds. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_V5_ITERATOR_TRAITS_HPP 20 | #define BOOST_REGEX_V5_ITERATOR_TRAITS_HPP 21 | 22 | namespace boost{ 23 | namespace BOOST_REGEX_DETAIL_NS{ 24 | 25 | template 26 | struct regex_iterator_traits : public std::iterator_traits {}; 27 | 28 | } // namespace BOOST_REGEX_DETAIL_NS 29 | } // namespace boost 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /external/boost/regex/v5/mem_block_cache.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 3 | * John Maddock 4 | * 5 | * Use, modification and distribution are subject to the 6 | * Boost Software License, Version 1.0. (See accompanying file 7 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | */ 10 | 11 | /* 12 | * LOCATION: see http://www.boost.org for most recent version. 13 | * FILE mem_block_cache.hpp 14 | * VERSION see 15 | * DESCRIPTION: memory block cache used by the non-recursive matcher. 16 | */ 17 | 18 | #ifndef BOOST_REGEX_V5_MEM_BLOCK_CACHE_HPP 19 | #define BOOST_REGEX_V5_MEM_BLOCK_CACHE_HPP 20 | 21 | #include 22 | #ifdef BOOST_HAS_THREADS 23 | #include 24 | #endif 25 | 26 | #ifndef BOOST_NO_CXX11_HDR_ATOMIC 27 | #include 28 | #if ATOMIC_POINTER_LOCK_FREE == 2 29 | #define BOOST_REGEX_MEM_BLOCK_CACHE_LOCK_FREE 30 | #define BOOST_REGEX_ATOMIC_POINTER std::atomic 31 | #endif 32 | #endif 33 | 34 | namespace boost{ 35 | namespace BOOST_REGEX_DETAIL_NS{ 36 | 37 | #if BOOST_REGEX_MAX_CACHE_BLOCKS != 0 38 | #ifdef BOOST_REGEX_MEM_BLOCK_CACHE_LOCK_FREE /* lock free implementation */ 39 | struct mem_block_cache 40 | { 41 | std::atomic cache[BOOST_REGEX_MAX_CACHE_BLOCKS]; 42 | 43 | ~mem_block_cache() 44 | { 45 | for (size_t i = 0;i < BOOST_REGEX_MAX_CACHE_BLOCKS; ++i) { 46 | if (cache[i].load()) ::operator delete(cache[i].load()); 47 | } 48 | } 49 | void* get() 50 | { 51 | for (size_t i = 0;i < BOOST_REGEX_MAX_CACHE_BLOCKS; ++i) { 52 | void* p = cache[i].load(); 53 | if (p != NULL) { 54 | if (cache[i].compare_exchange_strong(p, NULL)) return p; 55 | } 56 | } 57 | return ::operator new(BOOST_REGEX_BLOCKSIZE); 58 | } 59 | void put(void* ptr) 60 | { 61 | for (size_t i = 0;i < BOOST_REGEX_MAX_CACHE_BLOCKS; ++i) { 62 | void* p = cache[i].load(); 63 | if (p == NULL) { 64 | if (cache[i].compare_exchange_strong(p, ptr)) return; 65 | } 66 | } 67 | ::operator delete(ptr); 68 | } 69 | 70 | static mem_block_cache& instance() 71 | { 72 | static mem_block_cache block_cache = { { {nullptr} } }; 73 | return block_cache; 74 | } 75 | }; 76 | 77 | 78 | #else /* lock-based implementation */ 79 | 80 | 81 | struct mem_block_node 82 | { 83 | mem_block_node* next; 84 | }; 85 | 86 | struct mem_block_cache 87 | { 88 | // this member has to be statically initialsed: 89 | mem_block_node* next { nullptr }; 90 | unsigned cached_blocks { 0 }; 91 | #ifdef BOOST_HAS_THREADS 92 | std::mutex mut; 93 | #endif 94 | 95 | ~mem_block_cache() 96 | { 97 | while(next) 98 | { 99 | mem_block_node* old = next; 100 | next = next->next; 101 | ::operator delete(old); 102 | } 103 | } 104 | void* get() 105 | { 106 | #ifdef BOOST_HAS_THREADS 107 | std::lock_guard g(mut); 108 | #endif 109 | if(next) 110 | { 111 | mem_block_node* result = next; 112 | next = next->next; 113 | --cached_blocks; 114 | return result; 115 | } 116 | return ::operator new(BOOST_REGEX_BLOCKSIZE); 117 | } 118 | void put(void* p) 119 | { 120 | #ifdef BOOST_HAS_THREADS 121 | std::lock_guard g(mut); 122 | #endif 123 | if(cached_blocks >= BOOST_REGEX_MAX_CACHE_BLOCKS) 124 | { 125 | ::operator delete(p); 126 | } 127 | else 128 | { 129 | mem_block_node* old = static_cast(p); 130 | old->next = next; 131 | next = old; 132 | ++cached_blocks; 133 | } 134 | } 135 | static mem_block_cache& instance() 136 | { 137 | static mem_block_cache block_cache; 138 | return block_cache; 139 | } 140 | }; 141 | #endif 142 | #endif 143 | 144 | #if BOOST_REGEX_MAX_CACHE_BLOCKS == 0 145 | 146 | inline void* get_mem_block() 147 | { 148 | return ::operator new(BOOST_REGEX_BLOCKSIZE); 149 | } 150 | 151 | inline void put_mem_block(void* p) 152 | { 153 | ::operator delete(p); 154 | } 155 | 156 | #else 157 | 158 | inline void* get_mem_block() 159 | { 160 | return mem_block_cache::instance().get(); 161 | } 162 | 163 | inline void put_mem_block(void* p) 164 | { 165 | mem_block_cache::instance().put(p); 166 | } 167 | 168 | #endif 169 | } 170 | } // namespace boost 171 | 172 | #endif 173 | 174 | -------------------------------------------------------------------------------- /external/boost/regex/v5/pattern_except.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE pattern_except.hpp 15 | * VERSION see 16 | * DESCRIPTION: Declares pattern-matching exception classes. 17 | */ 18 | 19 | #ifndef BOOST_RE_V5_PAT_EXCEPT_HPP 20 | #define BOOST_RE_V5_PAT_EXCEPT_HPP 21 | 22 | #ifndef BOOST_REGEX_CONFIG_HPP 23 | #include 24 | #endif 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace boost{ 32 | 33 | #ifdef BOOST_REGEX_MSVC 34 | #pragma warning(push) 35 | #pragma warning(disable : 4275) 36 | #if BOOST_REGEX_MSVC >= 1800 37 | #pragma warning(disable : 26812 4459) 38 | #endif 39 | #endif 40 | class regex_error : public std::runtime_error 41 | { 42 | public: 43 | explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0) 44 | : std::runtime_error(s) 45 | , m_error_code(err) 46 | , m_position(pos) 47 | { 48 | } 49 | explicit regex_error(regex_constants::error_type err) 50 | : std::runtime_error(::boost::BOOST_REGEX_DETAIL_NS::get_default_error_string(err)) 51 | , m_error_code(err) 52 | , m_position(0) 53 | { 54 | } 55 | ~regex_error() noexcept override {} 56 | regex_constants::error_type code()const 57 | { return m_error_code; } 58 | std::ptrdiff_t position()const 59 | { return m_position; } 60 | void raise()const 61 | { 62 | #ifndef BOOST_NO_EXCEPTIONS 63 | #ifndef BOOST_REGEX_STANDALONE 64 | ::boost::throw_exception(*this); 65 | #else 66 | throw* this; 67 | #endif 68 | #endif 69 | } 70 | private: 71 | regex_constants::error_type m_error_code; 72 | std::ptrdiff_t m_position; 73 | }; 74 | 75 | typedef regex_error bad_pattern; 76 | typedef regex_error bad_expression; 77 | 78 | namespace BOOST_REGEX_DETAIL_NS{ 79 | 80 | template 81 | inline void raise_runtime_error(const E& ex) 82 | { 83 | #ifndef BOOST_REGEX_STANDALONE 84 | ::boost::throw_exception(ex); 85 | #else 86 | throw ex; 87 | #endif 88 | } 89 | 90 | template 91 | void raise_error(const traits& t, regex_constants::error_type code) 92 | { 93 | (void)t; // warning suppression 94 | regex_error e(t.error_string(code), code, 0); 95 | ::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(e); 96 | } 97 | 98 | } 99 | 100 | #ifdef BOOST_REGEX_MSVC 101 | #pragma warning(pop) 102 | #endif 103 | 104 | } // namespace boost 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /external/boost/regex/v5/primary_transform.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE: primary_transform.hpp 15 | * VERSION: see 16 | * DESCRIPTION: Heuristically determines the sort string format in use 17 | * by the current locale. 18 | */ 19 | 20 | #ifndef BOOST_REGEX_PRIMARY_TRANSFORM 21 | #define BOOST_REGEX_PRIMARY_TRANSFORM 22 | 23 | namespace boost{ 24 | namespace BOOST_REGEX_DETAIL_NS{ 25 | 26 | 27 | enum{ 28 | sort_C, 29 | sort_fixed, 30 | sort_delim, 31 | sort_unknown 32 | }; 33 | 34 | template 35 | unsigned count_chars(const S& s, charT c) 36 | { 37 | // 38 | // Count how many occurrences of character c occur 39 | // in string s: if c is a delimeter between collation 40 | // fields, then this should be the same value for all 41 | // sort keys: 42 | // 43 | unsigned int count = 0; 44 | for(unsigned pos = 0; pos < s.size(); ++pos) 45 | { 46 | if(s[pos] == c) ++count; 47 | } 48 | return count; 49 | } 50 | 51 | 52 | template 53 | unsigned find_sort_syntax(const traits* pt, charT* delim) 54 | { 55 | // 56 | // compare 'a' with 'A' to see how similar they are, 57 | // should really use a-accute but we can't portably do that, 58 | // 59 | typedef typename traits::string_type string_type; 60 | typedef typename traits::char_type char_type; 61 | 62 | // Suppress incorrect warning for MSVC 63 | (void)pt; 64 | 65 | char_type a[2] = {'a', '\0', }; 66 | string_type sa(pt->transform(a, a+1)); 67 | if(sa == a) 68 | { 69 | *delim = 0; 70 | return sort_C; 71 | } 72 | char_type A[2] = { 'A', '\0', }; 73 | string_type sA(pt->transform(A, A+1)); 74 | char_type c[2] = { ';', '\0', }; 75 | string_type sc(pt->transform(c, c+1)); 76 | 77 | int pos = 0; 78 | while((pos <= static_cast(sa.size())) && (pos <= static_cast(sA.size())) && (sa[pos] == sA[pos])) ++pos; 79 | --pos; 80 | if(pos < 0) 81 | { 82 | *delim = 0; 83 | return sort_unknown; 84 | } 85 | // 86 | // at this point sa[pos] is either the end of a fixed width field 87 | // or the character that acts as a delimiter: 88 | // 89 | charT maybe_delim = sa[pos]; 90 | if((pos != 0) && (count_chars(sa, maybe_delim) == count_chars(sA, maybe_delim)) && (count_chars(sa, maybe_delim) == count_chars(sc, maybe_delim))) 91 | { 92 | *delim = maybe_delim; 93 | return sort_delim; 94 | } 95 | // 96 | // OK doen't look like a delimiter, try for fixed width field: 97 | // 98 | if((sa.size() == sA.size()) && (sa.size() == sc.size())) 99 | { 100 | // note assumes that the fixed width field is less than 101 | // (numeric_limits::max)(), should be true for all types 102 | // I can't imagine 127 character fields... 103 | *delim = static_cast(++pos); 104 | return sort_fixed; 105 | } 106 | // 107 | // don't know what it is: 108 | // 109 | *delim = 0; 110 | return sort_unknown; 111 | } 112 | 113 | 114 | } // namespace BOOST_REGEX_DETAIL_NS 115 | } // namespace boost 116 | 117 | #endif 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /external/boost/regex/v5/regex.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex.cpp 15 | * VERSION see 16 | * DESCRIPTION: Declares boost::basic_regex<> and associated 17 | * functions and classes. This header is the main 18 | * entry point for the template regex code. 19 | */ 20 | 21 | #ifndef BOOST_RE_REGEX_HPP_INCLUDED 22 | #define BOOST_RE_REGEX_HPP_INCLUDED 23 | 24 | #ifdef __cplusplus 25 | 26 | // what follows is all C++ don't include in C builds!! 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | namespace boost{ 48 | #ifdef BOOST_REGEX_NO_FWD 49 | typedef basic_regex > regex; 50 | #ifndef BOOST_NO_WREGEX 51 | typedef basic_regex > wregex; 52 | #endif 53 | #endif 54 | 55 | typedef match_results cmatch; 56 | typedef match_results smatch; 57 | #ifndef BOOST_NO_WREGEX 58 | typedef match_results wcmatch; 59 | typedef match_results wsmatch; 60 | #endif 61 | 62 | } // namespace boost 63 | 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | 73 | #endif // __cplusplus 74 | 75 | #endif // include 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /external/boost/regex/v5/regex_fwd.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_fwd.cpp 15 | * VERSION see 16 | * DESCRIPTION: Forward declares boost::basic_regex<> and 17 | * associated typedefs. 18 | */ 19 | 20 | #ifndef BOOST_REGEX_FWD_HPP_INCLUDED 21 | #define BOOST_REGEX_FWD_HPP_INCLUDED 22 | 23 | #ifndef BOOST_REGEX_CONFIG_HPP 24 | #include 25 | #endif 26 | 27 | // 28 | // define BOOST_REGEX_NO_FWD if this 29 | // header doesn't work! 30 | // 31 | #ifdef BOOST_REGEX_NO_FWD 32 | # ifndef BOOST_RE_REGEX_HPP 33 | # include 34 | # endif 35 | #else 36 | 37 | namespace boost{ 38 | 39 | template 40 | class cpp_regex_traits; 41 | template 42 | struct c_regex_traits; 43 | template 44 | class w32_regex_traits; 45 | 46 | #ifdef BOOST_REGEX_USE_WIN32_LOCALE 47 | template > 48 | struct regex_traits; 49 | #elif defined(BOOST_REGEX_USE_CPP_LOCALE) 50 | template > 51 | struct regex_traits; 52 | #else 53 | template > 54 | struct regex_traits; 55 | #endif 56 | 57 | template > 58 | class basic_regex; 59 | 60 | typedef basic_regex > regex; 61 | #ifndef BOOST_NO_WREGEX 62 | typedef basic_regex > wregex; 63 | #endif 64 | 65 | } // namespace boost 66 | 67 | #endif // BOOST_REGEX_NO_FWD 68 | 69 | #endif 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /external/boost/regex/v5/regex_grep.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_grep.hpp 15 | * VERSION see 16 | * DESCRIPTION: Provides regex_grep implementation. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_V5_REGEX_GREP_HPP 20 | #define BOOST_REGEX_V5_REGEX_GREP_HPP 21 | 22 | 23 | namespace boost{ 24 | 25 | // 26 | // regex_grep: 27 | // find all non-overlapping matches within the sequence first last: 28 | // 29 | template 30 | inline unsigned int regex_grep(Predicate foo, 31 | BidiIterator first, 32 | BidiIterator last, 33 | const basic_regex& e, 34 | match_flag_type flags = match_default) 35 | { 36 | if(e.flags() & regex_constants::failbit) 37 | return false; 38 | 39 | typedef typename match_results::allocator_type match_allocator_type; 40 | 41 | match_results m; 42 | BOOST_REGEX_DETAIL_NS::perl_matcher matcher(first, last, m, e, flags, first); 43 | unsigned int count = 0; 44 | while(matcher.find()) 45 | { 46 | ++count; 47 | if(0 == foo(m)) 48 | return count; // caller doesn't want to go on 49 | if(m[0].second == last) 50 | return count; // we've reached the end, don't try and find an extra null match. 51 | if(m.length() == 0) 52 | { 53 | if(m[0].second == last) 54 | return count; 55 | // we found a NULL-match, now try to find 56 | // a non-NULL one at the same position: 57 | match_results m2(m); 58 | matcher.setf(match_not_null | match_continuous); 59 | if(matcher.find()) 60 | { 61 | ++count; 62 | if(0 == foo(m)) 63 | return count; 64 | } 65 | else 66 | { 67 | // reset match back to where it was: 68 | m = m2; 69 | } 70 | matcher.unsetf((match_not_null | match_continuous) & ~flags); 71 | } 72 | } 73 | return count; 74 | } 75 | 76 | // 77 | // regex_grep convenience interfaces: 78 | // 79 | template 80 | inline unsigned int regex_grep(Predicate foo, const charT* str, 81 | const basic_regex& e, 82 | match_flag_type flags = match_default) 83 | { 84 | return regex_grep(foo, str, str + traits::length(str), e, flags); 85 | } 86 | 87 | template 88 | inline unsigned int regex_grep(Predicate foo, const std::basic_string& s, 89 | const basic_regex& e, 90 | match_flag_type flags = match_default) 91 | { 92 | return regex_grep(foo, s.begin(), s.end(), e, flags); 93 | } 94 | 95 | } // namespace boost 96 | 97 | #endif // BOOST_REGEX_V5_REGEX_GREP_HPP 98 | 99 | -------------------------------------------------------------------------------- /external/boost/regex/v5/regex_match.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_match.hpp 15 | * VERSION see 16 | * DESCRIPTION: Regular expression matching algorithms. 17 | * Note this is an internal header file included 18 | * by regex.hpp, do not include on its own. 19 | */ 20 | 21 | 22 | #ifndef BOOST_REGEX_MATCH_HPP 23 | #define BOOST_REGEX_MATCH_HPP 24 | 25 | namespace boost{ 26 | 27 | // 28 | // proc regex_match 29 | // returns true if the specified regular expression matches 30 | // the whole of the input. Fills in what matched in m. 31 | // 32 | template 33 | bool regex_match(BidiIterator first, BidiIterator last, 34 | match_results& m, 35 | const basic_regex& e, 36 | match_flag_type flags = match_default) 37 | { 38 | BOOST_REGEX_DETAIL_NS::perl_matcher matcher(first, last, m, e, flags, first); 39 | return matcher.match(); 40 | } 41 | template 42 | bool regex_match(iterator first, iterator last, 43 | const basic_regex& e, 44 | match_flag_type flags = match_default) 45 | { 46 | match_results m; 47 | return regex_match(first, last, m, e, flags | regex_constants::match_any); 48 | } 49 | // 50 | // query_match convenience interfaces: 51 | // 52 | template 53 | inline bool regex_match(const charT* str, 54 | match_results& m, 55 | const basic_regex& e, 56 | match_flag_type flags = match_default) 57 | { 58 | return regex_match(str, str + traits::length(str), m, e, flags); 59 | } 60 | 61 | template 62 | inline bool regex_match(const std::basic_string& s, 63 | match_results::const_iterator, Allocator>& m, 64 | const basic_regex& e, 65 | match_flag_type flags = match_default) 66 | { 67 | return regex_match(s.begin(), s.end(), m, e, flags); 68 | } 69 | template 70 | inline bool regex_match(const charT* str, 71 | const basic_regex& e, 72 | match_flag_type flags = match_default) 73 | { 74 | match_results m; 75 | return regex_match(str, str + traits::length(str), m, e, flags | regex_constants::match_any); 76 | } 77 | 78 | template 79 | inline bool regex_match(const std::basic_string& s, 80 | const basic_regex& e, 81 | match_flag_type flags = match_default) 82 | { 83 | typedef typename std::basic_string::const_iterator iterator; 84 | match_results m; 85 | return regex_match(s.begin(), s.end(), m, e, flags | regex_constants::match_any); 86 | } 87 | 88 | 89 | } // namespace boost 90 | 91 | #endif // BOOST_REGEX_MATCH_HPP 92 | 93 | -------------------------------------------------------------------------------- /external/boost/regex/v5/regex_merge.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_format.hpp 15 | * VERSION see 16 | * DESCRIPTION: Provides formatting output routines for search and replace 17 | * operations. Note this is an internal header file included 18 | * by regex.hpp, do not include on its own. 19 | */ 20 | 21 | #ifndef BOOST_REGEX_V5_REGEX_MERGE_HPP 22 | #define BOOST_REGEX_V5_REGEX_MERGE_HPP 23 | 24 | 25 | namespace boost{ 26 | 27 | template 28 | inline OutputIterator regex_merge(OutputIterator out, 29 | Iterator first, 30 | Iterator last, 31 | const basic_regex& e, 32 | const charT* fmt, 33 | match_flag_type flags = match_default) 34 | { 35 | return regex_replace(out, first, last, e, fmt, flags); 36 | } 37 | 38 | template 39 | inline OutputIterator regex_merge(OutputIterator out, 40 | Iterator first, 41 | Iterator last, 42 | const basic_regex& e, 43 | const std::basic_string& fmt, 44 | match_flag_type flags = match_default) 45 | { 46 | return regex_merge(out, first, last, e, fmt.c_str(), flags); 47 | } 48 | 49 | template 50 | inline std::basic_string regex_merge(const std::basic_string& s, 51 | const basic_regex& e, 52 | const charT* fmt, 53 | match_flag_type flags = match_default) 54 | { 55 | return regex_replace(s, e, fmt, flags); 56 | } 57 | 58 | template 59 | inline std::basic_string regex_merge(const std::basic_string& s, 60 | const basic_regex& e, 61 | const std::basic_string& fmt, 62 | match_flag_type flags = match_default) 63 | { 64 | return regex_replace(s, e, fmt, flags); 65 | } 66 | 67 | } // namespace boost 68 | 69 | #endif // BOOST_REGEX_V5_REGEX_MERGE_HPP 70 | 71 | 72 | -------------------------------------------------------------------------------- /external/boost/regex/v5/regex_raw_buffer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_raw_buffer.hpp 15 | * VERSION see 16 | * DESCRIPTION: Raw character buffer for regex code. 17 | * Note this is an internal header file included 18 | * by regex.hpp, do not include on its own. 19 | */ 20 | 21 | #ifndef BOOST_REGEX_RAW_BUFFER_HPP 22 | #define BOOST_REGEX_RAW_BUFFER_HPP 23 | 24 | #ifndef BOOST_REGEX_CONFIG_HPP 25 | #include 26 | #endif 27 | 28 | #include 29 | #include 30 | 31 | namespace boost{ 32 | namespace BOOST_REGEX_DETAIL_NS{ 33 | 34 | struct empty_padding{}; 35 | 36 | union padding 37 | { 38 | void* p; 39 | unsigned int i; 40 | }; 41 | 42 | template 43 | struct padding3 44 | { 45 | enum{ 46 | padding_size = 8, 47 | padding_mask = 7 48 | }; 49 | }; 50 | 51 | template<> 52 | struct padding3<2> 53 | { 54 | enum{ 55 | padding_size = 2, 56 | padding_mask = 1 57 | }; 58 | }; 59 | 60 | template<> 61 | struct padding3<4> 62 | { 63 | enum{ 64 | padding_size = 4, 65 | padding_mask = 3 66 | }; 67 | }; 68 | 69 | template<> 70 | struct padding3<8> 71 | { 72 | enum{ 73 | padding_size = 8, 74 | padding_mask = 7 75 | }; 76 | }; 77 | 78 | template<> 79 | struct padding3<16> 80 | { 81 | enum{ 82 | padding_size = 16, 83 | padding_mask = 15 84 | }; 85 | }; 86 | 87 | enum{ 88 | padding_size = padding3::padding_size, 89 | padding_mask = padding3::padding_mask 90 | }; 91 | 92 | // 93 | // class raw_storage 94 | // basically this is a simplified vector 95 | // this is used by basic_regex for expression storage 96 | // 97 | 98 | class raw_storage 99 | { 100 | public: 101 | typedef std::size_t size_type; 102 | typedef unsigned char* pointer; 103 | private: 104 | pointer last, start, end; 105 | public: 106 | 107 | raw_storage(); 108 | raw_storage(size_type n); 109 | 110 | ~raw_storage() 111 | { 112 | ::operator delete(start); 113 | } 114 | 115 | void resize(size_type n) 116 | { 117 | size_type newsize = start ? last - start : 1024; 118 | while (newsize < n) 119 | newsize *= 2; 120 | size_type datasize = end - start; 121 | // extend newsize to WORD/DWORD boundary: 122 | newsize = (newsize + padding_mask) & ~(padding_mask); 123 | 124 | // allocate and copy data: 125 | pointer ptr = static_cast(::operator new(newsize)); 126 | BOOST_REGEX_NOEH_ASSERT(ptr) 127 | if (start) 128 | std::memcpy(ptr, start, datasize); 129 | 130 | // get rid of old buffer: 131 | ::operator delete(start); 132 | 133 | // and set up pointers: 134 | start = ptr; 135 | end = ptr + datasize; 136 | last = ptr + newsize; 137 | } 138 | 139 | void* extend(size_type n) 140 | { 141 | if(size_type(last - end) < n) 142 | resize(n + (end - start)); 143 | pointer result = end; 144 | end += n; 145 | return result; 146 | } 147 | 148 | void* insert(size_type pos, size_type n) 149 | { 150 | BOOST_REGEX_ASSERT(pos <= size_type(end - start)); 151 | if (size_type(last - end) < n) 152 | resize(n + (end - start)); 153 | void* result = start + pos; 154 | std::memmove(start + pos + n, start + pos, (end - start) - pos); 155 | end += n; 156 | return result; 157 | } 158 | 159 | size_type size() 160 | { 161 | return size_type(end - start); 162 | } 163 | 164 | size_type capacity() 165 | { 166 | return size_type(last - start); 167 | } 168 | 169 | void* data()const 170 | { 171 | return start; 172 | } 173 | 174 | size_type index(void* ptr) 175 | { 176 | return size_type(static_cast(ptr) - static_cast(data())); 177 | } 178 | 179 | void clear() 180 | { 181 | end = start; 182 | } 183 | 184 | void align() 185 | { 186 | // move end up to a boundary: 187 | end = start + (((end - start) + padding_mask) & ~padding_mask); 188 | } 189 | void swap(raw_storage& that) 190 | { 191 | std::swap(start, that.start); 192 | std::swap(end, that.end); 193 | std::swap(last, that.last); 194 | } 195 | }; 196 | 197 | inline raw_storage::raw_storage() 198 | { 199 | last = start = end = 0; 200 | } 201 | 202 | inline raw_storage::raw_storage(size_type n) 203 | { 204 | start = end = static_cast(::operator new(n)); 205 | BOOST_REGEX_NOEH_ASSERT(start) 206 | last = start + n; 207 | } 208 | 209 | } // namespace BOOST_REGEX_DETAIL_NS 210 | } // namespace boost 211 | 212 | #endif 213 | 214 | -------------------------------------------------------------------------------- /external/boost/regex/v5/regex_replace.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2009 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_format.hpp 15 | * VERSION see 16 | * DESCRIPTION: Provides formatting output routines for search and replace 17 | * operations. Note this is an internal header file included 18 | * by regex.hpp, do not include on its own. 19 | */ 20 | 21 | #ifndef BOOST_REGEX_V5_REGEX_REPLACE_HPP 22 | #define BOOST_REGEX_V5_REGEX_REPLACE_HPP 23 | 24 | 25 | namespace boost{ 26 | 27 | template 28 | OutputIterator regex_replace(OutputIterator out, 29 | BidirectionalIterator first, 30 | BidirectionalIterator last, 31 | const basic_regex& e, 32 | Formatter fmt, 33 | match_flag_type flags = match_default) 34 | { 35 | regex_iterator i(first, last, e, flags); 36 | regex_iterator j; 37 | if(i == j) 38 | { 39 | if(!(flags & regex_constants::format_no_copy)) 40 | out = BOOST_REGEX_DETAIL_NS::copy(first, last, out); 41 | } 42 | else 43 | { 44 | BidirectionalIterator last_m(first); 45 | while(i != j) 46 | { 47 | if(!(flags & regex_constants::format_no_copy)) 48 | out = BOOST_REGEX_DETAIL_NS::copy(i->prefix().first, i->prefix().second, out); 49 | out = i->format(out, fmt, flags, e); 50 | last_m = (*i)[0].second; 51 | if(flags & regex_constants::format_first_only) 52 | break; 53 | ++i; 54 | } 55 | if(!(flags & regex_constants::format_no_copy)) 56 | out = BOOST_REGEX_DETAIL_NS::copy(last_m, last, out); 57 | } 58 | return out; 59 | } 60 | 61 | template 62 | std::basic_string regex_replace(const std::basic_string& s, 63 | const basic_regex& e, 64 | Formatter fmt, 65 | match_flag_type flags = match_default) 66 | { 67 | std::basic_string result; 68 | BOOST_REGEX_DETAIL_NS::string_out_iterator > i(result); 69 | regex_replace(i, s.begin(), s.end(), e, fmt, flags); 70 | return result; 71 | } 72 | 73 | } // namespace boost 74 | 75 | #endif // BOOST_REGEX_V5_REGEX_REPLACE_HPP 76 | 77 | 78 | -------------------------------------------------------------------------------- /external/boost/regex/v5/regex_search.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_search.hpp 15 | * VERSION see 16 | * DESCRIPTION: Provides regex_search implementation. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_V5_REGEX_SEARCH_HPP 20 | #define BOOST_REGEX_V5_REGEX_SEARCH_HPP 21 | 22 | 23 | namespace boost{ 24 | 25 | template 26 | bool regex_search(BidiIterator first, BidiIterator last, 27 | match_results& m, 28 | const basic_regex& e, 29 | match_flag_type flags = match_default) 30 | { 31 | return regex_search(first, last, m, e, flags, first); 32 | } 33 | 34 | template 35 | bool regex_search(BidiIterator first, BidiIterator last, 36 | match_results& m, 37 | const basic_regex& e, 38 | match_flag_type flags, 39 | BidiIterator base) 40 | { 41 | if(e.flags() & regex_constants::failbit) 42 | return false; 43 | 44 | BOOST_REGEX_DETAIL_NS::perl_matcher matcher(first, last, m, e, flags, base); 45 | return matcher.find(); 46 | } 47 | 48 | // 49 | // regex_search convenience interfaces: 50 | // 51 | template 52 | inline bool regex_search(const charT* str, 53 | match_results& m, 54 | const basic_regex& e, 55 | match_flag_type flags = match_default) 56 | { 57 | return regex_search(str, str + traits::length(str), m, e, flags); 58 | } 59 | 60 | template 61 | inline bool regex_search(const std::basic_string& s, 62 | match_results::const_iterator, Allocator>& m, 63 | const basic_regex& e, 64 | match_flag_type flags = match_default) 65 | { 66 | return regex_search(s.begin(), s.end(), m, e, flags); 67 | } 68 | 69 | template 70 | bool regex_search(BidiIterator first, BidiIterator last, 71 | const basic_regex& e, 72 | match_flag_type flags = match_default) 73 | { 74 | if(e.flags() & regex_constants::failbit) 75 | return false; 76 | 77 | match_results m; 78 | typedef typename match_results::allocator_type match_alloc_type; 79 | BOOST_REGEX_DETAIL_NS::perl_matcher matcher(first, last, m, e, flags | regex_constants::match_any, first); 80 | return matcher.find(); 81 | } 82 | 83 | template 84 | inline bool regex_search(const charT* str, 85 | const basic_regex& e, 86 | match_flag_type flags = match_default) 87 | { 88 | return regex_search(str, str + traits::length(str), e, flags); 89 | } 90 | 91 | template 92 | inline bool regex_search(const std::basic_string& s, 93 | const basic_regex& e, 94 | match_flag_type flags = match_default) 95 | { 96 | return regex_search(s.begin(), s.end(), e, flags); 97 | } 98 | 99 | } // namespace boost 100 | 101 | #endif // BOOST_REGEX_V5_REGEX_SEARCH_HPP 102 | 103 | 104 | -------------------------------------------------------------------------------- /external/boost/regex/v5/regex_split.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_split.hpp 15 | * VERSION see 16 | * DESCRIPTION: Implements regex_split and associated functions. 17 | * Note this is an internal header file included 18 | * by regex.hpp, do not include on its own. 19 | */ 20 | 21 | #ifndef BOOST_REGEX_SPLIT_HPP 22 | #define BOOST_REGEX_SPLIT_HPP 23 | 24 | namespace boost{ 25 | 26 | #ifdef BOOST_REGEX_MSVC 27 | # pragma warning(push) 28 | #if BOOST_REGEX_MSVC < 1910 29 | #pragma warning(disable:4800) 30 | #endif 31 | #endif 32 | 33 | namespace BOOST_REGEX_DETAIL_NS{ 34 | 35 | template 36 | const basic_regex& get_default_expression(charT) 37 | { 38 | static const charT expression_text[4] = { '\\', 's', '+', '\00', }; 39 | static const basic_regex e(expression_text); 40 | return e; 41 | } 42 | 43 | template 44 | class split_pred 45 | { 46 | typedef std::basic_string string_type; 47 | typedef typename string_type::const_iterator iterator_type; 48 | iterator_type* p_last; 49 | OutputIterator* p_out; 50 | std::size_t* p_max; 51 | std::size_t initial_max; 52 | public: 53 | split_pred(iterator_type* a, OutputIterator* b, std::size_t* c) 54 | : p_last(a), p_out(b), p_max(c), initial_max(*c) {} 55 | 56 | bool operator()(const match_results& what); 57 | }; 58 | 59 | template 60 | bool split_pred::operator() 61 | (const match_results& what) 62 | { 63 | *p_last = what[0].second; 64 | if(what.size() > 1) 65 | { 66 | // output sub-expressions only: 67 | for(unsigned i = 1; i < what.size(); ++i) 68 | { 69 | *(*p_out) = what.str(i); 70 | ++(*p_out); 71 | if(0 == --*p_max) return false; 72 | } 73 | return *p_max != 0; 74 | } 75 | else 76 | { 77 | // output $` only if it's not-null or not at the start of the input: 78 | const sub_match& sub = what[-1]; 79 | if((sub.first != sub.second) || (*p_max != initial_max)) 80 | { 81 | *(*p_out) = sub.str(); 82 | ++(*p_out); 83 | return --*p_max; 84 | } 85 | } 86 | // 87 | // initial null, do nothing: 88 | return true; 89 | } 90 | 91 | } // namespace BOOST_REGEX_DETAIL_NS 92 | 93 | template 94 | std::size_t regex_split(OutputIterator out, 95 | std::basic_string& s, 96 | const basic_regex& e, 97 | match_flag_type flags, 98 | std::size_t max_split) 99 | { 100 | typedef typename std::basic_string::const_iterator ci_t; 101 | //typedef typename match_results::allocator_type match_allocator; 102 | ci_t last = s.begin(); 103 | std::size_t init_size = max_split; 104 | BOOST_REGEX_DETAIL_NS::split_pred pred(&last, &out, &max_split); 105 | ci_t i, j; 106 | i = s.begin(); 107 | j = s.end(); 108 | regex_grep(pred, i, j, e, flags); 109 | // 110 | // if there is still input left, do a final push as long as max_split 111 | // is not exhausted, and we're not splitting sub-expressions rather 112 | // than whitespace: 113 | if(max_split && (last != s.end()) && (e.mark_count() == 0)) 114 | { 115 | *out = std::basic_string((ci_t)last, (ci_t)s.end()); 116 | ++out; 117 | last = s.end(); 118 | --max_split; 119 | } 120 | // 121 | // delete from the string everything that has been processed so far: 122 | s.erase(0, last - s.begin()); 123 | // 124 | // return the number of new records pushed: 125 | return init_size - max_split; 126 | } 127 | 128 | template 129 | inline std::size_t regex_split(OutputIterator out, 130 | std::basic_string& s, 131 | const basic_regex& e, 132 | match_flag_type flags = match_default) 133 | { 134 | return regex_split(out, s, e, flags, UINT_MAX); 135 | } 136 | 137 | template 138 | inline std::size_t regex_split(OutputIterator out, 139 | std::basic_string& s) 140 | { 141 | return regex_split(out, s, BOOST_REGEX_DETAIL_NS::get_default_expression(charT(0)), match_default, UINT_MAX); 142 | } 143 | 144 | #ifdef BOOST_REGEX_MSVC 145 | # pragma warning(pop) 146 | #endif 147 | 148 | } // namespace boost 149 | 150 | #endif 151 | 152 | 153 | -------------------------------------------------------------------------------- /external/boost/regex/v5/regex_traits.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2003 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_traits.hpp 15 | * VERSION see 16 | * DESCRIPTION: Declares regular expression traits classes. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_TRAITS_HPP_INCLUDED 20 | #define BOOST_REGEX_TRAITS_HPP_INCLUDED 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #if defined(_WIN32) && !defined(BOOST_REGEX_NO_W32) 30 | # include 31 | #endif 32 | #include 33 | 34 | namespace boost{ 35 | 36 | template 37 | struct regex_traits : public implementationT 38 | { 39 | regex_traits() : implementationT() {} 40 | }; 41 | 42 | // 43 | // class regex_traits_wrapper. 44 | // this is what our implementation will actually store; 45 | // it provides default implementations of the "optional" 46 | // interfaces that we support, in addition to the 47 | // required "standard" ones: 48 | // 49 | namespace BOOST_REGEX_DETAIL_NS{ 50 | 51 | template 52 | struct has_boost_extensions_tag 53 | { 54 | template 55 | static double checker(U*, typename U::boost_extensions_tag* = nullptr); 56 | static char checker(...); 57 | static T* get(); 58 | 59 | static const bool value = sizeof(checker(get())) > 1; 60 | }; 61 | 62 | 63 | template 64 | struct default_wrapper : public BaseT 65 | { 66 | typedef typename BaseT::char_type char_type; 67 | std::string error_string(::boost::regex_constants::error_type e)const 68 | { 69 | return ::boost::BOOST_REGEX_DETAIL_NS::get_default_error_string(e); 70 | } 71 | ::boost::regex_constants::syntax_type syntax_type(char_type c)const 72 | { 73 | return (char_type(c & 0x7f) == c) ? get_default_syntax_type(static_cast(c)) : ::boost::regex_constants::syntax_char; 74 | } 75 | ::boost::regex_constants::escape_syntax_type escape_syntax_type(char_type c)const 76 | { 77 | return (char_type(c & 0x7f) == c) ? get_default_escape_syntax_type(static_cast(c)) : ::boost::regex_constants::escape_type_identity; 78 | } 79 | std::intmax_t toi(const char_type*& p1, const char_type* p2, int radix)const 80 | { 81 | return ::boost::BOOST_REGEX_DETAIL_NS::global_toi(p1, p2, radix, *this); 82 | } 83 | char_type translate(char_type c, bool icase)const 84 | { 85 | return (icase ? this->translate_nocase(c) : this->translate(c)); 86 | } 87 | char_type translate(char_type c)const 88 | { 89 | return BaseT::translate(c); 90 | } 91 | char_type tolower(char_type c)const 92 | { 93 | return ::boost::BOOST_REGEX_DETAIL_NS::global_lower(c); 94 | } 95 | char_type toupper(char_type c)const 96 | { 97 | return ::boost::BOOST_REGEX_DETAIL_NS::global_upper(c); 98 | } 99 | }; 100 | 101 | template 102 | struct compute_wrapper_base 103 | { 104 | typedef BaseT type; 105 | }; 106 | template 107 | struct compute_wrapper_base 108 | { 109 | typedef default_wrapper type; 110 | }; 111 | 112 | } // namespace BOOST_REGEX_DETAIL_NS 113 | 114 | template 115 | struct regex_traits_wrapper 116 | : public ::boost::BOOST_REGEX_DETAIL_NS::compute_wrapper_base< 117 | BaseT, 118 | ::boost::BOOST_REGEX_DETAIL_NS::has_boost_extensions_tag::value 119 | >::type 120 | { 121 | regex_traits_wrapper(){} 122 | private: 123 | regex_traits_wrapper(const regex_traits_wrapper&); 124 | regex_traits_wrapper& operator=(const regex_traits_wrapper&); 125 | }; 126 | 127 | } // namespace boost 128 | 129 | #endif // include 130 | 131 | -------------------------------------------------------------------------------- /external/boost/regex/v5/regex_workaround.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2005 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE regex_workarounds.cpp 15 | * VERSION see 16 | * DESCRIPTION: Declares Misc workarounds. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_WORKAROUND_HPP 20 | #define BOOST_REGEX_WORKAROUND_HPP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #ifndef BOOST_REGEX_STANDALONE 28 | #include 29 | #include 30 | #endif 31 | 32 | #ifdef BOOST_REGEX_NO_BOOL 33 | # define BOOST_REGEX_MAKE_BOOL(x) static_cast((x) ? true : false) 34 | #else 35 | # define BOOST_REGEX_MAKE_BOOL(x) static_cast(x) 36 | #endif 37 | 38 | /***************************************************************************** 39 | * 40 | * helper functions pointer_construct/pointer_destroy: 41 | * 42 | ****************************************************************************/ 43 | 44 | #ifdef __cplusplus 45 | namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ 46 | 47 | #ifdef BOOST_REGEX_MSVC 48 | #pragma warning (push) 49 | #pragma warning (disable : 4100) 50 | #endif 51 | 52 | template 53 | inline void pointer_destroy(T* p) 54 | { p->~T(); (void)p; } 55 | 56 | #ifdef BOOST_REGEX_MSVC 57 | #pragma warning (pop) 58 | #endif 59 | 60 | template 61 | inline void pointer_construct(T* p, const T& t) 62 | { new (p) T(t); } 63 | 64 | }} // namespaces 65 | #endif 66 | 67 | /***************************************************************************** 68 | * 69 | * helper function copy: 70 | * 71 | ****************************************************************************/ 72 | 73 | #if defined(BOOST_WORKAROUND) 74 | #if BOOST_WORKAROUND(BOOST_REGEX_MSVC, >= 1400) && defined(__STDC_WANT_SECURE_LIB__) && __STDC_WANT_SECURE_LIB__ 75 | #define BOOST_REGEX_HAS_STRCPY_S 76 | #endif 77 | #endif 78 | 79 | #ifdef __cplusplus 80 | namespace boost{ namespace BOOST_REGEX_DETAIL_NS{ 81 | 82 | #if defined(BOOST_REGEX_MSVC) && (BOOST_REGEX_MSVC < 1910) 83 | // 84 | // MSVC 10 will either emit warnings or else refuse to compile 85 | // code that makes perfectly legitimate use of std::copy, when 86 | // the OutputIterator type is a user-defined class (apparently all user 87 | // defined iterators are "unsafe"). What's more Microsoft have removed their 88 | // non-standard "unchecked" versions, even though they are still in the MS 89 | // documentation!! Work around this as best we can: 90 | // 91 | template 92 | inline OutputIterator copy( 93 | InputIterator first, 94 | InputIterator last, 95 | OutputIterator dest 96 | ) 97 | { 98 | while (first != last) 99 | *dest++ = *first++; 100 | return dest; 101 | } 102 | #else 103 | using std::copy; 104 | #endif 105 | 106 | 107 | #if defined(BOOST_REGEX_HAS_STRCPY_S) 108 | 109 | // use safe versions of strcpy etc: 110 | using ::strcpy_s; 111 | using ::strcat_s; 112 | #else 113 | inline std::size_t strcpy_s( 114 | char *strDestination, 115 | std::size_t sizeInBytes, 116 | const char *strSource 117 | ) 118 | { 119 | std::size_t lenSourceWithNull = std::strlen(strSource) + 1; 120 | if (lenSourceWithNull > sizeInBytes) 121 | return 1; 122 | std::memcpy(strDestination, strSource, lenSourceWithNull); 123 | return 0; 124 | } 125 | inline std::size_t strcat_s( 126 | char *strDestination, 127 | std::size_t sizeInBytes, 128 | const char *strSource 129 | ) 130 | { 131 | std::size_t lenSourceWithNull = std::strlen(strSource) + 1; 132 | std::size_t lenDestination = std::strlen(strDestination); 133 | if (lenSourceWithNull + lenDestination > sizeInBytes) 134 | return 1; 135 | std::memcpy(strDestination + lenDestination, strSource, lenSourceWithNull); 136 | return 0; 137 | } 138 | 139 | #endif 140 | 141 | inline void overflow_error_if_not_zero(std::size_t i) 142 | { 143 | if(i) 144 | { 145 | std::overflow_error e("String buffer too small"); 146 | #ifndef BOOST_REGEX_STANDALONE 147 | boost::throw_exception(e); 148 | #else 149 | throw e; 150 | #endif 151 | } 152 | } 153 | 154 | }} // namespaces 155 | 156 | #endif // __cplusplus 157 | 158 | #endif // include guard 159 | 160 | -------------------------------------------------------------------------------- /external/boost/regex/v5/syntax_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2003 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org for most recent version. 14 | * FILE syntax_type.hpp 15 | * VERSION see 16 | * DESCRIPTION: Declares regular expression synatx type enumerator. 17 | */ 18 | 19 | #ifndef BOOST_REGEX_SYNTAX_TYPE_HPP 20 | #define BOOST_REGEX_SYNTAX_TYPE_HPP 21 | 22 | namespace boost{ 23 | namespace regex_constants{ 24 | 25 | typedef unsigned char syntax_type; 26 | 27 | // 28 | // values chosen are binary compatible with previous version: 29 | // 30 | static const syntax_type syntax_char = 0; 31 | static const syntax_type syntax_open_mark = 1; 32 | static const syntax_type syntax_close_mark = 2; 33 | static const syntax_type syntax_dollar = 3; 34 | static const syntax_type syntax_caret = 4; 35 | static const syntax_type syntax_dot = 5; 36 | static const syntax_type syntax_star = 6; 37 | static const syntax_type syntax_plus = 7; 38 | static const syntax_type syntax_question = 8; 39 | static const syntax_type syntax_open_set = 9; 40 | static const syntax_type syntax_close_set = 10; 41 | static const syntax_type syntax_or = 11; 42 | static const syntax_type syntax_escape = 12; 43 | static const syntax_type syntax_dash = 14; 44 | static const syntax_type syntax_open_brace = 15; 45 | static const syntax_type syntax_close_brace = 16; 46 | static const syntax_type syntax_digit = 17; 47 | static const syntax_type syntax_comma = 27; 48 | static const syntax_type syntax_equal = 37; 49 | static const syntax_type syntax_colon = 36; 50 | static const syntax_type syntax_not = 53; 51 | 52 | // extensions: 53 | 54 | static const syntax_type syntax_hash = 13; 55 | static const syntax_type syntax_newline = 26; 56 | 57 | // escapes: 58 | 59 | typedef syntax_type escape_syntax_type; 60 | 61 | static const escape_syntax_type escape_type_word_assert = 18; 62 | static const escape_syntax_type escape_type_not_word_assert = 19; 63 | static const escape_syntax_type escape_type_control_f = 29; 64 | static const escape_syntax_type escape_type_control_n = 30; 65 | static const escape_syntax_type escape_type_control_r = 31; 66 | static const escape_syntax_type escape_type_control_t = 32; 67 | static const escape_syntax_type escape_type_control_v = 33; 68 | static const escape_syntax_type escape_type_ascii_control = 35; 69 | static const escape_syntax_type escape_type_hex = 34; 70 | static const escape_syntax_type escape_type_unicode = 0; // not used 71 | static const escape_syntax_type escape_type_identity = 0; // not used 72 | static const escape_syntax_type escape_type_backref = syntax_digit; 73 | static const escape_syntax_type escape_type_decimal = syntax_digit; // not used 74 | static const escape_syntax_type escape_type_class = 22; 75 | static const escape_syntax_type escape_type_not_class = 23; 76 | 77 | // extensions: 78 | 79 | static const escape_syntax_type escape_type_left_word = 20; 80 | static const escape_syntax_type escape_type_right_word = 21; 81 | static const escape_syntax_type escape_type_start_buffer = 24; // for \` 82 | static const escape_syntax_type escape_type_end_buffer = 25; // for \' 83 | static const escape_syntax_type escape_type_control_a = 28; // for \a 84 | static const escape_syntax_type escape_type_e = 38; // for \e 85 | static const escape_syntax_type escape_type_E = 47; // for \Q\E 86 | static const escape_syntax_type escape_type_Q = 48; // for \Q\E 87 | static const escape_syntax_type escape_type_X = 49; // for \X 88 | static const escape_syntax_type escape_type_C = 50; // for \C 89 | static const escape_syntax_type escape_type_Z = 51; // for \Z 90 | static const escape_syntax_type escape_type_G = 52; // for \G 91 | 92 | static const escape_syntax_type escape_type_property = 54; // for \p 93 | static const escape_syntax_type escape_type_not_property = 55; // for \P 94 | static const escape_syntax_type escape_type_named_char = 56; // for \N 95 | static const escape_syntax_type escape_type_extended_backref = 57; // for \g 96 | static const escape_syntax_type escape_type_reset_start_mark = 58; // for \K 97 | static const escape_syntax_type escape_type_line_ending = 59; // for \R 98 | 99 | static const escape_syntax_type syntax_max = 60; 100 | 101 | } 102 | } 103 | 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /external/boost/regex_fwd.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 1998-2002 4 | * John Maddock 5 | * 6 | * Use, modification and distribution are subject to the 7 | * Boost Software License, Version 1.0. (See accompanying file 8 | * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | * 10 | */ 11 | 12 | /* 13 | * LOCATION: see http://www.boost.org/libs/regex for documentation. 14 | * FILE regex_fwd.cpp 15 | * VERSION see 16 | * DESCRIPTION: Forward declares boost::basic_regex<> and 17 | * associated typedefs. 18 | */ 19 | 20 | #ifndef BOOST_REGEX_FWD_HPP 21 | #define BOOST_REGEX_FWD_HPP 22 | 23 | #ifndef BOOST_REGEX_CONFIG_HPP 24 | #include 25 | #endif 26 | 27 | #ifdef BOOST_REGEX_CXX03 28 | #include 29 | #else 30 | #include 31 | #endif 32 | 33 | #endif 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /external/doctest/doc/markdown/build-systems.md: -------------------------------------------------------------------------------- 1 | ## Build systems 2 | 3 | The latest released version of doctest can be obtained from here: https://raw.githubusercontent.com/doctest/doctest/master/doctest/doctest.h 4 | 5 | You can substitute ```master``` with ```dev``` or a tag like ```v1.4.8``` for a specific version in the URL above. 6 | 7 | ### CMake 8 | 9 | - **doctest** is easiest to use as a single file inside your own repository. Then the following minimal example will work: 10 | 11 | ```cmake 12 | cmake_minimum_required(VERSION 3.0) 13 | project(cmake_test VERSION 0.0.1 LANGUAGES CXX) 14 | 15 | # Prepare doctest for other targets to use 16 | find_package(doctest REQUIRED) 17 | 18 | # Make test executable 19 | add_executable(tests main.cpp) 20 | target_compile_features(tests PRIVATE cxx_std_17) 21 | target_link_libraries(tests PRIVATE doctest::doctest) 22 | ``` 23 | 24 | - You can also use the following CMake snippet to automatically fetch the entire **doctest** repository from github and configure it as an external project: 25 | 26 | ```cmake 27 | include(ExternalProject) 28 | find_package(Git REQUIRED) 29 | 30 | ExternalProject_Add( 31 | doctest 32 | PREFIX ${CMAKE_BINARY_DIR}/doctest 33 | GIT_REPOSITORY https://github.com/doctest/doctest.git 34 | TIMEOUT 10 35 | UPDATE_COMMAND ${GIT_EXECUTABLE} pull 36 | CONFIGURE_COMMAND "" 37 | BUILD_COMMAND "" 38 | INSTALL_COMMAND "" 39 | LOG_DOWNLOAD ON 40 | ) 41 | 42 | # Expose required variable (DOCTEST_INCLUDE_DIR) to parent scope 43 | ExternalProject_Get_Property(doctest source_dir) 44 | set(DOCTEST_INCLUDE_DIR ${source_dir}/doctest CACHE INTERNAL "Path to include folder for doctest") 45 | ``` 46 | 47 | And later you'll be able to use the doctest include directory like this: 48 | 49 | ```cmake 50 | # add it globally 51 | include_directories(${DOCTEST_INCLUDE_DIR}) 52 | 53 | # or per target 54 | target_include_directories(my_target PUBLIC ${DOCTEST_INCLUDE_DIR}) 55 | ``` 56 | 57 | - If you have the entire doctest repository available (as a submodule or just as files) you could also include it in your CMake build by using ```add_subdirectory(path/to/doctest)``` and then you could use it like this: 58 | 59 | ```cmake 60 | add_executable(my_tests src_1.cpp src_2.cpp ...) 61 | target_link_libraries(my_tests doctest) 62 | ``` 63 | 64 | - The ```CMakeLists.txt``` file of the doctest repository has ```install()``` commands so you could also use doctest as a package. 65 | 66 | - To discover tests from an executable and register them in ctest you could use [```doctest_discover_tests()``` from scripts/cmake/doctest.cmake](../../scripts/cmake/doctest.cmake) - read the comments in the file on how to use it. It works just like [the same functionality in Catch](https://github.com/catchorg/Catch2/blob/master/docs/cmake-integration.md#automatic-test-registration). 67 | 68 | ### Package managers 69 | 70 | **doctest** is available through the following package managers: 71 | 72 | - vcpkg 73 | - You can download and install doctest using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager: 74 | ```sh 75 | git clone https://github.com/Microsoft/vcpkg.git 76 | cd vcpkg 77 | ./bootstrap-vcpkg.sh #.\bootstrap-vcpkg.bat(for windows) 78 | ./vcpkg integrate install 79 | ./vcpkg install doctest 80 | ``` 81 | The doctest port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the [vcpkg repository](https://github.com/Microsoft/vcpkg). 82 | 83 | - hunter 84 | - conan 85 | - https://conan.io/center/doctest 86 | - https://github.com/conan-io/conan-center-index/tree/master/recipes/doctest 87 | - Homebrew (`brew install doctest`) 88 | 89 | - [build2](https://build2.org/) and [cppget.org](https://cppget.org/) 90 | + You can automatically download and use a specific version of **doctest** from the stable section of the [cppget.org](https://cppget.org/) package repositiory ([cppget.org/doctest](https://cppget.org/doctest)) in each of your [build2](https://build2.org) projects. 91 | + For that, make sure to add the stable section of the `cppget.org` repository to your project's `repositories.manifest` file to be able to fetch the package list. 92 | ``` 93 | : 94 | role: prerequisite 95 | location: https://pkg.cppget.org/1/stable 96 | #trust: ... 97 | ``` 98 | + Add the dependency on **doctest** with your optional specific version constraint to your project's `manifest` file to make the package available for import. 99 | ``` 100 | depends: doctest ^ 2.4.10 101 | ``` 102 | + Import **doctest** and add it to the dependencies of your application in your `buildfile`. Please note, it is still a single header-only library and nothing will be linked. Only the path of the header file will be made available to the executable. 103 | ``` 104 | import doctest = doctest%lib{doctest} 105 | exe{my-exe}: {hxx cxx}{**} $doctest 106 | ``` 107 | + For further information, please refer to [build2 | Documentation](https://build2.org/doc.xhtml), [cppget.org/doctest](https://cppget.org/doctest), or [GitHub: build2-packaging/doctest](https://github.com/build2-packaging/doctest) for bug reports. 108 | 109 | --- 110 | 111 | [Home](readme.md#reference) 112 | 113 |

114 | -------------------------------------------------------------------------------- /external/doctest/doc/markdown/logging.md: -------------------------------------------------------------------------------- 1 | ## Logging macros 2 | 3 | Additional messages can be logged during a test case (safely even in [**concurrent threads**](faq.md#is-doctest-thread-aware)). 4 | 5 | ## INFO() 6 | 7 | The ```INFO()``` macro allows heterogeneous sequences of expressions to be captured by listing them with commas. 8 | 9 | ```c++ 10 | INFO("The number is ", i); 11 | ``` 12 | 13 | This message will be relevant to all asserts after it in the current scope or in scopes nested in the current one and will be printed later only if an assert fails. 14 | 15 | The expression is **NOT** evaluated right away - instead it gets lazily evaluated only when needed. 16 | 17 | Some notes: 18 | 19 | - the lazy stringification means the expressions will be evaluated when an assert fails and not at the point of capture - so the value might have changed by then 20 | - refer to the [**stringification**](stringification.md) page for information on how to teach doctest to stringify your types 21 | 22 | The lazy evaluation means that in the common case when no asserts fail the code runs super fast. This makes it suitable even in loops - perhaps to log the iteration. 23 | 24 | There is also the **```CAPTURE()```** macro which is a convenience wrapper of **```INFO()```**: 25 | 26 | ```c++ 27 | CAPTURE(some_variable) 28 | ``` 29 | 30 | This will handle the stringification of the variable name for you (actually it works with any expression, not just variables). 31 | 32 | This would log something like: 33 | 34 | ```c++ 35 | some_variable := 42 36 | ``` 37 | 38 | ## Messages which can optionally fail test cases 39 | 40 | There are a few other macros for logging information: 41 | 42 | - ```MESSAGE(message)``` 43 | - ```FAIL_CHECK(message)``` 44 | - ```FAIL(message)``` 45 | 46 | ```FAIL()``` is like a ```REQUIRE``` assert - fails the test case and exits it. ```FAIL_CHECK()``` acts like a ```CHECK``` assert - fails the test case but continues with the execution. ```MESSAGE()``` just prints a message. 47 | 48 | ```c++ 49 | FAIL("This is not supposed to happen! some var: ", var); 50 | ``` 51 | 52 | Also there is no lazy stringification here - strings are always constructed and printed. 53 | 54 | There are also a few more intended for use by third party libraries such as mocking frameworks: 55 | 56 | - ```ADD_MESSAGE_AT(file, line, message)``` 57 | - ```ADD_FAIL_CHECK_AT(file, line, message)``` 58 | - ```ADD_FAIL_AT(file, line, message)``` 59 | 60 | They can be useful when integrating asserts from a different framework with doctest. 61 | 62 | ------ 63 | 64 | - Check out the [**example**](../../examples/all_features/logging.cpp) which shows how all of these are used. 65 | 66 | --- 67 | 68 | [Home](readme.md#reference) 69 | 70 |

71 | -------------------------------------------------------------------------------- /external/doctest/doc/markdown/main.md: -------------------------------------------------------------------------------- 1 | ## The ```main()``` entry point 2 | 3 | The usual way of writing tests in C++ has always been into separate source files from the code they test that form an executable containing only tests. In that scenario the default ```main()``` provided by **doctest** is usually sufficient: 4 | 5 | ```c++ 6 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 7 | #include "doctest.h" 8 | ``` 9 | 10 | This should be done in exactly one source file and is even a good idea to do this in a separate file with nothing else in it. 11 | 12 | However if you need more control - want to set options with code to the execution context or want to integrate the framework in your production code - then the default ```main()``` just won't do the job. In that case use [**```DOCTEST_CONFIG_IMPLEMENT```**](configuration.md#doctest_config_implement). 13 | 14 | All the [**command line**](commandline.md) options can be set like this (flags cannot because it wouldn't make sense). Filters can only be appended or cleared with the ```addFilter()``` or ```clearFilters()``` method of a ```doctest::Context``` object - the user cannot remove a specific filter with code. 15 | 16 | ```c++ 17 | #define DOCTEST_CONFIG_IMPLEMENT 18 | #include "doctest.h" 19 | 20 | int main(int argc, char** argv) { 21 | doctest::Context context; 22 | 23 | // !!! THIS IS JUST AN EXAMPLE SHOWING HOW DEFAULTS/OVERRIDES ARE SET !!! 24 | 25 | // defaults 26 | context.addFilter("test-case-exclude", "*math*"); // exclude test cases with "math" in their name 27 | context.setOption("abort-after", 5); // stop test execution after 5 failed assertions 28 | context.setOption("order-by", "name"); // sort the test cases by their name 29 | 30 | context.applyCommandLine(argc, argv); 31 | 32 | // overrides 33 | context.setOption("no-breaks", true); // don't break in the debugger when assertions fail 34 | 35 | int res = context.run(); // run 36 | 37 | if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this 38 | return res; // propagate the result of the tests 39 | 40 | int client_stuff_return_code = 0; 41 | // your program - if the testing framework is integrated in your production code 42 | 43 | return res + client_stuff_return_code; // the result from doctest is propagated here as well 44 | } 45 | 46 | ``` 47 | 48 | Note the call to ```.shouldExit()``` on the context - that is very important - it will be set when a query flag has been used (or the ```--no-run``` option is set to ```true```) and it is the user's responsibility to exit the application in a normal way. 49 | 50 | ### Dealing with shared objects (DLLs) 51 | 52 | The framework can be used separately in binaries (executables / shared objects) with each having its own test runner - this way even different versions of doctest can be used - but there will be no simple way to execute the tests from all loaded binaries and have the results aggregated and summarized. 53 | 54 | There is also an option to have the test runner (implementation) built in a binary and shared with others (so there is a single test registry) by exporting its public symbols (the ones needed for writing tests by the user - all the forward declarations of the framework). 55 | 56 | For more info on that checkout the [**```DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL```**](configuration.md#doctest_config_implementation_in_dll) config identifier and [**this example**](../../examples/executable_dll_and_plugin/). 57 | 58 | --------------- 59 | 60 | [Home](readme.md#reference) 61 | 62 |

63 | -------------------------------------------------------------------------------- /external/doctest/doc/markdown/readme.md: -------------------------------------------------------------------------------- 1 | Reference 2 | ======= 3 | 4 | Project: 5 | 6 | - [Features and design goals](features.md) - the complete list of features 7 | - [Community driven roadmap](https://github.com/doctest/doctest/issues/600) - upcoming features 8 | - [Benchmarks](benchmarks.md) - compile-time and runtime supremacy 9 | - [Contributing](../../CONTRIBUTING.md) - how to make a proper pull request 10 | - [Changelog](../../CHANGELOG.md) - generated changelog based on closed issues/PRs 11 | 12 | Usage: 13 | 14 | - [Tutorial](tutorial.md) - make sure you have read it before the other parts of the documentation 15 | - [Assertion macros](assertions.md) 16 | - [Test cases, subcases and test fixtures](testcases.md) 17 | - [Parameterized test cases](parameterized-tests.md) 18 | - [Logging macros](logging.md) 19 | - [Command line](commandline.md) 20 | - [```main()``` entry point](main.md) 21 | - [Configuration](configuration.md) 22 | - [String conversions](stringification.md) 23 | - [Reporters](reporters.md) 24 | - [Extensions](extensions.md) 25 | - [FAQ](faq.md) 26 | - [Build systems](build-systems.md) 27 | - [Examples](../../examples) 28 | 29 | This library is free, and will stay free but needs your support to sustain its development. There are lots of [**new features**](https://github.com/doctest/doctest/issues/600) and maintenance to do. If you work for a company using **doctest** or have the means to do so, please consider financial support. 30 | 31 | [![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/onqtam) 32 | [![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.me/onqtam/10) 33 | 34 | ------------ 35 | 36 |

37 | -------------------------------------------------------------------------------- /external/doctest/doc/markdown/reporters.md: -------------------------------------------------------------------------------- 1 | ## Reporters 2 | 3 | Doctest has a modular reporter/listener system with which users can write their own reporters and register them. The reporter interface can also be used for "listening" to events. 4 | 5 | You can list all registered reporters/listeners with ```--list-reporters```. There are a few implemented reporters in the framework: 6 | - ```console``` - streaming - writes normal lines of text with coloring if a capable terminal is detected 7 | - ```xml``` - streaming - writes in xml format tailored to doctest 8 | - ```junit``` - buffering - writes in JUnit-compatible xml - for more information look [here](https://github.com/doctest/doctest/issues/318) and [here](https://github.com/doctest/doctest/issues/376). 9 | 10 | Streaming means that results are delivered progressively and not at the end of the test run. 11 | 12 | The output is by default written to ```stdout``` but can be redirected with the use of the ```--out=``` [**command line option**](commandline.md). 13 | 14 | Example how to define your own reporter: 15 | 16 | ```c++ 17 | #include 18 | 19 | #include 20 | 21 | using namespace doctest; 22 | 23 | struct MyXmlReporter : public IReporter 24 | { 25 | // caching pointers/references to objects of these types - safe to do 26 | std::ostream& stdout_stream; 27 | const ContextOptions& opt; 28 | const TestCaseData* tc; 29 | std::mutex mutex; 30 | 31 | // constructor has to accept the ContextOptions by ref as a single argument 32 | MyXmlReporter(const ContextOptions& in) 33 | : stdout_stream(*in.cout) 34 | , opt(in) {} 35 | 36 | void report_query(const QueryData& /*in*/) override {} 37 | 38 | void test_run_start() override {} 39 | 40 | void test_run_end(const TestRunStats& /*in*/) override {} 41 | 42 | void test_case_start(const TestCaseData& in) override { tc = ∈ } 43 | 44 | // called when a test case is reentered because of unfinished subcases 45 | void test_case_reenter(const TestCaseData& /*in*/) override {} 46 | 47 | void test_case_end(const CurrentTestCaseStats& /*in*/) override {} 48 | 49 | void test_case_exception(const TestCaseException& /*in*/) override {} 50 | 51 | void subcase_start(const SubcaseSignature& /*in*/) override { 52 | std::lock_guard lock(mutex); 53 | } 54 | 55 | void subcase_end() override { 56 | std::lock_guard lock(mutex); 57 | } 58 | 59 | void log_assert(const AssertData& in) override { 60 | // don't include successful asserts by default - this is done here 61 | // instead of in the framework itself because doctest doesn't know 62 | // if/when a reporter/listener cares about successful results 63 | if(!in.m_failed && !opt.success) 64 | return; 65 | 66 | // make sure there are no races - this is done here instead of in the 67 | // framework itself because doctest doesn't know if reporters/listeners 68 | // care about successful asserts and thus doesn't lock a mutex unnecessarily 69 | std::lock_guard lock(mutex); 70 | 71 | // ... 72 | } 73 | 74 | void log_message(const MessageData& /*in*/) override { 75 | // messages too can be used in a multi-threaded context - like asserts 76 | std::lock_guard lock(mutex); 77 | 78 | // ... 79 | } 80 | 81 | void test_case_skipped(const TestCaseData& /*in*/) override {} 82 | }; 83 | 84 | // "1" is the priority - used for ordering when multiple reporters are used 85 | REGISTER_REPORTER("my_xml", 1, MyXmlReporter); 86 | 87 | // registering the same class as a reporter and as a listener is nonsense but it's possible 88 | REGISTER_LISTENER("my_listener", 1, MyXmlReporter); 89 | ``` 90 | 91 | Custom `IReporter` implementations must be registered with one of: 92 | 93 | * `REGISTER_REPORTER`, for when the new reporter is an option that users may choose at run-time. 94 | * `REGISTER_LISTENER`, for when the reporter is actually a listener and must always be executed, regardless of which reporters have been chosen at run-time. 95 | 96 | Multiple reporters can be used at the same time - just specify them through the ```--reporters=...``` [**command line filtering option**](commandline.md) using commas to separate them like this: ```--reporters=myReporter,xml``` and their order of execution will be based on their priority - that is the number "1" in the case of the example reporter above (lower means earlier - the default console/xml reporters from the framework have 0 as their priority and negative numbers are accepted as well). 97 | 98 | All registered listeners (```REGISTER_LISTENER```) will be executed before any reporter - they do not need to be specified and cannot be filtered through the command line. 99 | 100 | When implementing a reporter users are advised to follow the comments from the example above and look at the few implemented reporters in the framework itself. Also check out the [**example**](../../examples/all_features/reporters_and_listeners.cpp). 101 | 102 | --------------- 103 | 104 | [Home](readme.md#reference) 105 | 106 |

107 | -------------------------------------------------------------------------------- /media/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danieltodor/blaze/9813a9bf6507f4c4ff98121f633bf5739d2d0dc6/media/demo.png -------------------------------------------------------------------------------- /src/arg.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "argparse/argparse.hpp" 6 | 7 | struct Args : public argparse::Args 8 | { 9 | Args() = default; 10 | 11 | ~Args() = default; 12 | 13 | Args(const Args &obj) = default; 14 | 15 | Args & operator = (Args &&obj) 16 | { 17 | shell = obj.shell; 18 | init = obj.init; 19 | prompt = obj.prompt; 20 | right_prompt = obj.right_prompt; 21 | transient_prompt = obj.transient_prompt; 22 | first_print = obj.first_print; 23 | start_time = obj.start_time; 24 | finish_time = obj.finish_time; 25 | status = obj.status; 26 | background = obj.background; 27 | previous_command = obj.previous_command; 28 | return *this; 29 | } 30 | 31 | std::string &shell = arg("Current shell"); 32 | bool &init = flag("init", "Init current shell").set_default(false); 33 | bool &prompt = flag("prompt", "Print prompt").set_default(false); 34 | bool &right_prompt = flag("right-prompt", "Print right prompt").set_default(false); 35 | bool &transient_prompt = flag("transient-prompt", "Transient prompt").set_default(false); 36 | bool &first_print = kwarg("g,first-print", "First print of prompt").set_default(false); 37 | double &start_time = kwarg("s,start-time", "Time when the command was started").set_default(0); 38 | double &finish_time = kwarg("f,finish-time", "Time when the command was finished").set_default(0); 39 | int &status = kwarg("e,status", "Exit status of the last command").set_default(0); 40 | std::string &background = kwarg("b,background", "Background RGB color").set_default("0;0;0"); 41 | std::string &previous_command = kwarg("p,previous-command", "Previous command").set_default(""); 42 | }; 43 | -------------------------------------------------------------------------------- /src/color.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.hpp" 4 | #include "context.hpp" 5 | 6 | // Text modes 7 | #define BOLD 1 8 | #define DIM 2 9 | #define ITALIC 3 10 | #define UNDERLINE 4 11 | 12 | // Set text mode like bold, italic, etc 13 | std::string set_text_mode(const int code, const Context &context); 14 | 15 | // Set foreground color 16 | std::string set_foreground(const std::string &color, const Context &context); 17 | 18 | // Set background color 19 | std::string set_background(const std::string &color, const Context &context); 20 | 21 | // Reset all attributes 22 | std::string reset_all(const Context &context); 23 | 24 | // Reset selected text mode 25 | std::string reset_text_mode(const int code, const Context &context); 26 | 27 | // Reset foreground color 28 | std::string reset_foreground(const Context &context); 29 | 30 | // Reset background color 31 | std::string reset_background(const Context &context); 32 | 33 | // Move cursor up by x lines 34 | std::string move_cursor_up(const int lines, const Context &context); 35 | 36 | // Erase from cursor until end of screen 37 | std::string erase_until_end_of_screen(const Context &context); 38 | 39 | // Get sequence characters 40 | StringVector get_sequence_characters(const Context &context); 41 | -------------------------------------------------------------------------------- /src/config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.hpp" 4 | 5 | // Character that is unlikely to be used. Easy to check if the user changed the default. 6 | #define CONTROL_CHAR "`" 7 | // Alignments 8 | #define LEFT_ALIGNMENT "left" 9 | #define RIGHT_ALIGNMENT "right" 10 | #define RP_ALIGNMENT "right_prompt" 11 | 12 | struct Global 13 | { 14 | std::string padding = ""; 15 | }; 16 | 17 | struct Prompt 18 | { 19 | std::string string = " ❯ "; 20 | std::string foreground = ""; 21 | std::string error_foreground = ""; 22 | bool new_line = false; 23 | std::string separator = ""; 24 | bool transient = false; 25 | bool bottom = false; 26 | }; 27 | 28 | struct Connector 29 | { 30 | std::string character = " "; 31 | std::string foreground = ""; 32 | std::string background = ""; 33 | bool dim = false; 34 | }; 35 | 36 | struct Directory 37 | { 38 | int limit = 10; 39 | bool from_repository = true; 40 | }; 41 | 42 | struct Duration 43 | { 44 | double threshold = 2; 45 | int precision = 1; 46 | double fractional_until = 10; 47 | }; 48 | 49 | struct GitBranch 50 | { 51 | bool show_when_detached = false; 52 | StringVector ignore; 53 | }; 54 | 55 | struct GitCommit 56 | { 57 | bool show_when_attached = false; 58 | int length = 7; 59 | }; 60 | 61 | struct GitStatus 62 | { 63 | bool count = true; 64 | std::string spacing = " "; 65 | std::string clean = "✓"; 66 | std::string ahead = "↑"; 67 | std::string behind = "↓"; 68 | std::string stashed = "$"; 69 | std::string untracked = "?"; 70 | std::string conflicted = "="; 71 | std::string modified = "!"; 72 | std::string staged = "+"; 73 | std::string renamed = "»"; 74 | std::string deleted = "✘"; 75 | }; 76 | 77 | struct Date 78 | { 79 | std::string format = "%x"; 80 | }; 81 | 82 | struct Time 83 | { 84 | std::string format = "%X"; 85 | }; 86 | 87 | struct Status 88 | { 89 | bool show_zero = false; 90 | }; 91 | 92 | struct Module 93 | { 94 | std::string name = ""; 95 | std::string execute = ""; 96 | std::string content = ""; 97 | int level = 1; 98 | int position = 1; 99 | std::string align = LEFT_ALIGNMENT; 100 | std::string padding = CONTROL_CHAR; 101 | std::string inner_prefix = ""; 102 | std::string inner_suffix = ""; 103 | std::string outer_prefix = ""; 104 | std::string outer_suffix = ""; 105 | std::string foreground = ""; 106 | std::string background = ""; 107 | bool bold = false; 108 | bool dim = false; 109 | bool italic = false; 110 | bool underline = false; 111 | }; 112 | using ModuleVector = std::vector; 113 | using ModulePtrVector = std::vector; 114 | 115 | struct Config 116 | { 117 | Global global; 118 | Prompt prompt; 119 | Connector connector; 120 | Directory directory; 121 | Duration duration; 122 | GitBranch git_branch; 123 | GitCommit git_commit; 124 | GitStatus git_status; 125 | Date date; 126 | Time time; 127 | Status status; 128 | ModuleVector modules; 129 | }; 130 | 131 | // Read the user's config file, or set default values if there is no such file 132 | Config get_config(); 133 | 134 | // Previous module in the current group. Same level, same side 135 | Module *get_previous_module_in_group(ModuleVector &modules, const std::size_t index); 136 | 137 | // Next module in the current group. Same level, same side 138 | Module *get_next_module_in_group(ModuleVector &modules, const std::size_t index); 139 | 140 | // Modules on the current level 141 | ModulePtrVector get_modules_on_level(ModuleVector &modules, const int level); 142 | 143 | // At least one module on the right has content set 144 | bool contains_content_on_right(ModuleVector &modules, const int level); 145 | 146 | // Vertical size of the displayed config 147 | int vertical_size(const Config &config); 148 | -------------------------------------------------------------------------------- /src/context.cpp: -------------------------------------------------------------------------------- 1 | #include "context.hpp" 2 | #include "util.hpp" 3 | #include "pool.hpp" 4 | 5 | Context get_context(int argc, char *argv[]) 6 | { 7 | Args args; 8 | Config config; 9 | bool git_repository_detected = false; 10 | bool git_repository_detached = false; 11 | thread_pool.detach_task( 12 | [&args, argc, argv] 13 | { 14 | args = std::move(argparse::parse(argc, argv)); 15 | } 16 | ); 17 | thread_pool.detach_task( 18 | [&config] 19 | { 20 | config = get_config(); 21 | } 22 | ); 23 | thread_pool.detach_task( 24 | [&git_repository_detected, &git_repository_detached] 25 | { 26 | check_git_repository(git_repository_detected, git_repository_detached); 27 | } 28 | ); 29 | thread_pool.wait(); 30 | Context context = { 31 | args, 32 | config, 33 | get_env("HOME"), 34 | get_env("PWD"), 35 | git_repository_detected, 36 | git_repository_detached, 37 | get_current_time() 38 | }; 39 | return context; 40 | } 41 | 42 | // ----------------------------------- TESTS ----------------------------------- 43 | #ifdef TEST 44 | #include "test.hpp" 45 | 46 | TEST_CASE("get_context") 47 | { 48 | SUBCASE("easily testable values") 49 | { 50 | const int argc = 2; 51 | const char *argv[] = {"name", "bash"}; 52 | Context context = get_context(argc, const_cast(argv)); 53 | CHECK(context.args.shell == "bash"); 54 | CHECK(!context.HOME.empty()); 55 | CHECK(!context.PWD.empty()); 56 | CHECK(context.git_repository_detected); 57 | CHECK(!context.git_repository_detached); 58 | } 59 | SUBCASE("keyword arguments") 60 | { 61 | const int argc = 9; 62 | const char *argv[] = {"name", "zsh", "--prompt", "--start-time", "5", "-e", "255", "-b", "1;1;1"}; 63 | Context context = get_context(argc, const_cast(argv)); 64 | // Set 65 | CHECK(context.args.shell == "zsh"); 66 | CHECK(context.args.prompt); 67 | CHECK(context.args.start_time == 5); 68 | CHECK(context.args.status == 255); 69 | CHECK(context.args.background == "1;1;1"); 70 | // Default 71 | CHECK(!context.args.init); 72 | CHECK(context.args.finish_time == 0); 73 | CHECK(context.args.previous_command.empty()); 74 | } 75 | } 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/context.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "arg.hpp" 7 | #include "config.hpp" 8 | 9 | struct Context 10 | { 11 | Args args; 12 | Config config; 13 | std::string HOME; 14 | std::string PWD; 15 | bool git_repository_detected; 16 | bool git_repository_detached; 17 | std::tm time_structure; 18 | }; 19 | 20 | // Create context 21 | Context get_context(int argc, char *argv[]); 22 | -------------------------------------------------------------------------------- /src/init.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "init.hpp" 7 | #include "util.hpp" 8 | 9 | // Prepare shell init string 10 | std::string prepare_shell_init(const Context &context) 11 | { 12 | const std::string file_name = "init." + context.args.shell; 13 | const std::string paths[] = { 14 | // context.PWD + "/src/init/" + file_name, // For development 15 | context.HOME + "/.local/share/blaze/" + file_name 16 | }; 17 | std::ifstream file; 18 | for (const std::string &path : paths) 19 | { 20 | file.open(path); 21 | if (file.is_open()) 22 | { 23 | break; 24 | } 25 | } 26 | std::stringstream buffer; 27 | buffer << file.rdbuf(); 28 | return buffer.str(); 29 | } 30 | 31 | void print_shell_init(const Context &context) 32 | { 33 | std::cout << prepare_shell_init(context); 34 | } 35 | 36 | // ----------------------------------- TESTS ----------------------------------- 37 | #ifdef TEST 38 | #include "test.hpp" 39 | 40 | TEST_CASE("prepare_shell_init") 41 | { 42 | Context context; 43 | context.args.shell = "bash"; 44 | context.HOME = get_env("HOME"); 45 | const std::string result = prepare_shell_init(context); 46 | CHECK(result.find("PS1='") != std::string::npos); 47 | } 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/init.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "context.hpp" 4 | 5 | // Print init script 6 | void print_shell_init(const Context &context); 7 | -------------------------------------------------------------------------------- /src/init/init.bash: -------------------------------------------------------------------------------- 1 | _blaze_get_current_time() { 2 | echo "$(date +%s.%N)" 3 | } 4 | 5 | _blaze_save_start_time() { 6 | echo $(_blaze_get_current_time) > $_blaze_start_time_file 7 | } 8 | 9 | _blaze_get_start_time() { 10 | echo "$(cat $_blaze_start_time_file)" 11 | } 12 | 13 | _blaze_save_status() { 14 | echo $? > $_blaze_status_file 15 | } 16 | 17 | _blaze_get_status() { 18 | echo "$(cat $_blaze_status_file)" 19 | } 20 | 21 | _blaze_save_first_print() { 22 | if [[ -e $_blaze_first_print_file ]]; then 23 | echo "false" > $_blaze_first_print_file 24 | else 25 | echo "true" > $_blaze_first_print_file 26 | fi 27 | } 28 | 29 | _blaze_get_first_print() { 30 | echo "$(cat $_blaze_first_print_file)" 31 | } 32 | 33 | _blaze_save_previous_command() { 34 | echo "$(history 1 | cut -c 8-)" > $_blaze_previous_command_file 35 | } 36 | 37 | _blaze_get_previous_command() { 38 | echo "$(cat $_blaze_previous_command_file)" 39 | } 40 | 41 | _blaze_save_previous_status() { 42 | echo $(_blaze_get_status) > $_blaze_previous_status_file 43 | } 44 | 45 | _blaze_get_previous_status() { 46 | echo "$(cat $_blaze_previous_status_file)" 47 | } 48 | 49 | _blaze_preexec() { 50 | _blaze_save_start_time 51 | _blaze_save_first_print 52 | _blaze_save_previous_command 53 | _blaze_save_previous_status 54 | blaze bash --transient-prompt -e=$(_blaze_get_previous_status) -p="$(_blaze_get_previous_command)" 55 | } 56 | 57 | _blaze_precmd() { 58 | _blaze_save_status 59 | } 60 | 61 | _blaze_run_on_exit() { 62 | rm $_blaze_start_time_file 63 | rm $_blaze_status_file 64 | rm $_blaze_first_print_file 65 | rm $_blaze_previous_command_file 66 | rm $_blaze_previous_status_file 67 | } 68 | trap _blaze_run_on_exit EXIT 69 | trap "echo; _blaze_preexec" SIGINT # ^C needs an extra new line to prevent overwriting content during transient prompt 70 | 71 | _blaze_session="_blaze_${USER}_${BASHPID}" 72 | 73 | if [[ -d "/dev/shm" ]]; then 74 | _blaze_file_prefix="/dev/shm/$_blaze_session" 75 | else 76 | _blaze_file_prefix="/tmp/$_blaze_session" 77 | fi 78 | 79 | _blaze_default_background=$(~/.local/share/blaze/util.bash _blaze_get_current_background) 80 | _blaze_start_time_file="${_blaze_file_prefix}_start_time" 81 | _blaze_status_file="${_blaze_file_prefix}_status" 82 | _blaze_first_print_file="${_blaze_file_prefix}_first_print" 83 | _blaze_previous_command_file="${_blaze_file_prefix}_previous_command" 84 | _blaze_previous_status_file="${_blaze_file_prefix}_previous_status" 85 | 86 | _blaze_save_start_time 87 | _blaze_save_status 88 | _blaze_save_first_print 89 | _blaze_save_previous_command 90 | _blaze_save_previous_status 91 | 92 | # Bash doesn't have preexec/precmd hooks, but the behavior of these prompt variables are close enough 93 | PS0=$PS0'$(_blaze_preexec)' # Is expanded after a command is read and before the command is executed 94 | PROMPT_COMMAND=$PROMPT_COMMAND'$(_blaze_precmd)' # Executed before the printing of each primary prompt 95 | 96 | PS1='$(blaze bash --prompt -s=$(_blaze_get_start_time) -f=$(_blaze_get_current_time) -e=$(_blaze_get_status) -b=$_blaze_default_background -g=$(_blaze_get_first_print))' 97 | -------------------------------------------------------------------------------- /src/init/init.fish: -------------------------------------------------------------------------------- 1 | function _blaze_get_current_time 2 | echo (date +%s.%N) 3 | end 4 | 5 | function _blaze_preexec --on-event fish_preexec # Executed just after a command has been read and is about to be executed 6 | set _blaze_start_time (_blaze_get_current_time) 7 | set _blaze_first_print false 8 | set _blaze_previous_command $argv 9 | set _blaze_previous_status $_blaze_status 10 | blaze fish --transient-prompt -e=$_blaze_previous_status -p=$_blaze_previous_command 11 | end 12 | 13 | function _blaze_precmd --on-event fish_prompt # Executed before each prompt 14 | set _blaze_status $status 15 | set _blaze_finish_time (_blaze_get_current_time) 16 | end 17 | 18 | set _blaze_default_background (~/.local/share/blaze/util.bash _blaze_get_current_background) 19 | set _blaze_start_time 0 20 | set _blaze_finish_time 0 21 | set _blaze_status 0 22 | set _blaze_first_print true 23 | set _blaze_previous_command "" 24 | set _blaze_previous_status 0 25 | 26 | function fish_prompt 27 | blaze fish --prompt -s=$_blaze_start_time -f=$_blaze_finish_time -e=$_blaze_status -b=$_blaze_default_background -g=$_blaze_first_print 28 | end 29 | 30 | function fish_right_prompt 31 | blaze fish --right-prompt -s=$_blaze_start_time -f=$_blaze_finish_time -e=$_blaze_status -b=$_blaze_default_background -g=$_blaze_first_print 32 | end 33 | -------------------------------------------------------------------------------- /src/init/init.zsh: -------------------------------------------------------------------------------- 1 | _blaze_get_current_time() { 2 | echo "$(date +%s.%N)" 3 | } 4 | 5 | _blaze_preexec() { 6 | _blaze_start_time=$(_blaze_get_current_time) 7 | _blaze_first_print=false 8 | _blaze_previous_command=$1 9 | _blaze_previous_status=$_blaze_status 10 | blaze zsh --transient-prompt -e=$_blaze_previous_status -p=$_blaze_previous_command 11 | } 12 | 13 | _blaze_precmd() { 14 | _blaze_status=$? 15 | _blaze_finish_time=$(_blaze_get_current_time) 16 | } 17 | 18 | TRAPINT() { 19 | echo # ^C needs an extra new line to prevent overwriting content during transient prompt 20 | _blaze_preexec 21 | return $(( 128 + $1 )) 22 | } 23 | 24 | _blaze_default_background=$(~/.local/share/blaze/util.bash _blaze_get_current_background) 25 | _blaze_start_time=0 26 | _blaze_finish_time=0 27 | _blaze_status=0 28 | _blaze_first_print=true 29 | _blaze_previous_command="" 30 | _blaze_previous_status=0 31 | 32 | autoload -Uz add-zsh-hook 33 | add-zsh-hook preexec _blaze_preexec # Executed just after a command has been read and is about to be executed 34 | add-zsh-hook precmd _blaze_precmd # Executed before each prompt 35 | 36 | setopt prompt_subst # Enable prompt substitution 37 | 38 | ZLE_RPROMPT_INDENT="0" # Remove extra space at the end of right prompt 39 | PROMPT='$(blaze zsh --prompt -s=$_blaze_start_time -f=$_blaze_finish_time -e=$_blaze_status -b=$_blaze_default_background -g=$_blaze_first_print)' 40 | RPROMPT='$(blaze zsh --right-prompt -s=$_blaze_start_time -f=$_blaze_finish_time -e=$_blaze_status -b=$_blaze_default_background -g=$_blaze_first_print)' 41 | -------------------------------------------------------------------------------- /src/init/util.bash: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | # Get the RGB color of the terminal emulator. Works only in xterm compatible emulators. 4 | _blaze_get_current_background() { 5 | if [[ $COLORTERM != "truecolor" ]]; then 6 | echo "0;0;0" 7 | return 8 | fi 9 | exec < /dev/tty 10 | local oldstty=$(stty -g) 11 | stty raw -echo min 0 12 | local ps=11 # background 13 | echo -en "\033]${ps};?\033\\" > /dev/tty 14 | local hex_rgb="" 15 | IFS=';' read -r -d '\' hex_rgb 16 | stty $oldstty 17 | hex_rgb=$(echo $hex_rgb | sed 's/^.*\;//;s/[^rgb:0-9a-f/]//g') 18 | hex_rgb=$(echo $hex_rgb | sed 's/[rgb:|/]//g') 19 | local bg_rgb="" 20 | # Convert hex parts to decimal, and shift them to fit into range of 0-255 21 | bg_rgb+=$((16#${hex_rgb:0:4} >> 8))";" 22 | bg_rgb+=$((16#${hex_rgb:4:4} >> 8))";" 23 | bg_rgb+=$((16#${hex_rgb:8:4} >> 8)) 24 | echo $bg_rgb 25 | } 26 | 27 | if [[ $# -eq 0 ]]; then 28 | echo "Pass the function name to call" 29 | exit 1 30 | fi 31 | 32 | # Call the function and echo the result 33 | echo $($1) 34 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "init.hpp" 2 | #include "print.hpp" 3 | #include "context.hpp" 4 | #include "test.hpp" 5 | 6 | int main(int argc, char *argv[]) 7 | { 8 | #ifdef TEST 9 | run_tests(argc, argv); 10 | #endif 11 | Context context = get_context(argc, argv); 12 | if (context.args.init) 13 | { 14 | print_shell_init(context); 15 | } 16 | else if (context.args.prompt) 17 | { 18 | print_prompt(context); 19 | } 20 | else if (context.args.right_prompt) 21 | { 22 | print_right_prompt(context); 23 | } 24 | else if (context.args.transient_prompt) 25 | { 26 | print_transient_prompt(context); 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /src/module.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "module.hpp" 4 | #include "modules/date.hpp" 5 | #include "modules/directory.hpp" 6 | #include "modules/duration.hpp" 7 | #include "modules/git_branch.hpp" 8 | #include "modules/git_commit.hpp" 9 | #include "modules/git_status.hpp" 10 | #include "modules/host.hpp" 11 | #include "modules/shell.hpp" 12 | #include "modules/status.hpp" 13 | #include "modules/time.hpp" 14 | #include "modules/user.hpp" 15 | 16 | const std::unordered_map module_map 17 | { 18 | {"date", &date}, 19 | {"directory", &directory}, 20 | {"duration", &duration}, 21 | {"git_branch", &git_branch}, 22 | {"git_commit", &git_commit}, 23 | {"git_status", &git_status}, 24 | {"host", &host}, 25 | {"shell", &shell}, 26 | {"status", &status}, 27 | {"time", &time}, 28 | {"user", &user} 29 | }; 30 | 31 | std::string call_module(const std::string &name, const Context &context) 32 | { 33 | const auto pair = module_map.find(name); 34 | if (pair == module_map.end()) 35 | { 36 | return ""; 37 | } 38 | return (*pair).second(context); 39 | } 40 | 41 | // ----------------------------------- TESTS ----------------------------------- 42 | #ifdef TEST 43 | #include "test.hpp" 44 | 45 | TEST_CASE("call_module") 46 | { 47 | Context context; 48 | SUBCASE("non-existent module") 49 | { 50 | CHECK(call_module("unknown", context) == ""); 51 | } 52 | SUBCASE("existing module") 53 | { 54 | context.args.status = 255; 55 | CHECK(call_module("status", context) == "255"); 56 | } 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/module.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "context.hpp" 6 | 7 | // Call the module function by its name 8 | std::string call_module(const std::string &name, const Context &context); 9 | -------------------------------------------------------------------------------- /src/modules/date.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "context.hpp" 6 | #include "util.hpp" 7 | 8 | // Current date 9 | std::string date(const Context &context) 10 | { 11 | const Config &config = context.config; 12 | return format_time(context.time_structure, config.date.format); 13 | } 14 | 15 | // ----------------------------------- TESTS ----------------------------------- 16 | #ifdef TEST 17 | #include "test.hpp" 18 | 19 | TEST_CASE("date") 20 | { 21 | Context context; 22 | context.time_structure.tm_gmtoff = 7200; 23 | context.time_structure.tm_isdst = 1; 24 | context.time_structure.tm_yday = 215; 25 | context.time_structure.tm_wday = 6; 26 | context.time_structure.tm_year = 124; 27 | context.time_structure.tm_mon = 7; 28 | context.time_structure.tm_mday = 3; 29 | context.time_structure.tm_hour = 20; 30 | context.time_structure.tm_min = 4; 31 | context.time_structure.tm_sec = 34; 32 | SUBCASE("correct date %F format") 33 | { 34 | context.config.date.format = "%F"; 35 | CHECK(date(context) == "2024-08-03"); 36 | } 37 | SUBCASE("correct date %T format") 38 | { 39 | context.config.date.format = "%T"; 40 | CHECK(date(context) == "20:04:34"); 41 | } 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/modules/directory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "context.hpp" 6 | #include "util.hpp" 7 | 8 | // Current working directory 9 | std::string directory(const Context &context) 10 | { 11 | std::string result = ""; 12 | const Config &config = context.config; 13 | const std::string &HOME = context.HOME; 14 | const std::string &PWD = context.PWD; 15 | result += PWD; 16 | if (result.find(HOME) != std::string::npos) 17 | { 18 | result.replace(0, HOME.length(), "~"); 19 | } 20 | if (config.directory.from_repository && context.git_repository_detected) 21 | { 22 | std::string git_repository_path = execute_command("git rev-parse --show-toplevel"); 23 | if (git_repository_path.find(HOME) != std::string::npos) 24 | { 25 | git_repository_path.replace(0, HOME.length(), "~"); 26 | } 27 | const std::size_t index = find_nth_occurrence(git_repository_path, "/", 1, true); 28 | result.replace(0, index + 1, ""); 29 | } 30 | if (config.directory.limit > 0) 31 | { 32 | const std::size_t index = find_nth_occurrence(result, "/", config.directory.limit, true); 33 | if (index != std::string::npos) 34 | { 35 | result.replace(0, index, "..."); 36 | } 37 | } 38 | return result; 39 | } 40 | 41 | // ----------------------------------- TESTS ----------------------------------- 42 | #ifdef TEST 43 | #include "test.hpp" 44 | 45 | TEST_CASE("directory") 46 | { 47 | Context context; 48 | context.PWD = "/a/b/c"; 49 | context.config.directory.limit = 4; 50 | context.config.directory.from_repository = false; 51 | SUBCASE("replace home with ~") 52 | { 53 | context.HOME = "/a"; 54 | CHECK(directory(context) == "~/b/c"); 55 | } 56 | SUBCASE("PWD when not in home directory") 57 | { 58 | context.HOME = "/d"; 59 | CHECK(directory(context) == "/a/b/c"); 60 | } 61 | SUBCASE("from repository") 62 | { 63 | context.PWD = get_env("PWD"); 64 | context.config.directory.from_repository = true; 65 | context.git_repository_detected = true; 66 | CHECK(directory(context) == "blaze"); 67 | } 68 | SUBCASE("from repository inside subdirectory") 69 | { 70 | context.HOME = get_env("HOME"); 71 | context.PWD = get_env("PWD") + "/a/b/c"; 72 | context.config.directory.from_repository = true; 73 | context.git_repository_detected = true; 74 | CHECK(directory(context) == "blaze/a/b/c"); 75 | } 76 | SUBCASE("from repository directory limit") 77 | { 78 | context.HOME = get_env("HOME"); 79 | context.PWD = get_env("PWD") + "/a/b/c/d/e/f"; 80 | context.config.directory.from_repository = true; 81 | context.git_repository_detected = true; 82 | CHECK(directory(context) == ".../c/d/e/f"); 83 | } 84 | SUBCASE("directory limit reached") 85 | { 86 | context.HOME = "/a"; 87 | context.PWD = "/a/b/c/d/e"; 88 | CHECK(directory(context) == ".../b/c/d/e"); 89 | } 90 | SUBCASE("directory limit not reached") 91 | { 92 | context.HOME = "/a"; 93 | context.PWD = "/a/b/c/d/e"; 94 | context.config.directory.limit = 5; 95 | CHECK(directory(context) == "~/b/c/d/e"); 96 | } 97 | } 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /src/modules/duration.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "context.hpp" 7 | 8 | // Times in seconds 9 | #define HOUR 3600 10 | #define MINUTE 60 11 | #define SECOND 1 12 | 13 | // Execution time of the last command (wall time) 14 | std::string duration(const Context &context) 15 | { 16 | auto subtract_time = [](double &from, const int unit) 17 | { 18 | int time = floor(from / unit); 19 | from -= time * unit; 20 | return time; 21 | }; 22 | const Config &config = context.config; 23 | const double precision = std::pow(10, -config.duration.precision); 24 | const double start_time = context.args.start_time; 25 | const double finish_time = context.args.finish_time; 26 | const double difference = round((finish_time - start_time) / precision) * precision; 27 | if (difference < config.duration.threshold || start_time <= 0 || finish_time <= 0) 28 | { 29 | return ""; 30 | } 31 | std::string result = ""; 32 | double remainder = difference; 33 | const int hours = subtract_time(remainder, HOUR); 34 | const int minutes = subtract_time(remainder, MINUTE); 35 | const int seconds = subtract_time(remainder, SECOND); 36 | const double fractional = round(remainder / precision) * precision; 37 | if (hours) 38 | { 39 | result += std::to_string(hours) + 'h'; 40 | } 41 | if (minutes) 42 | { 43 | result += hours ? " " : ""; 44 | result += std::to_string(minutes) + 'm'; 45 | } 46 | if (seconds || fractional > 0) 47 | { 48 | result += hours || minutes ? " " : ""; 49 | if (difference < config.duration.fractional_until) 50 | { 51 | result += std::to_string(seconds); 52 | result += std::to_string(fractional).substr(1, 1 + config.duration.precision); 53 | } 54 | else 55 | { 56 | result += std::to_string(static_cast(round(seconds + fractional))); 57 | } 58 | result += 's'; 59 | } 60 | return result; 61 | } 62 | 63 | // ----------------------------------- TESTS ----------------------------------- 64 | #ifdef TEST 65 | #include "test.hpp" 66 | 67 | TEST_CASE("duration") 68 | { 69 | Context context; 70 | context.config.duration.precision = 1; 71 | context.config.duration.threshold = 1; 72 | context.config.duration.fractional_until = 5; 73 | context.args.start_time = 0; 74 | context.args.finish_time = 0; 75 | SUBCASE("empty if start time is zero") 76 | { 77 | context.args.start_time = 0; 78 | context.args.finish_time = 10; 79 | CHECK(duration(context) == ""); 80 | } 81 | SUBCASE("empty if finish time is zero") 82 | { 83 | context.args.start_time = 10; 84 | context.args.finish_time = 0; 85 | CHECK(duration(context) == ""); 86 | } 87 | SUBCASE("empty if less than threshold") 88 | { 89 | context.config.duration.threshold = 10; 90 | context.args.start_time = 1; 91 | context.args.finish_time = 10; 92 | CHECK(duration(context) == ""); 93 | } 94 | SUBCASE("correct fractional") 95 | { 96 | context.config.duration.precision = 4; 97 | context.config.duration.threshold = 1; 98 | context.args.start_time = 3.5; 99 | context.args.finish_time = 5.512345; 100 | CHECK(duration(context) == "2.0123s"); 101 | } 102 | SUBCASE("skip fractional above fractional_until") 103 | { 104 | context.config.duration.precision = 4; 105 | context.config.duration.fractional_until = 5; 106 | context.args.start_time = 1; 107 | context.args.finish_time = 6.412345; 108 | CHECK(duration(context) == "5s"); 109 | } 110 | SUBCASE("correct rounding down") 111 | { 112 | context.config.duration.threshold = 1; 113 | context.config.duration.fractional_until = 5; 114 | context.args.start_time = 1; 115 | context.args.finish_time = 6.4; 116 | CHECK(duration(context) == "5s"); 117 | } 118 | SUBCASE("correct rounding up") 119 | { 120 | context.config.duration.threshold = 1; 121 | context.config.duration.fractional_until = 5; 122 | context.args.start_time = 1; 123 | context.args.finish_time = 6.5; 124 | CHECK(duration(context) == "6s"); 125 | } 126 | SUBCASE("correct seconds") 127 | { 128 | context.config.duration.precision = 1; 129 | context.args.start_time = 3; 130 | context.args.finish_time = 30.4; 131 | CHECK(duration(context) == "27s"); 132 | } 133 | SUBCASE("correct minutes") 134 | { 135 | context.args.start_time = 3; 136 | context.args.finish_time = 300.4; 137 | CHECK(duration(context) == "4m 57s"); 138 | } 139 | SUBCASE("correct hours") 140 | { 141 | context.args.start_time = 3; 142 | context.args.finish_time = 5900.4; 143 | CHECK(duration(context) == "1h 38m 17s"); 144 | } 145 | } 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /src/modules/git_branch.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "context.hpp" 6 | #include "util.hpp" 7 | 8 | // Active branch in the repository 9 | std::string git_branch(const Context &context) 10 | { 11 | const Config &config = context.config; 12 | if (!context.git_repository_detected) 13 | { 14 | return ""; 15 | } 16 | else if (context.git_repository_detached && !config.git_branch.show_when_detached) 17 | { 18 | return ""; 19 | } 20 | std::string result = ""; 21 | result += execute_command("git name-rev --name-only HEAD"); 22 | strip(result); 23 | regex_replace( 24 | result, 25 | { 26 | "[~^]\\d*$", 27 | "^tags\\/" 28 | }, 29 | "" 30 | ); 31 | if (!regex_find_all(result, config.git_branch.ignore).empty()) 32 | { 33 | result = ""; 34 | } 35 | return result; 36 | } 37 | 38 | // ----------------------------------- TESTS ----------------------------------- 39 | #ifdef TEST 40 | #include "test.hpp" 41 | 42 | TEST_CASE("git_branch") 43 | { 44 | Context context; 45 | SUBCASE("not a repository") 46 | { 47 | context.git_repository_detected = false; 48 | context.git_repository_detached = false; 49 | CHECK(git_branch(context) == ""); 50 | } 51 | SUBCASE("branch") 52 | { 53 | context.PWD = get_env("PWD"); 54 | context.git_repository_detected = true; 55 | context.git_repository_detached = false; 56 | CHECK(git_branch(context) == "master"); 57 | } 58 | SUBCASE("hide detached") 59 | { 60 | context.PWD = get_env("PWD"); 61 | context.git_repository_detected = true; 62 | context.git_repository_detached = true; 63 | CHECK(git_branch(context) == ""); 64 | } 65 | SUBCASE("show detached") 66 | { 67 | context.PWD = get_env("PWD"); 68 | context.git_repository_detected = true; 69 | context.git_repository_detached = true; 70 | context.config.git_branch.show_when_detached = true; 71 | CHECK(git_branch(context) != ""); 72 | } 73 | SUBCASE("ignored branch") 74 | { 75 | context.PWD = get_env("PWD"); 76 | context.git_repository_detected = true; 77 | context.git_repository_detached = false; 78 | context.config.git_branch.ignore = {"master"}; 79 | CHECK(git_branch(context) == ""); 80 | } 81 | } 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /src/modules/git_commit.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "context.hpp" 6 | #include "util.hpp" 7 | 8 | // Commit hash 9 | std::string git_commit(const Context &context) 10 | { 11 | const Config &config = context.config; 12 | if (!context.git_repository_detected) 13 | { 14 | return ""; 15 | } 16 | else if (!context.git_repository_detached && !config.git_commit.show_when_attached) 17 | { 18 | return ""; 19 | } 20 | std::string result = ""; 21 | const int length = config.git_commit.length > 0 ? config.git_commit.length : 99; 22 | result += execute_command("git rev-parse --short=" + std::to_string(length) + " HEAD"); 23 | strip(result); 24 | return result; 25 | } 26 | 27 | // ----------------------------------- TESTS ----------------------------------- 28 | #ifdef TEST 29 | #include "test.hpp" 30 | 31 | TEST_CASE("git_commit") 32 | { 33 | Context context; 34 | SUBCASE("not a repository") 35 | { 36 | context.git_repository_detected = false; 37 | context.git_repository_detached = true; 38 | CHECK(git_commit(context) == ""); 39 | } 40 | SUBCASE("hide if not detached") 41 | { 42 | context.PWD = get_env("PWD"); 43 | context.git_repository_detected = true; 44 | context.git_repository_detached = false; 45 | CHECK(git_commit(context) == ""); 46 | } 47 | SUBCASE("show if not detached") 48 | { 49 | context.PWD = get_env("PWD"); 50 | context.git_repository_detected = true; 51 | context.git_repository_detached = false; 52 | context.config.git_commit.show_when_attached = true; 53 | CHECK(git_commit(context) != ""); 54 | } 55 | SUBCASE("commit trimmed") 56 | { 57 | context.PWD = get_env("PWD"); 58 | context.git_repository_detected = true; 59 | context.git_repository_detached = true; 60 | context.config.git_commit.length = 8; 61 | CHECK(git_commit(context).length() == 8); 62 | } 63 | SUBCASE("commit not trimmed") 64 | { 65 | context.PWD = get_env("PWD"); 66 | context.git_repository_detected = true; 67 | context.git_repository_detached = true; 68 | context.config.git_commit.length = 0; 69 | CHECK(git_commit(context).length() > 8); 70 | } 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/modules/git_status.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "types.hpp" 6 | #include "context.hpp" 7 | #include "util.hpp" 8 | 9 | // Symbols indicating the current state of the repository 10 | std::string git_status(const Context &context) 11 | { 12 | if (!context.git_repository_detected) 13 | { 14 | return ""; 15 | } 16 | const Config &config = context.config; 17 | std::string result = ""; 18 | auto add_status = [&config, &result](const std::size_t count, const std::string &symbol) 19 | { 20 | if (count && !symbol.empty()) 21 | { 22 | result += config.git_status.count ? std::to_string(count) : ""; 23 | result += symbol; 24 | result += config.git_status.spacing; 25 | } 26 | }; 27 | std::string status = execute_command("git status --porcelain=v2 --branch --show-stash"); 28 | StringVector ahead_behind = regex_find_all(status, {"(?<=^# branch\\.ab \\+).*?(?=\n)"}); 29 | if (!ahead_behind.empty()) 30 | { 31 | ahead_behind = split(ahead_behind.at(0), " -"); 32 | add_status(std::stoul(ahead_behind.at(0)), config.git_status.ahead); 33 | add_status(std::stoul(ahead_behind.at(1)), config.git_status.behind); 34 | } 35 | const StringVector stashed = regex_find_all(status, {"(?<=^# stash )\\d+"}); 36 | if (!stashed.empty()) 37 | { 38 | add_status(std::stoul(stashed.at(0)), config.git_status.stashed); 39 | } 40 | add_status(regex_find_all(status, {"^\\? "}).size(), config.git_status.untracked); 41 | add_status(regex_find_all(status, {"^u "}).size(), config.git_status.conflicted); 42 | add_status(regex_find_all(status, {"^\\d .M "}).size(), config.git_status.modified); 43 | add_status(regex_find_all(status, {"^\\d [AM]. "}).size(), config.git_status.staged); 44 | add_status(regex_find_all(status, {"^\\d R. "}).size(), config.git_status.renamed); 45 | add_status(regex_find_all(status, {"^\\d .D "}).size(), config.git_status.deleted); 46 | if (result.empty()) 47 | { 48 | result += config.git_status.clean; 49 | } 50 | else 51 | { 52 | result = result.substr(0, result.length() - config.git_status.spacing.length()); 53 | } 54 | return result; 55 | } 56 | 57 | // ----------------------------------- TESTS ----------------------------------- 58 | #ifdef TEST 59 | #include "test.hpp" 60 | 61 | TEST_CASE("git_status") 62 | { 63 | Context context; 64 | SUBCASE("not a repository") 65 | { 66 | context.git_repository_detected = false; 67 | CHECK(git_status(context) == ""); 68 | } 69 | SUBCASE("status") 70 | { 71 | context.HOME = get_env("HOME"); 72 | context.PWD = get_env("PWD"); 73 | context.git_repository_detected = true; 74 | CHECK(git_status(context).length() > 0); 75 | } 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/modules/host.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "context.hpp" 6 | #include "util.hpp" 7 | 8 | // Hostname 9 | std::string host(const Context &context) 10 | { 11 | (void)context; 12 | std::string result = ""; 13 | result += execute_command("cat /etc/hostname"); 14 | strip(result); 15 | return result; 16 | } 17 | 18 | // ----------------------------------- TESTS ----------------------------------- 19 | #ifdef TEST 20 | #include "test.hpp" 21 | 22 | TEST_CASE("host") 23 | { 24 | Context context; 25 | CHECK(host(context).length() > 0); 26 | } 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/modules/shell.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "context.hpp" 6 | 7 | // Currently active shell 8 | std::string shell(const Context &context) 9 | { 10 | return context.args.shell; 11 | } 12 | 13 | // ----------------------------------- TESTS ----------------------------------- 14 | #ifdef TEST 15 | #include "test.hpp" 16 | 17 | TEST_CASE("shell") 18 | { 19 | Context context; 20 | context.args.shell = "abc"; 21 | CHECK(shell(context) == "abc"); 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/modules/status.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "context.hpp" 6 | 7 | // Exit status of the last command 8 | std::string status(const Context &context) 9 | { 10 | if (context.args.status == 0 && !context.config.status.show_zero) 11 | { 12 | return ""; 13 | } 14 | return std::to_string(context.args.status); 15 | } 16 | 17 | // ----------------------------------- TESTS ----------------------------------- 18 | #ifdef TEST 19 | #include "test.hpp" 20 | 21 | TEST_CASE("status") 22 | { 23 | Context context; 24 | context.config.status.show_zero = false; 25 | context.args.status = 0; 26 | SUBCASE("empty if status is zero and show_zero is false") 27 | { 28 | CHECK(status(context) == ""); 29 | } 30 | SUBCASE("correct status 0") 31 | { 32 | context.config.status.show_zero = true; 33 | CHECK(status(context) == "0"); 34 | } 35 | SUBCASE("correct positive status") 36 | { 37 | context.args.status = 255; 38 | CHECK(status(context) == "255"); 39 | } 40 | SUBCASE("correct negative status") 41 | { 42 | context.args.status = -255; 43 | CHECK(status(context) == "-255"); 44 | } 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/modules/time.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "context.hpp" 6 | #include "util.hpp" 7 | 8 | // Current time 9 | std::string time(const Context &context) 10 | { 11 | const Config &config = context.config; 12 | return format_time(context.time_structure, config.time.format); 13 | } 14 | 15 | // ----------------------------------- TESTS ----------------------------------- 16 | #ifdef TEST 17 | #include "test.hpp" 18 | 19 | TEST_CASE("time") 20 | { 21 | Context context; 22 | context.time_structure.tm_gmtoff = 7200; 23 | context.time_structure.tm_isdst = 1; 24 | context.time_structure.tm_yday = 215; 25 | context.time_structure.tm_wday = 6; 26 | context.time_structure.tm_year = 124; 27 | context.time_structure.tm_mon = 7; 28 | context.time_structure.tm_mday = 3; 29 | context.time_structure.tm_hour = 20; 30 | context.time_structure.tm_min = 4; 31 | context.time_structure.tm_sec = 34; 32 | SUBCASE("correct time %R format") 33 | { 34 | context.config.time.format = "%R"; 35 | CHECK(time(context) == "20:04"); 36 | } 37 | SUBCASE("correct time %T format") 38 | { 39 | context.config.time.format = "%T"; 40 | CHECK(time(context) == "20:04:34"); 41 | } 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/modules/user.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "context.hpp" 6 | #include "util.hpp" 7 | 8 | // Current user 9 | std::string user(const Context &context) 10 | { 11 | (void)context; 12 | return get_env("USER"); 13 | } 14 | 15 | // ----------------------------------- TESTS ----------------------------------- 16 | #ifdef TEST 17 | #include "test.hpp" 18 | 19 | TEST_CASE("user") 20 | { 21 | Context context; 22 | CHECK(user(context).length() > 0); 23 | } 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/pool.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "thread-pool/BS_thread_pool.hpp" 4 | 5 | #define THREAD_LIMIT 4U 6 | 7 | inline BS::thread_pool thread_pool(std::min(std::thread::hardware_concurrency(), THREAD_LIMIT)); 8 | 9 | // ----------------------------------- TESTS ----------------------------------- 10 | #ifdef TEST 11 | #include "test.hpp" 12 | 13 | TEST_CASE("thread count") 14 | { 15 | const std::size_t thread_count = thread_pool.get_thread_count(); 16 | CHECK(thread_count > 0); 17 | CHECK(thread_count <= THREAD_LIMIT); 18 | } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/print.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "context.hpp" 4 | 5 | // Print the modules and the prompt 6 | void print_prompt(Context &context); 7 | 8 | // Print the right prompt 9 | void print_right_prompt(Context &context); 10 | 11 | // Print the transient prompt 12 | void print_transient_prompt(Context &context); 13 | -------------------------------------------------------------------------------- /src/test.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT 2 | 3 | #include "test.hpp" 4 | 5 | #ifdef TEST 6 | #include 7 | 8 | void run_tests(int argc, const char* const* argv) 9 | { 10 | doctest::Context context; 11 | context.setOption("no-breaks", true); 12 | context.applyCommandLine(argc, argv); 13 | int result = context.run(); 14 | if (context.shouldExit()) 15 | { 16 | std::exit(result); 17 | } 18 | } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/test.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef TEST 4 | 5 | #include "doctest/doctest.h" 6 | 7 | // Run test cases 8 | void run_tests(int argc, const char* const* argv); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/types.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | using StringVector = std::vector; 7 | -------------------------------------------------------------------------------- /src/util.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "types.hpp" 7 | 8 | // Terminal window size 9 | winsize get_winsize(); 10 | 11 | // Number of displayed characters in the strings 12 | std::size_t get_length(const StringVector &strings); 13 | 14 | // Find the start index of the nth occurrence of a substring in a string 15 | std::size_t find_nth_occurrence(const std::string &string, const std::string &substring, const std::size_t n, const bool reverse=false); 16 | 17 | // Split the string at delimiters 18 | StringVector split(const std::string &string, const std::string &delimiter); 19 | 20 | // Join the strings at delimiters 21 | std::string join(const StringVector &strings, const std::string &delimiter); 22 | 23 | // Multiply string n times 24 | std::string multiply_string(const int number, const std::string &string); 25 | 26 | // Replace parts in-place 27 | void regex_replace(std::string &string, const StringVector &patterns, const std::string &replacement); 28 | 29 | // Find all occurences 30 | StringVector regex_find_all(const std::string &string, const StringVector &patterns); 31 | 32 | // Strip whitespace from beginning/end of string 33 | void strip(std::string &string); 34 | 35 | // Execute command in shell 36 | std::string execute_command(const std::string &command, int *status=nullptr); 37 | 38 | // Check the presence and state of the current repository 39 | void check_git_repository(bool &detected, bool &detached); 40 | 41 | // Read ENV variables. Always returns string to allow concatenation 42 | std::string get_env(const std::string &name); 43 | 44 | // System time 45 | std::tm get_current_time(); 46 | 47 | // Formatted time representation 48 | std::string format_time(const std::tm &time_structure, const std::string &format); 49 | 50 | // Check if every character in the string is a digit 51 | bool is_number(const std::string &string); 52 | -------------------------------------------------------------------------------- /use_config: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | src_dir=./config 4 | src_file=$src_dir/$1.toml 5 | dest_dir=~/.config/blaze 6 | dest_file=$dest_dir/config.toml 7 | 8 | if [[ $# -eq 0 ]]; then 9 | echo "Select a config from the list:" 10 | for entry in $src_dir/*; do 11 | echo $(basename $entry .toml) 12 | done 13 | exit 1 14 | fi 15 | 16 | if [[ ! -f $src_file ]]; then 17 | echo "No such file as $src_file" 18 | echo "Run the command without arguments to see the available configs" 19 | exit 1 20 | fi 21 | 22 | mkdir -p $dest_dir 23 | cp $src_file $dest_file 24 | echo "Config copied to $dest_file" 25 | --------------------------------------------------------------------------------