├── .gitattributes ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── build ├── Makefile ├── Makefile.Build ├── Makefile.Project ├── capo.sln ├── capo.vcxproj └── capo.vcxproj.filters ├── capo ├── assert.hpp ├── cmdline.hpp ├── concept.hpp ├── constant_array.hpp ├── construct.hpp ├── countof.hpp ├── detect_plat.hpp ├── file.hpp ├── force_inline.hpp ├── func_decl.hpp ├── inherit.hpp ├── iterator.hpp ├── make.hpp ├── max_min.hpp ├── memory.hpp ├── memory │ ├── alloc_concept.hpp │ ├── allocator.hpp │ ├── fixed_pool.hpp │ ├── scope_alloc.hpp │ ├── standard_alloc.hpp │ └── variable_pool.hpp ├── noncopyable.hpp ├── operator.hpp ├── output.hpp ├── preprocessor.hpp ├── preprocessor │ ├── pp_arg.hpp │ ├── pp_count.hpp │ ├── pp_functions.hpp │ ├── pp_macros.hpp │ ├── pp_mult.hpp │ ├── pp_nest.hpp │ └── pp_repeat.hpp ├── printf.hpp ├── random.hpp ├── range.hpp ├── scope_guard.hpp ├── semaphore.hpp ├── sequence.hpp ├── signal.hpp ├── singleton.hpp ├── spin_lock.hpp ├── stopwatch.hpp ├── thread_local_ptr.hpp ├── thread_wrapper.hpp ├── trackable.hpp ├── tuple.hpp ├── type_list.hpp ├── type_name.hpp ├── type_traits.hpp ├── types_to_seq.hpp ├── unused.hpp └── waiter.hpp ├── src └── thread_local_ptr.cpp ├── test ├── AllUnitTestsForMSVC │ ├── AllUnitTestsForMSVC.vcxproj │ ├── AllUnitTestsForMSVC.vcxproj.filters │ ├── stdafx.cpp │ ├── stdafx.h │ ├── targetver.h │ └── unittests.cpp ├── ut-assert │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-assert.cpp │ ├── ut-assert.vcxproj │ └── ut-assert.vcxproj.filters ├── ut-cmdline │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-cmdline.cpp │ ├── ut-cmdline.vcxproj │ └── ut-cmdline.vcxproj.filters ├── ut-concept │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-concept.cpp │ ├── ut-concept.vcxproj │ └── ut-concept.vcxproj.filters ├── ut-constant_array │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-constant_array.cpp │ ├── ut-constant_array.vcxproj │ └── ut-constant_array.vcxproj.filters ├── ut-construct │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-construct.cpp │ ├── ut-construct.vcxproj │ └── ut-construct.vcxproj.filters ├── ut-countof │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-countof.cpp │ ├── ut-countof.vcxproj │ └── ut-countof.vcxproj.filters ├── ut-gc │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-gc.cpp │ ├── ut-gc.vcxproj │ └── ut-gc.vcxproj.filters ├── ut-main │ ├── Makefile │ ├── ut-main.cpp │ ├── ut-main.vcxproj │ └── ut-main.vcxproj.filters ├── ut-max_min │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-max_min.cpp │ ├── ut-max_min.vcxproj │ └── ut-max_min.vcxproj.filters ├── ut-memory │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-memory.cpp │ ├── ut-memory.vcxproj │ └── ut-memory.vcxproj.filters ├── ut-operator │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-operator.cpp │ ├── ut-operator.vcxproj │ └── ut-operator.vcxproj.filters ├── ut-preprocessor │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-preprocessor.cpp │ ├── ut-preprocessor.vcxproj │ └── ut-preprocessor.vcxproj.filters ├── ut-printf │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-printf.cpp │ ├── ut-printf.vcxproj │ └── ut-printf.vcxproj.filters ├── ut-range │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-range.cpp │ ├── ut-range.vcxproj │ └── ut-range.vcxproj.filters ├── ut-semaphore │ ├── Makefile │ ├── ut-semaphore.cpp │ ├── ut-semaphore.vcxproj │ └── ut-semaphore.vcxproj.filters ├── ut-sequence │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-sequence.cpp │ ├── ut-sequence.vcxproj │ └── ut-sequence.vcxproj.filters ├── ut-signal │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-signal.cpp │ ├── ut-signal.vcxproj │ └── ut-signal.vcxproj.filters ├── ut-singleton │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-singleton.cpp │ ├── ut-singleton.vcxproj │ └── ut-singleton.vcxproj.filters ├── ut-spin_lock │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-spin_lock.cpp │ ├── ut-spin_lock.vcxproj │ └── ut-spin_lock.vcxproj.filters ├── ut-stopwatch │ ├── Makefile │ ├── ut-stopwatch.cpp │ ├── ut-stopwatch.vcxproj │ └── ut-stopwatch.vcxproj.filters ├── ut-trackable │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-trackable.cpp │ ├── ut-trackable.vcxproj │ └── ut-trackable.vcxproj.filters ├── ut-type_list │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-type_list.cpp │ ├── ut-type_list.vcxproj │ └── ut-type_list.vcxproj.filters ├── ut-type_name │ ├── Makefile │ ├── ut-type_name.cpp │ ├── ut-type_name.vcxproj │ └── ut-type_name.vcxproj.filters ├── ut-types_to_seq │ ├── Makefile │ ├── cases.h │ ├── preparing.h │ ├── ut-types_to_seq.cpp │ ├── ut-types_to_seq.vcxproj │ └── ut-types_to_seq.vcxproj.filters └── ut-waiter │ ├── Makefile │ ├── ut-waiter.cpp │ ├── ut-waiter.vcxproj │ └── ut-waiter.vcxproj.filters └── third └── gtest ├── gtest-death-test.h ├── gtest-message.h ├── gtest-param-test.h ├── gtest-param-test.h.pump ├── gtest-printers.h ├── gtest-spi.h ├── gtest-test-part.h ├── gtest-typed-test.h ├── gtest.h ├── gtest_pred_impl.h ├── gtest_prod.h ├── internal ├── custom │ ├── gtest-port.h │ ├── gtest-printers.h │ └── gtest.h ├── gtest-death-test-internal.h ├── gtest-filepath.h ├── gtest-internal.h ├── gtest-linked_ptr.h ├── gtest-param-util-generated.h ├── gtest-param-util-generated.h.pump ├── gtest-param-util.h ├── gtest-port-arch.h ├── gtest-port.h ├── gtest-string.h ├── gtest-tuple.h ├── gtest-tuple.h.pump ├── gtest-type-util.h └── gtest-type-util.h.pump └── lib ├── mingw32 ├── gtest.a └── gtestd.a ├── mingw64 ├── gtest.a └── gtestd.a ├── msvc32 ├── gtest.lib └── gtestd.lib └── msvc64 ├── gtest.lib └── gtestd.lib /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 133 | #packages/ 134 | 135 | # Windows Azure Build Output 136 | csx 137 | *.build.csdef 138 | 139 | # Windows Store app package directory 140 | AppPackages/ 141 | 142 | # Others 143 | sql/ 144 | *.Cache 145 | ClientBin/ 146 | [Ss]tyle[Cc]op.* 147 | ~$* 148 | *~ 149 | *.dbmdl 150 | *.[Pp]ublish.xml 151 | *.pfx 152 | *.publishsettings 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | App_Data/*.mdf 166 | App_Data/*.ldf 167 | 168 | ############# 169 | ## Windows detritus 170 | ############# 171 | 172 | # Windows image file caches 173 | Thumbs.db 174 | ehthumbs.db 175 | 176 | # Folder config file 177 | Desktop.ini 178 | 179 | # Recycle Bin used on file shares 180 | $RECYCLE.BIN/ 181 | 182 | # Mac crap 183 | .DS_Store 184 | 185 | 186 | ############# 187 | ## Python 188 | ############# 189 | 190 | *.py[co] 191 | 192 | # Packages 193 | *.egg 194 | *.egg-info 195 | dist/ 196 | build/ 197 | eggs/ 198 | parts/ 199 | var/ 200 | sdist/ 201 | develop-eggs/ 202 | .installed.cfg 203 | 204 | # Installer logs 205 | pip-log.txt 206 | 207 | # Unit test / coverage reports 208 | .coverage 209 | .tox 210 | 211 | #Translations 212 | *.mo 213 | 214 | #Mr Developer 215 | .mr.developer.cfg 216 | /build-test-Desktop_Qt_5_2_1_MinGW_32bit-Debug 217 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | matrix: 4 | include: 5 | - os: linux 6 | compiler: gcc 7 | addons: 8 | apt: 9 | sources: 10 | - ubuntu-toolchain-r-test 11 | - george-edison55-precise-backports 12 | packages: 13 | - g++-4.9 14 | - cmake-data 15 | - cmake 16 | env: 17 | - CXX=g++-4.9 18 | - CX=g++-4.9 19 | - CC=gcc-4.9 20 | 21 | - os: linux 22 | compiler: clang 23 | addons: 24 | apt: 25 | sources: 26 | - ubuntu-toolchain-r-test 27 | - george-edison55-precise-backports 28 | packages: 29 | - clang-3.4 30 | - g++-4.8 31 | - cmake-data 32 | - cmake 33 | env: 34 | - CXX=clang++ 35 | - CX=clang++ 36 | - CC=clang 37 | 38 | install: 39 | - $CX --version 40 | 41 | before_script: 42 | - sudo apt-get -qq install libgtest-dev 43 | - pushd /usr/src/gtest 44 | - sudo cmake CMakeLists.txt 45 | - sudo make 46 | - sudo cp *.a /usr/lib 47 | - popd 48 | 49 | script: 50 | - cd ./build && make bits=64 51 | - for filename in $( ls ./bin/release/$CC); do ./bin/release/$CC/$filename; done 52 | 53 | notifications: 54 | slack: 55 | on_success: never 56 | on_failure: never 57 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The Capo Library - Lightweight C++ Standard Library Expansion (https://github.com/mutouyun/capo) 2 | Copyright (c) 2014, mutouyun (http://orzz.org). All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Capo Library 2 | 3 | C++标准库的轻量级拓展 4 | 5 | [![Build Status](https://travis-ci.org/mutouyun/capo.svg?branch=master)](https://travis-ci.org/mutouyun/capo) 6 | [![Build status](https://ci.appveyor.com/api/projects/status/n4loffu8ut15crgi/branch/master?svg=true)](https://ci.appveyor.com/project/mutouyun/capo) 7 | 8 | * 支持的编译器(C++14以上): msvc(vc2015+), gcc(4.9.2+), clang(3.4.0+). 9 | * 每个功能都是独立的头文件(hpp), 除了Win下的thread_local_ptr之外, 不需要编译. 10 | 11 | ## 12 | 13 | - build -> sln && Makefiles 14 | - capo -> 所有的公开接口及实现 15 | - src -> 需要编译的代码,及私有接口和实现 16 | - test -> 测试用例 17 | - third -> 引入的第三方库 18 | 19 | ### ToDoList 20 | 21 | string.string - std::string的功能拓展 22 | proofing.trace - 调试输出 23 | thread.blocking_queue - 多线程下的blocking_queue 24 | thread.thread_pool - 线程池 25 | coroutine - 协程库 26 | ...... 27 | -------------------------------------------------------------------------------- /build/Makefile: -------------------------------------------------------------------------------- 1 | # Define exports 2 | 3 | export CC ?= gcc 4 | export CX ?= g++ 5 | export LB ?= ar 6 | 7 | export CFLAGS ?= -pipe -frtti -Wall -Wextra -fexceptions -march=nocona -std=c++1y 8 | export LFLAGS ?= -Wl,-s 9 | export AFLAGS ?= -csr 10 | 11 | # Check os 12 | 13 | export os = linux 14 | export debug = 0 15 | export bits = 32 16 | 17 | ifeq ($(os), win) 18 | # windows 19 | LFLAGS += -Wl,-subsystem,console -mthreads 20 | MK = mkdir 21 | RM = rmdir /s /q 22 | LIB_DIR = mingw$(bits) 23 | export THIRD_PATH = $(WORK_PATH)/third 24 | ifeq ($(debug), 0) 25 | export THIRD_LIB = $(THIRD_PATH)/gtest/lib/$(LIB_DIR)/gtest.a 26 | else 27 | export THIRD_LIB = $(THIRD_PATH)/gtest/lib/$(LIB_DIR)/gtestd.a 28 | endif 29 | else 30 | # linux or others 31 | LFLAGS += -pthread 32 | MK = mkdir -p 33 | RM = rm -r 34 | LIB_DIR = $(os)-$(CX) 35 | export THIRD_PATH = 36 | export THIRD_LIB = -lgtest 37 | endif 38 | 39 | # Define workspace 40 | 41 | export WORK_PATH ?= $(CURDIR)/.. 42 | export BUILD_PATH ?= $(CURDIR) 43 | export TESTS_PATH = $(WORK_PATH)/test 44 | export INCPATH = -I$(WORK_PATH) 45 | ifneq ($(THIRD_PATH),) 46 | INCPATH += -I$(THIRD_PATH) 47 | endif 48 | 49 | ifeq ($(debug), 0) 50 | # release 51 | CFLAGS += -O2 -DNDEBUG 52 | CONFIG_DIR = release 53 | else 54 | # debug 55 | CFLAGS += -g 56 | CONFIG_DIR = debug 57 | endif 58 | 59 | ifeq ($(bits), 32) 60 | # 32-bit 61 | CFLAGS += -m32 62 | LFLAGS += -m32 63 | else 64 | # 64-bit 65 | CFLAGS += -m64 66 | LFLAGS += -m64 67 | endif 68 | 69 | # Output directory 70 | 71 | export OUT = $(BUILD_PATH)/bin/$(CONFIG_DIR)/$(CC) 72 | export TMP = $(BUILD_PATH)/tmp/$(CONFIG_DIR)/$(CC) 73 | 74 | # Project 75 | 76 | PRO_NAME = capo 77 | SRC_PATH = $(WORK_PATH)/src 78 | SRC_FILES = \ 79 | $(SRC_PATH)/thread_local_ptr.cpp 80 | 81 | MODULES = \ 82 | ut-main ut-preprocessor ut-type_name ut-type_list \ 83 | ut-concept ut-constant_array ut-types_to_seq ut-countof \ 84 | ut-operator ut-max_min ut-sequence ut-range \ 85 | ut-stopwatch ut-printf ut-assert ut-spin_lock \ 86 | ut-semaphore ut-waiter ut-construct ut-signal \ 87 | ut-gc ut-singleton ut-memory ut-trackable ut-cmdline 88 | 89 | BUILD_RULES = $(PRO_NAME) $(MODULES) 90 | include $(BUILD_PATH)/Makefile.Project 91 | 92 | # Build 93 | 94 | BUILD_TYPE = lib 95 | DEPEND_TARGET = output begin 96 | include $(BUILD_PATH)/Makefile.Build 97 | 98 | export DEPEND = $(OUT)/ut-main.a $(OUT)/$(PRO_NAME).a 99 | $(MODULES): output 100 | @$(MAKE) -C $(TESTS_PATH)/$@ 101 | 102 | # Targets 103 | 104 | output: 105 | @echo Making directorys... 106 | @-$(MK) "$(OUT)" 107 | @-$(MK) "$(TMP)" 108 | @echo Making complete. 109 | 110 | clean: 111 | @echo Cleaning directorys... 112 | @-$(RM) "$(TMP)" 113 | @-$(RM) "$(OUT)" 114 | @echo Clean complete. 115 | 116 | distclean: 117 | @echo Cleaning directorys... 118 | @-$(RM) "$(BUILD_PATH)/tmp" 119 | @-$(RM) "$(BUILD_PATH)/bin" 120 | @echo Clean complete. 121 | 122 | # PHONY 123 | 124 | .PHONY: all clean distclean 125 | -------------------------------------------------------------------------------- /build/Makefile.Build: -------------------------------------------------------------------------------- 1 | # Check windows, for fixing GNU Make exception: 2 | # See: http://win-builds.org/bugs/index.php?do=details&task_id=113 3 | 4 | ifeq ($(os), win) 5 | SHELL = C:/Windows/system32/cmd.exe 6 | endif 7 | 8 | # Build rules 9 | 10 | all: $(BUILD_RULES) 11 | 12 | begin: 13 | @echo "" 14 | @echo ================================ 15 | @echo - Building: $(PRO_NAME)... 16 | @echo ================================ 17 | @echo "" 18 | 19 | # Compile 20 | 21 | $(OBJ_FILES): $(OBJ_PATH)/%.o: $(SRC_PATH)/%.cpp $(INC_FILES) $(DEPEND_TARGET) 22 | @echo Compiling $<... 23 | @$(CX) $(CFLAGS) -o $@ $(INCPATH) -c $< 24 | 25 | $(PRO_NAME): $(OBJ_FILES) $(DEPEND) 26 | ifeq ($(BUILD_TYPE), lib) 27 | @echo Linking $@.a... 28 | @$(AR) $(AFLAGS) $(OUT)/$@.a $^ 29 | else 30 | @echo Linking $@... 31 | @$(CX) $(LFLAGS) -o $(OUT)/$@ $^ $(THIRD_LIB) 32 | endif 33 | @echo "" 34 | @echo - Building complete: $(PRO_NAME). 35 | @echo "" 36 | -------------------------------------------------------------------------------- /build/Makefile.Project: -------------------------------------------------------------------------------- 1 | # Project 2 | 3 | SRC_PATH ?= . 4 | OBJ_PATH ?= $(TMP) 5 | OBJ_FILES = $(patsubst $(SRC_PATH)/%.cpp, $(OBJ_PATH)/%.o, $(SRC_FILES)) 6 | 7 | BUILD_RULES ?= begin $(PRO_NAME) 8 | -------------------------------------------------------------------------------- /capo/cmdline.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | The Capo Library 3 | Code covered by the MIT License 4 | 5 | Author: mutouyun (http://orzz.org) 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "capo/output.hpp" 11 | 12 | #include // std::string 13 | #include // std::function 14 | #include // std::cout 15 | #include // std::forward 16 | #include // std::vector 17 | 18 | namespace capo { 19 | namespace cmdline { 20 | 21 | class parser; 22 | using handle_t = void(const parser&, const std::string&); 23 | 24 | struct option 25 | { 26 | const char* sname_; 27 | const char* lname_; 28 | const char* description_; 29 | bool necessary_; 30 | std::string default_; 31 | std::function handle_; 32 | }; 33 | 34 | using options = std::vector