├── README.md └── examples ├── ch01 └── GuessNumber.cpp ├── ch02 ├── fig02_01.cpp ├── fig02_02.cpp ├── fig02_03.cpp ├── fig02_04.cpp ├── fig02_05.cpp └── fig02_06.cpp ├── ch03 ├── fig03_01.cpp ├── fig03_02.cpp ├── fig03_03.cpp ├── fig03_04.cpp ├── fig03_05 │ ├── BigNumber │ │ ├── CMakeLists.txt │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── bin │ │ │ └── BigNumber │ │ │ │ ├── include │ │ │ │ └── bignumber.h │ │ │ │ └── lib │ │ │ │ └── libBigNumber.a │ │ ├── main.cpp │ │ └── src │ │ │ ├── bignumber.cpp │ │ │ └── bignumber.h │ └── fig03_05.cpp └── fig03_06 │ ├── fig03_06.cpp │ ├── fmt │ ├── core.h │ ├── format-inl.h │ └── format.h │ └── format.cc ├── ch04 ├── fig04_01.cpp ├── fig04_02.cpp ├── fig04_03.cpp ├── fig04_04.cpp ├── fig04_05.cpp ├── fig04_06.cpp ├── fig04_07.cpp ├── fig04_07_with_error.cpp ├── fig04_08.cpp ├── fig04_09.cpp ├── fig04_10.cpp ├── fig04_11.cpp └── fig04_12.cpp ├── ch05 ├── cipher.h ├── fig05_01.cpp ├── fig05_02.cpp ├── fig05_03.cpp ├── fig05_04.cpp ├── fig05_05.cpp ├── fig05_06.cpp ├── fig05_07.cpp ├── fig05_08.cpp ├── fig05_09.cpp ├── fig05_10.cpp ├── fig05_11.cpp ├── fig05_12.cpp ├── fig05_14.cpp ├── fig05_15.cpp ├── fig05_16.cpp ├── fig05_17.cpp ├── fig05_18.cpp └── maximum.h ├── ch06 ├── fig06_01.cpp ├── fig06_02.cpp ├── fig06_03.cpp ├── fig06_04.cpp ├── fig06_05.cpp ├── fig06_06.cpp ├── fig06_07.cpp ├── fig06_08.cpp ├── fig06_09.cpp ├── fig06_10.cpp ├── fig06_11.cpp ├── fig06_12.cpp ├── fig06_13.cpp └── fig06_14.cpp ├── ch07 ├── fig07_01.cpp ├── fig07_02.cpp ├── fig07_03.cpp ├── fig07_06.cpp ├── fig07_07.cpp ├── fig07_08.cpp ├── fig07_09.cpp ├── fig07_10.cpp ├── fig07_11.cpp ├── fig07_12.cpp ├── fig07_13.cpp └── fig07_14.cpp ├── ch08 ├── accounts.csv ├── fig08_01.cpp ├── fig08_02.cpp ├── fig08_03.cpp ├── fig08_04.cpp ├── fig08_05.cpp ├── fig08_06.cpp ├── fig08_07.cpp ├── fig08_08.cpp ├── fig08_09.cpp ├── fig08_10.cpp ├── fig08_11.cpp ├── fig08_12.cpp ├── fig08_13.cpp ├── fig08_14.cpp ├── fig08_15.cpp ├── fig08_16.cpp ├── fig08_17.cpp ├── fig08_18.cpp ├── format.cc └── titanic.csv ├── ch09 ├── fig09_01-02 │ ├── Account.h │ └── AccountTest.cpp ├── fig09_03-04 │ ├── Account.h │ └── AccountTest.cpp ├── fig09_05-06 │ ├── Account.h │ └── AccountTest.cpp ├── fig09_07-09 │ ├── Time.cpp │ ├── Time.h │ └── fig09_09.cpp ├── fig09_10-12 │ ├── Time.cpp │ ├── Time.h │ └── fig09_12.cpp ├── fig09_13-15 │ ├── CreateAndDestroy.cpp │ ├── CreateAndDestroy.h │ └── fig09_15.cpp ├── fig09_16-18 │ ├── Time.cpp │ ├── Time.h │ └── fig09_18.cpp ├── fig09_19-21 │ ├── Date.cpp │ ├── Date.h │ └── fig09_21.cpp ├── fig09_22 │ ├── Time.cpp │ ├── Time.h │ └── fig09_22.cpp ├── fig09_23-27 │ ├── Date.cpp │ ├── Date.h │ ├── Employee.cpp │ ├── Employee.h │ └── fig09_27.cpp ├── fig09_28 │ └── fig09_28.cpp ├── fig09_29 │ └── fig09_29.cpp ├── fig09_30-32 │ ├── Time.cpp │ ├── Time.h │ └── fig09_32.cpp ├── fig09_33-35 │ ├── Employee.cpp │ ├── Employee.h │ └── fig09_35.cpp ├── fig09_36 │ ├── fig09_36.cpp │ └── records.json └── fig09_37 │ └── fig09_37.cpp ├── ch10 ├── fig10_01-03 │ ├── SalariedEmployee.cpp │ ├── SalariedEmployee.h │ └── fig10_03.cpp ├── fig10_04-06 │ ├── SalariedCommissionEmployee.cpp │ ├── SalariedCommissionEmployee.h │ ├── SalariedEmployee.cpp │ ├── SalariedEmployee.h │ └── fig10_06.cpp ├── fig10_07 │ ├── SalariedCommissionEmployee.cpp │ ├── SalariedCommissionEmployee.h │ ├── SalariedEmployee.cpp │ ├── SalariedEmployee.h │ └── fig10_07.cpp ├── fig10_08 │ ├── SalariedCommissionEmployee.cpp │ ├── SalariedCommissionEmployee.h │ ├── SalariedEmployee.cpp │ ├── SalariedEmployee.h │ └── fig10_08.cpp ├── fig10_09 │ ├── SalariedCommissionEmployee.cpp │ ├── SalariedCommissionEmployee.h │ ├── SalariedEmployee.cpp │ ├── SalariedEmployee.h │ └── fig10_09.cpp ├── fig10_10 │ ├── SalariedCommissionEmployee.cpp │ ├── SalariedCommissionEmployee.h │ ├── SalariedEmployee.cpp │ ├── SalariedEmployee.h │ └── fig10_10.cpp ├── fig10_11-17 │ ├── CommissionEmployee.cpp │ ├── CommissionEmployee.h │ ├── Employee.cpp │ ├── Employee.h │ ├── SalariedEmployee.cpp │ ├── SalariedEmployee.h │ └── fig10_17.cpp ├── fig10_19-25 │ ├── CommissionEmployee.cpp │ ├── CommissionEmployee.h │ ├── Employee.cpp │ ├── Employee.h │ ├── SalariedEmployee.cpp │ ├── SalariedEmployee.h │ └── fig10_25.cpp ├── fig10_26-33 │ ├── Commission.cpp │ ├── Commission.h │ ├── CompensationModel.h │ ├── Employee.cpp │ ├── Employee.h │ ├── Salaried.cpp │ ├── Salaried.h │ └── fig10_33.cpp ├── fig10_34-40 │ ├── Commission.cpp │ ├── Commission.h │ ├── Employee.cpp │ ├── Employee.h │ ├── Salaried.cpp │ ├── Salaried.h │ └── fig10_40.cpp ├── fig10_41-45 │ ├── Base1.h │ ├── Base2.h │ ├── Derived.cpp │ ├── Derived.h │ └── fig10_45.cpp ├── fig10_46 │ └── fig10_46.cpp └── fig10_47 │ └── fig10_47.cpp ├── ch11 ├── fig11_01 │ └── fig11_01.cpp ├── fig11_02 │ └── fig11_02.cpp ├── fig11_03-05 │ ├── MyArray.cpp │ ├── MyArray.h │ └── fig11_03.cpp ├── fig11_06 │ └── fig11_06.cpp ├── fig11_07 │ ├── MyArray.cpp │ ├── MyArray.h │ └── fig11_07.cpp └── fig11_08 │ ├── MyArray.cpp │ ├── MyArray.h │ └── fig11_08.cpp ├── ch12 ├── fig12_01-02 │ ├── DivideByZeroException.h │ └── fig12_02.cpp ├── fig12_03 │ └── fig12_03.cpp ├── fig12_04 │ ├── fig12_04.cpp │ └── fig12_04modified.cpp ├── fig12_05 │ └── fig12_05.cpp ├── fig12_06 │ └── fig12_06.cpp ├── fig12_07 │ └── fig12_07.cpp ├── fig12_08 │ └── fig12_08.cpp └── fig12_09 │ └── fig12_09.cpp ├── ch13 ├── fig13_01.cpp ├── fig13_02.cpp ├── fig13_03.cpp ├── fig13_04.cpp ├── fig13_05.cpp ├── fig13_06.cpp ├── fig13_07.cpp ├── fig13_08.cpp ├── fig13_09.cpp ├── fig13_10.cpp ├── fig13_11.cpp └── fig13_12.cpp ├── ch14 ├── fig14_01.cpp ├── fig14_02.cpp ├── fig14_03.cpp ├── fig14_04.cpp ├── fig14_05.cpp ├── fig14_06.cpp ├── fig14_07.cpp ├── fig14_08.cpp ├── fig14_09.cpp ├── fig14_10.cpp ├── fig14_11.cpp ├── fig14_12.cpp ├── fig14_13.cpp ├── fig14_14.cpp ├── fig14_15.cpp ├── fig14_16.cpp ├── fig14_17.cpp └── fig14_18.cpp ├── ch15 ├── fig15_01-02 │ ├── Stack.h │ └── fig15_02.cpp ├── fig15_03.cpp ├── fig15_04.cpp ├── fig15_05.cpp ├── fig15_06.cpp ├── fig15_07.cpp ├── fig15_08.cpp ├── fig15_09.cpp ├── fig15_10.cpp ├── fig15_11-12 │ ├── MyArray.h │ └── fig15_12.cpp ├── fig15_13.cpp ├── fig15_14.cpp ├── fig15_15.cpp ├── fig15_16.cpp ├── fig15_17.cpp ├── fig15_18.cpp ├── fig15_19.cpp ├── fig15_20.cpp └── fig15_21.cpp ├── ch16 ├── fig16_01 │ └── fig16_01.cpp ├── fig16_02-03 │ ├── fig16_03.cpp │ └── welcome.ixx ├── fig16_04-05 │ ├── deitel.math.ixx │ └── fig16_05.cpp ├── fig16_06-07 - Copy │ ├── fig16_07.cpp │ └── privatefragmentdemo.ixx ├── fig16_06-08 │ ├── deitel.math-impl.cpp │ ├── deitel.math.ixx │ └── fig16_08.cpp ├── fig16_09-11 │ ├── deitel.time-impl.cpp │ ├── deitel.time.ixx │ └── fig16_11.cpp ├── fig16_12-15 │ ├── deitel.math-powers.ixx │ ├── deitel.math-roots.ixx │ ├── deitel.math.ixx │ └── fig16_15.cpp ├── fig16_16-21 │ ├── deitel.math.ixx │ ├── deitel.math.powers.ixx │ ├── deitel.math.roots.ixx │ ├── fig16_17.cpp │ ├── fig16_19.cpp │ └── fig16_21.cpp ├── fig16_22 │ └── fig16_22.cpp ├── fig16_23-24 │ ├── moduleA.ixx │ └── moduleB.ixx ├── fig16_25-27 │ ├── fig16_27.cpp │ ├── moduleA.ixx │ └── moduleB.ixx └── fig16_28-29 │ ├── deitel.time-impl.cpp │ ├── deitel.time.ixx │ └── fig16_28.cpp ├── ch17 ├── fig17_01 │ └── fig17_01.cpp ├── fig17_02 │ └── fig17_02.cpp ├── fig17_03-04 │ ├── printtask.cpp │ └── printtask.h ├── fig17_05-06 │ ├── SharedBufferTest.cpp │ └── UnsynchronizedBuffer.h ├── fig17_07-08 │ ├── SharedBufferTest.cpp │ └── SynchronizedBuffer.h ├── fig17_09-10 │ ├── CircularBuffer.h │ └── SharedBufferTest.cpp ├── fig17_11 │ └── CooperativeCancelation.cpp ├── fig17_12 │ ├── async.cpp │ ├── async.o │ └── format.o ├── fig17_13 │ └── atomic.cpp ├── fig17_14 │ └── LatchDemo.cpp ├── fig17_15 │ └── BarrierDemo.cpp └── fig17_16 │ ├── SharedBufferTest.cpp │ └── SynchronizedBuffer.h ├── ch18 ├── fig18_01.cpp ├── fig18_02.cpp └── fig18_03.cpp ├── ch19 ├── fig19_01.cpp ├── fig19_02.cpp ├── fig19_03.cpp ├── fig19_04.cpp ├── fig19_05.cpp ├── fig19_06.cpp ├── fig19_07.cpp ├── fig19_08.cpp ├── fig19_09.cpp ├── fig19_10.cpp ├── fig19_11.cpp ├── fig19_12.cpp ├── fig19_13.cpp ├── fig19_14.cpp ├── fig19_15.cpp ├── fig19_16.cpp ├── fig19_17.cpp ├── fig19_18.cpp ├── fig19_19.cpp ├── fig19_20.cpp ├── fig19_21.cpp ├── fig19_22.cpp └── fig19_23.cpp ├── ch20 ├── fig20_01.cpp ├── fig20_02.cpp ├── fig20_03.cpp ├── fig20_04.cpp ├── fig20_05.cpp ├── fig20_06 │ ├── CommissionEmployee.cpp │ ├── CommissionEmployee.h │ ├── Employee.cpp │ ├── Employee.h │ ├── SalariedEmployee.cpp │ ├── SalariedEmployee.h │ └── fig20_06.cpp ├── fig20_07.cpp ├── fig20_08.cpp ├── fig20_09-13 │ ├── Author.cpp │ ├── Author.h │ ├── Book.cpp │ ├── Book.h │ └── fig20_13.cpp └── fig20_14.cpp └── libraries ├── BigNumber ├── CMakeLists.txt ├── LICENSE.md ├── README.md ├── bin │ └── BigNumber │ │ ├── include │ │ └── bignumber.h │ │ └── lib │ │ └── libBigNumber.a ├── main.cpp └── src │ ├── bignumber.cpp │ └── bignumber.h ├── GSL ├── .clang-format ├── .github │ └── workflows │ │ ├── android.yml │ │ └── ios.yml ├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── CMakeSettings.json ├── CONTRIBUTING.md ├── GSL.natvis ├── LICENSE ├── README.md ├── ThirdPartyNotices.txt ├── azure-pipelines.yml ├── cmake │ └── guidelineSupportLibrary.cmake ├── include │ ├── CMakeLists.txt │ └── gsl │ │ ├── algorithm │ │ ├── assert │ │ ├── byte │ │ ├── gsl │ │ ├── gsl_algorithm │ │ ├── gsl_assert │ │ ├── gsl_byte │ │ ├── gsl_narrow │ │ ├── gsl_util │ │ ├── narrow │ │ ├── pointers │ │ ├── span │ │ ├── span_ext │ │ ├── string_span │ │ └── util ├── pipelines │ ├── jobs.yml │ └── steps.yml └── tests │ ├── CMakeLists.txt │ ├── CMakeLists.txt.in │ ├── algorithm_tests.cpp │ ├── assertion_tests.cpp │ ├── at_tests.cpp │ ├── byte_tests.cpp │ ├── no_exception_ensure_tests.cpp │ ├── notnull_tests.cpp │ ├── owner_tests.cpp │ ├── span_compatibility_tests.cpp │ ├── span_ext_tests.cpp │ ├── span_tests.cpp │ ├── strict_notnull_tests.cpp │ ├── string_span_tests.cpp │ └── utils_tests.cpp ├── cereal-1.3.0 ├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── appveyor.yml ├── doc │ ├── CMakeLists.txt │ ├── DoxygenLayout.xml │ ├── doxygen.in │ ├── footer.html │ └── mainpage.dox ├── include │ └── cereal │ │ ├── access.hpp │ │ ├── archives │ │ ├── adapters.hpp │ │ ├── binary.hpp │ │ ├── json.hpp │ │ ├── portable_binary.hpp │ │ └── xml.hpp │ │ ├── cereal.hpp │ │ ├── details │ │ ├── helpers.hpp │ │ ├── polymorphic_impl.hpp │ │ ├── polymorphic_impl_fwd.hpp │ │ ├── static_object.hpp │ │ ├── traits.hpp │ │ └── util.hpp │ │ ├── external │ │ ├── base64.hpp │ │ ├── rapidjson │ │ │ ├── allocators.h │ │ │ ├── cursorstreamwrapper.h │ │ │ ├── document.h │ │ │ ├── encodedstream.h │ │ │ ├── encodings.h │ │ │ ├── error │ │ │ │ ├── en.h │ │ │ │ └── error.h │ │ │ ├── filereadstream.h │ │ │ ├── filewritestream.h │ │ │ ├── fwd.h │ │ │ ├── internal │ │ │ │ ├── biginteger.h │ │ │ │ ├── diyfp.h │ │ │ │ ├── dtoa.h │ │ │ │ ├── ieee754.h │ │ │ │ ├── itoa.h │ │ │ │ ├── meta.h │ │ │ │ ├── pow10.h │ │ │ │ ├── regex.h │ │ │ │ ├── stack.h │ │ │ │ ├── strfunc.h │ │ │ │ ├── strtod.h │ │ │ │ └── swap.h │ │ │ ├── istreamwrapper.h │ │ │ ├── memorybuffer.h │ │ │ ├── memorystream.h │ │ │ ├── msinttypes │ │ │ │ ├── inttypes.h │ │ │ │ └── stdint.h │ │ │ ├── ostreamwrapper.h │ │ │ ├── pointer.h │ │ │ ├── prettywriter.h │ │ │ ├── rapidjson.h │ │ │ ├── reader.h │ │ │ ├── schema.h │ │ │ ├── stream.h │ │ │ ├── stringbuffer.h │ │ │ └── writer.h │ │ └── rapidxml │ │ │ ├── license.txt │ │ │ ├── manual.html │ │ │ ├── rapidxml.hpp │ │ │ ├── rapidxml_iterators.hpp │ │ │ ├── rapidxml_print.hpp │ │ │ └── rapidxml_utils.hpp │ │ ├── macros.hpp │ │ ├── specialize.hpp │ │ ├── types │ │ ├── array.hpp │ │ ├── atomic.hpp │ │ ├── base_class.hpp │ │ ├── bitset.hpp │ │ ├── boost_variant.hpp │ │ ├── chrono.hpp │ │ ├── common.hpp │ │ ├── complex.hpp │ │ ├── concepts │ │ │ └── pair_associative_container.hpp │ │ ├── deque.hpp │ │ ├── forward_list.hpp │ │ ├── functional.hpp │ │ ├── list.hpp │ │ ├── map.hpp │ │ ├── memory.hpp │ │ ├── optional.hpp │ │ ├── polymorphic.hpp │ │ ├── queue.hpp │ │ ├── set.hpp │ │ ├── stack.hpp │ │ ├── string.hpp │ │ ├── tuple.hpp │ │ ├── unordered_map.hpp │ │ ├── unordered_set.hpp │ │ ├── utility.hpp │ │ ├── valarray.hpp │ │ ├── variant.hpp │ │ └── vector.hpp │ │ └── version.hpp ├── sandbox │ ├── CMakeLists.txt │ ├── performance.cpp │ ├── sandbox.cpp │ ├── sandbox_json.cpp │ ├── sandbox_rtti.cpp │ ├── sandbox_shared_lib │ │ ├── CMakeLists.txt │ │ ├── base.cpp │ │ ├── base.hpp │ │ ├── derived.cpp │ │ └── derived.hpp │ └── sandbox_vs.cpp ├── scripts │ ├── add_rapidjson_prefix.sh │ ├── appveyor.bat │ ├── renameincludes.sh │ ├── updatecoverage.sh │ └── updatedoc.in └── unittests │ ├── CMakeLists.txt │ ├── array.cpp │ ├── array.hpp │ ├── atomic.cpp │ ├── atomic.hpp │ ├── basic_string.cpp │ ├── basic_string.hpp │ ├── bitset.cpp │ ├── bitset.hpp │ ├── boost │ ├── CMakeLists.txt │ ├── boost_variant.cpp │ └── boost_variant.hpp │ ├── chrono.cpp │ ├── chrono.hpp │ ├── cmake-config-module.cmake │ ├── common.hpp │ ├── complex.cpp │ ├── complex.hpp │ ├── cpp17 │ ├── CMakeLists.txt │ ├── optional.cpp │ ├── optional.hpp │ ├── variant.cpp │ └── variant.hpp │ ├── defer.cpp │ ├── defer.hpp │ ├── deque.cpp │ ├── deque.hpp │ ├── doctest.h │ ├── forward_list.cpp │ ├── forward_list.hpp │ ├── list.cpp │ ├── list.hpp │ ├── load_construct.cpp │ ├── load_construct.hpp │ ├── map.cpp │ ├── map.hpp │ ├── memory.cpp │ ├── memory.hpp │ ├── memory_cycles.cpp │ ├── memory_cycles.hpp │ ├── multimap.cpp │ ├── multimap.hpp │ ├── multiset.cpp │ ├── multiset.hpp │ ├── pair.cpp │ ├── pair.hpp │ ├── pod.cpp │ ├── pod.hpp │ ├── polymorphic.cpp │ ├── polymorphic.hpp │ ├── portability_test.cpp │ ├── portable_binary_archive.cpp │ ├── portable_binary_archive.hpp │ ├── priority_queue.cpp │ ├── priority_queue.hpp │ ├── queue.cpp │ ├── queue.hpp │ ├── run_portability_test.cmake │ ├── run_valgrind.sh │ ├── set.cpp │ ├── set.hpp │ ├── stack.cpp │ ├── stack.hpp │ ├── structs.cpp │ ├── structs.hpp │ ├── structs_minimal.cpp │ ├── structs_minimal.hpp │ ├── structs_specialized.cpp │ ├── structs_specialized.hpp │ ├── tuple.cpp │ ├── tuple.hpp │ ├── unordered_loads.cpp │ ├── unordered_loads.hpp │ ├── unordered_map.cpp │ ├── unordered_map.hpp │ ├── unordered_multimap.cpp │ ├── unordered_multimap.hpp │ ├── unordered_multiset.cpp │ ├── unordered_multiset.hpp │ ├── unordered_set.cpp │ ├── unordered_set.hpp │ ├── user_data_adapters.cpp │ ├── user_data_adapters.hpp │ ├── valarray.cpp │ ├── valarray.hpp │ ├── vector.cpp │ ├── vector.hpp │ ├── versioning.cpp │ └── versioning.hpp ├── concurrencpp ├── .clang-format ├── .gitignore ├── CMakeLists.txt ├── LICENSE.txt ├── README.md ├── cmake │ ├── ciBuild.cmake │ ├── ciToolsUpdate.cmake │ ├── concurrencppConfig.cmake │ ├── concurrencppInjectTSAN.cmake │ ├── coroutineOptions.cmake │ ├── exec.cmake │ └── setCiVars.cmake ├── example │ ├── 10_regular_timer │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 11_oneshot_timer │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 12_delay_object │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 13_generator │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 1_hello_world │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 2_concurrent_even_number_counting │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 3_async_file_processing │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 4_async_file_processing_version_2 │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 5_prime_number_finder │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 6_manual_executor │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 7_when_all │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 8_when_any │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ ├── 9_result_promise │ │ ├── CMakeLists.txt │ │ └── source │ │ │ └── main.cpp │ └── CMakeLists.txt ├── include │ └── concurrencpp │ │ ├── concurrencpp.h │ │ ├── coroutines │ │ └── coroutine.h │ │ ├── errors.h │ │ ├── executors │ │ ├── constants.h │ │ ├── derivable_executor.h │ │ ├── executor.h │ │ ├── executor_all.h │ │ ├── inline_executor.h │ │ ├── manual_executor.h │ │ ├── thread_executor.h │ │ ├── thread_pool_executor.h │ │ └── worker_thread_executor.h │ │ ├── forward_declarations.h │ │ ├── platform_defs.h │ │ ├── results │ │ ├── constants.h │ │ ├── generator.h │ │ ├── impl │ │ │ ├── consumer_context.h │ │ │ ├── generator_state.h │ │ │ ├── lazy_result_state.h │ │ │ ├── producer_context.h │ │ │ ├── result_state.h │ │ │ ├── return_value_struct.h │ │ │ └── shared_result_state.h │ │ ├── lazy_result.h │ │ ├── lazy_result_awaitable.h │ │ ├── make_result.h │ │ ├── promises.h │ │ ├── result.h │ │ ├── result_awaitable.h │ │ ├── result_fwd_declarations.h │ │ ├── resume_on.h │ │ ├── shared_result.h │ │ ├── shared_result_awaitable.h │ │ └── when_result.h │ │ ├── runtime │ │ ├── constants.h │ │ └── runtime.h │ │ ├── task.h │ │ ├── threads │ │ ├── binary_semaphore.h │ │ ├── cache_line.h │ │ └── thread.h │ │ ├── timers │ │ ├── constants.h │ │ ├── timer.h │ │ └── timer_queue.h │ │ └── utils │ │ └── bind.h ├── sandbox │ ├── CMakeLists.txt │ └── main.cpp ├── source │ ├── executors │ │ ├── executor.cpp │ │ ├── manual_executor.cpp │ │ ├── thread_executor.cpp │ │ ├── thread_pool_executor.cpp │ │ └── worker_thread_executor.cpp │ ├── results │ │ ├── impl │ │ │ ├── consumer_context.cpp │ │ │ ├── result_state.cpp │ │ │ └── shared_result_state.cpp │ │ └── promises.cpp │ ├── runtime │ │ └── runtime.cpp │ ├── task.cpp │ ├── threads │ │ ├── binary_semaphore.cpp │ │ └── thread.cpp │ └── timers │ │ ├── timer.cpp │ │ └── timer_queue.cpp └── test │ ├── CMakeLists.txt │ ├── include │ ├── infra │ │ ├── assertions.h │ │ └── tester.h │ └── utils │ │ ├── custom_exception.h │ │ ├── executor_shutdowner.h │ │ ├── object_observer.h │ │ ├── random.h │ │ ├── test_generators.h │ │ ├── test_ready_lazy_result.h │ │ ├── test_ready_result.h │ │ └── throwing_executor.h │ └── source │ ├── infra │ ├── assertions.cpp │ └── tester.cpp │ ├── tests │ ├── coroutine_tests │ │ ├── coroutine_promise_tests.cpp │ │ └── coroutine_tests.cpp │ ├── executor_tests │ │ ├── inline_executor_tests.cpp │ │ ├── manual_executor_tests.cpp │ │ ├── thread_executor_tests.cpp │ │ ├── thread_pool_executor_tests.cpp │ │ └── worker_thread_executor_tests.cpp │ ├── result_tests │ │ ├── generator_tests.cpp │ │ ├── lazy_result_tests.cpp │ │ ├── make_result_tests.cpp │ │ ├── result_await_tests.cpp │ │ ├── result_promise_tests.cpp │ │ ├── result_resolve_tests.cpp │ │ ├── result_tests.cpp │ │ ├── resume_on_tests.cpp │ │ ├── shared_result_await_tests.cpp │ │ ├── shared_result_resolve_tests.cpp │ │ ├── shared_result_tests.cpp │ │ ├── when_all_tests.cpp │ │ └── when_any_tests.cpp │ ├── runtime_tests.cpp │ ├── task_tests.cpp │ └── timer_tests │ │ ├── timer_queue_tests.cpp │ │ └── timer_tests.cpp │ ├── thread_sanitizer │ ├── executors.cpp │ ├── fibonacci.cpp │ ├── lazy_fibonacci.cpp │ ├── matrix_multiplication.cpp │ ├── quick_sort.cpp │ ├── result.cpp │ ├── shared_result.cpp │ ├── when_all.cpp │ └── when_any.cpp │ └── utils │ └── object_observer.cpp ├── fmt ├── .clang-format ├── .github │ ├── pull_request_template.md │ └── workflows │ │ ├── doc.yml │ │ ├── linux.yml │ │ ├── macos.yml │ │ └── windows.yml ├── .gitignore ├── CMakeLists.txt ├── CONTRIBUTING.md ├── ChangeLog.rst ├── LICENSE.rst ├── README.rst ├── doc │ ├── CMakeLists.txt │ ├── _static │ │ ├── bootstrap.min.js │ │ ├── breathe.css │ │ └── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ └── glyphicons-halflings-regular.woff │ ├── _templates │ │ ├── layout.html │ │ └── search.html │ ├── api.rst │ ├── basic-bootstrap │ │ ├── README │ │ ├── layout.html │ │ └── theme.conf │ ├── bootstrap │ │ ├── alerts.less │ │ ├── badges.less │ │ ├── bootstrap.less │ │ ├── breadcrumbs.less │ │ ├── button-groups.less │ │ ├── buttons.less │ │ ├── carousel.less │ │ ├── close.less │ │ ├── code.less │ │ ├── component-animations.less │ │ ├── dropdowns.less │ │ ├── forms.less │ │ ├── glyphicons.less │ │ ├── grid.less │ │ ├── input-groups.less │ │ ├── jumbotron.less │ │ ├── labels.less │ │ ├── list-group.less │ │ ├── media.less │ │ ├── mixins.less │ │ ├── mixins │ │ │ ├── alerts.less │ │ │ ├── background-variant.less │ │ │ ├── border-radius.less │ │ │ ├── buttons.less │ │ │ ├── center-block.less │ │ │ ├── clearfix.less │ │ │ ├── forms.less │ │ │ ├── gradients.less │ │ │ ├── grid-framework.less │ │ │ ├── grid.less │ │ │ ├── hide-text.less │ │ │ ├── image.less │ │ │ ├── labels.less │ │ │ ├── list-group.less │ │ │ ├── nav-divider.less │ │ │ ├── nav-vertical-align.less │ │ │ ├── opacity.less │ │ │ ├── pagination.less │ │ │ ├── panels.less │ │ │ ├── progress-bar.less │ │ │ ├── reset-filter.less │ │ │ ├── resize.less │ │ │ ├── responsive-visibility.less │ │ │ ├── size.less │ │ │ ├── tab-focus.less │ │ │ ├── table-row.less │ │ │ ├── text-emphasis.less │ │ │ ├── text-overflow.less │ │ │ └── vendor-prefixes.less │ │ ├── modals.less │ │ ├── navbar.less │ │ ├── navs.less │ │ ├── normalize.less │ │ ├── pager.less │ │ ├── pagination.less │ │ ├── panels.less │ │ ├── popovers.less │ │ ├── print.less │ │ ├── progress-bars.less │ │ ├── responsive-embed.less │ │ ├── responsive-utilities.less │ │ ├── scaffolding.less │ │ ├── tables.less │ │ ├── theme.less │ │ ├── thumbnails.less │ │ ├── tooltip.less │ │ ├── type.less │ │ ├── utilities.less │ │ ├── variables.less │ │ └── wells.less │ ├── build.py │ ├── conf.py │ ├── contents.rst │ ├── fmt.less │ ├── index.rst │ ├── python-license.txt │ ├── syntax.rst │ └── usage.rst ├── include │ └── fmt │ │ ├── args.h │ │ ├── chrono.h │ │ ├── color.h │ │ ├── compile.h │ │ ├── core.h │ │ ├── format-inl.h │ │ ├── format.h │ │ ├── locale.h │ │ ├── os.h │ │ ├── ostream.h │ │ ├── printf.h │ │ ├── ranges.h │ │ └── xchar.h ├── src │ ├── fmt.cc │ ├── format.cc │ └── os.cc ├── support │ ├── Android.mk │ ├── AndroidManifest.xml │ ├── C++.sublime-syntax │ ├── README │ ├── Vagrantfile │ ├── appveyor-build.py │ ├── appveyor.yml │ ├── build-docs.py │ ├── build.gradle │ ├── cmake │ │ ├── FindSetEnv.cmake │ │ ├── JoinPaths.cmake │ │ ├── cxx14.cmake │ │ ├── fmt-config.cmake.in │ │ └── fmt.pc.in │ ├── compute-powers.py │ ├── docopt.py │ ├── manage.py │ ├── rst2md.py │ └── rtd │ │ ├── conf.py │ │ ├── index.rst │ │ └── theme │ │ ├── layout.html │ │ └── theme.conf └── test │ ├── CMakeLists.txt │ ├── add-subdirectory-test │ ├── CMakeLists.txt │ └── main.cc │ ├── args-test.cc │ ├── assert-test.cc │ ├── chrono-test.cc │ ├── color-test.cc │ ├── compile-error-test │ └── CMakeLists.txt │ ├── compile-test.cc │ ├── core-test.cc │ ├── cuda-test │ ├── CMakeLists.txt │ ├── cpp14.cc │ └── cuda-cpp14.cu │ ├── enforce-checks-test.cc │ ├── find-package-test │ ├── CMakeLists.txt │ └── main.cc │ ├── format │ ├── format-impl-test.cc │ ├── format-test.cc │ ├── fuzzing │ ├── .gitignore │ ├── CMakeLists.txt │ ├── README.md │ ├── build.sh │ ├── chrono-duration.cc │ ├── float.cc │ ├── fuzzer-common.h │ ├── main.cc │ ├── named-arg.cc │ ├── one-arg.cc │ └── two-args.cc │ ├── gtest-extra-test.cc │ ├── gtest-extra.cc │ ├── gtest-extra.h │ ├── gtest │ ├── .clang-format │ ├── CMakeLists.txt │ ├── gmock-gtest-all.cc │ ├── gmock │ │ └── gmock.h │ └── gtest │ │ ├── gtest-spi.h │ │ └── gtest.h │ ├── header-only-test.cc │ ├── mock-allocator.h │ ├── module-test.cc │ ├── os-test.cc │ ├── ostream-test.cc │ ├── posix-mock-test.cc │ ├── posix-mock.h │ ├── printf-test.cc │ ├── ranges-test.cc │ ├── scan-test.cc │ ├── scan.h │ ├── static-export-test │ ├── CMakeLists.txt │ ├── library.cc │ └── main.cc │ ├── std-format-test.cc │ ├── test-assert.h │ ├── test-main.cc │ ├── unicode-test.cc │ ├── util.cc │ ├── util.h │ └── xchar-test.cc ├── generator ├── .gitattributes ├── .github │ └── workflows │ │ └── cmake.yml ├── .gitignore ├── CMakeLists.txt ├── CMakeSettings.json ├── COPYING ├── README.md ├── cmake │ └── tl-generator-config.cmake.in ├── include │ └── tl │ │ └── generator.hpp ├── tests │ └── test.cpp └── vcpkg.json ├── miniz-cpp ├── .gitignore ├── CMakeLists.txt ├── LICENSE.md ├── README.md ├── examples │ ├── pipe.cpp │ ├── read.cpp │ └── write.cpp ├── tests │ └── test.cpp └── zip_file.hpp └── rapidcsv ├── .github └── workflows │ ├── linux.yml │ ├── macos.yml │ └── windows.yml ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── doc ├── README.md ├── rapidcsv_Converter.md ├── rapidcsv_ConverterParams.md ├── rapidcsv_Document.md ├── rapidcsv_LabelParams.md ├── rapidcsv_LineReaderParams.md ├── rapidcsv_SeparatorParams.md └── rapidcsv_no_converter.md ├── examples ├── cmake-add-subdirectory │ ├── CMakeLists.txt │ ├── README.md │ └── src │ │ └── exprog2.cpp ├── cmake-fetchcontent │ ├── CMakeLists.txt │ ├── README.md │ └── src │ │ └── exprog.cpp ├── colhdr.csv ├── colrowhdr.csv ├── ex001.cpp ├── ex002.cpp ├── ex003.cpp ├── ex004.cpp ├── ex005.cpp ├── ex006.cpp ├── ex007.cpp ├── ex008.cpp ├── ex009.cpp ├── nohdr.csv ├── rowhdr.csv └── semi.csv ├── make.sh ├── src └── rapidcsv.h ├── tests ├── chi-utf16.csv ├── msft.csv ├── perftest.h ├── ptest001.cpp ├── ptest002.cpp ├── test001.cpp ├── test002.cpp ├── test003.cpp ├── test004.cpp ├── test005.cpp ├── test006.cpp ├── test007.cpp ├── test008.cpp ├── test009.cpp ├── test010.cpp ├── test011.cpp ├── test012.cpp ├── test013.cpp ├── test014.cpp ├── test015.cpp ├── test016.cpp ├── test017.cpp ├── test018.cpp ├── test019.cpp ├── test020.cpp ├── test021.cpp ├── test022.cpp ├── test023.cpp ├── test024.cpp ├── test025.cpp ├── test026.cpp ├── test027.cpp ├── test028.cpp ├── test029.cpp ├── test030.cpp ├── test031.cpp ├── test032.cpp ├── test033.cpp ├── test034.cpp ├── test035.cpp ├── test036.cpp ├── test037.cpp ├── test038.cpp ├── test039.cpp ├── test040.cpp ├── test040b.cpp ├── test041.cpp ├── test042.cpp ├── test043.cpp ├── test044.cpp ├── test045.cpp ├── test046.cpp ├── test047.cpp ├── test048.cpp ├── test049.cpp ├── test050.cpp ├── test051.cpp ├── test052.cpp ├── test053.cpp ├── test054.cpp ├── test055.cpp ├── test056.cpp ├── test057.cpp ├── test058.cpp ├── test059.cpp ├── test060.cpp ├── test061.cpp ├── test062.cpp ├── test063.cpp ├── test064.cpp ├── test065.cpp ├── test066.cpp ├── test067.cpp ├── test068.cpp ├── test069.cpp ├── test070.cpp ├── test071.cpp ├── test072.cpp ├── test073.cpp ├── test074.cpp ├── test075.cpp ├── test076.cpp ├── test077.cpp ├── test078.cpp ├── test079.cpp ├── test080.cpp ├── test081.cpp ├── test082.cpp ├── test083.cpp ├── test084.cpp ├── test085.cpp ├── test086.cpp └── unittest.h ├── uncrustify.cfg └── winmake.bat /README.md: -------------------------------------------------------------------------------- 1 | # C++20 for Programmers 2 | This repository contains the source code and supporting files associated with our book **C++20 for Programmers**. https://deitel.com/c-plus-plus-20-for-programmers 3 | 4 | These files are Copyright 2022 by Deitel & Associates, Inc. and Pearson Education, Inc. All Rights Reserved. 5 | 6 | You may use these files for your personal purposes, but please do not repost them without our express written consent. 7 | 8 | If you have any questions, open an issue in the Issues tab or email us: deitel at deitel dot com. 9 | 10 | The authors and publisher of this book have used their best efforts in preparing this book. These efforts include the development, research, and testing of the theories and programs to determine their effectiveness. The authors and publisher make no warranty of any kind, expressed or implied, with regard to these programs or to the documentation contained in this book. The authors and publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these programs. 11 | -------------------------------------------------------------------------------- /examples/ch03/fig03_05/BigNumber/bin/BigNumber/lib/libBigNumber.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/ch03/fig03_05/BigNumber/bin/BigNumber/lib/libBigNumber.a -------------------------------------------------------------------------------- /examples/ch05/cipher.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/ch05/cipher.h -------------------------------------------------------------------------------- /examples/ch05/fig05_18.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/ch05/fig05_18.cpp -------------------------------------------------------------------------------- /examples/ch08/accounts.csv: -------------------------------------------------------------------------------- 1 | account,name,balance 2 | 100,Jones,24.98 3 | 200,Doe,345.67 4 | 300,White,0.0 5 | 400,Stone,-42.16 6 | 500,Rich,224.62 7 | -------------------------------------------------------------------------------- /examples/ch09/fig09_36/records.json: -------------------------------------------------------------------------------- 1 | { 2 | "records": [ 3 | { 4 | "account": 100, 5 | "first": "Brian", 6 | "last": "Blue", 7 | "balance": 123.45 8 | }, 9 | { 10 | "account": 200, 11 | "first": "Sue", 12 | "last": "Green", 13 | "balance": 987.65 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /examples/ch16/fig16_06-08/fig16_08.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/ch16/fig16_06-08/fig16_08.cpp -------------------------------------------------------------------------------- /examples/ch16/fig16_23-24/moduleA.ixx: -------------------------------------------------------------------------------- 1 | // Fig. 16.23: moduleA.ixx 2 | // Primary module interface unit that imports moduleB. 3 | export module moduleA; // declares the primary module interface unit 4 | 5 | export import moduleB; // import and re-export moduleB 6 | 7 | 8 | /************************************************************************* 9 | * (C) Copyright 1992-2021 by Deitel & Associates, Inc. and * 10 | * Pearson Education, Inc. All Rights Reserved. * 11 | * * 12 | * DISCLAIMER: The authors and publisher of this book have used their * 13 | * best efforts in preparing the book. These efforts include the * 14 | * development, research, and testing of the theories and programs * 15 | * to determine their effectiveness. The authors and publisher make * 16 | * no warranty of any kind, expressed or implied, with regard to these * 17 | * programs or to the documentation contained in these books. The authors * 18 | * and publisher shall not be liable in any event for incidental or * 19 | * consequential damages in connection with, or arising out of, the * 20 | * furnishing, performance, or use of these programs. * 21 | **************************************************************************/ 22 | -------------------------------------------------------------------------------- /examples/ch16/fig16_23-24/moduleB.ixx: -------------------------------------------------------------------------------- 1 | // Fig. 16.24: moduleB.ixx 2 | // Primary module interface unit that imports moduleA. 3 | export module moduleB; // declares the primary module interface unit 4 | 5 | export import moduleA; // import and re-export moduleA 6 | 7 | /************************************************************************* 8 | * (C) Copyright 1992-2021 by Deitel & Associates, Inc. and * 9 | * Pearson Education, Inc. All Rights Reserved. * 10 | * * 11 | * DISCLAIMER: The authors and publisher of this book have used their * 12 | * best efforts in preparing the book. These efforts include the * 13 | * development, research, and testing of the theories and programs * 14 | * to determine their effectiveness. The authors and publisher make * 15 | * no warranty of any kind, expressed or implied, with regard to these * 16 | * programs or to the documentation contained in these books. The authors * 17 | * and publisher shall not be liable in any event for incidental or * 18 | * consequential damages in connection with, or arising out of, the * 19 | * furnishing, performance, or use of these programs. * 20 | **************************************************************************/ 21 | -------------------------------------------------------------------------------- /examples/ch16/fig16_25-27/moduleA.ixx: -------------------------------------------------------------------------------- 1 | // Fig. 16.25: moduleA.ixx 2 | // Primary module interface unit that exports function cube. 3 | export module moduleA; // declares the primary module interface unit 4 | 5 | export int cube(int x) { return x * x * x; } 6 | 7 | 8 | 9 | /************************************************************************* 10 | * (C) Copyright 1992-2021 by Deitel & Associates, Inc. and * 11 | * Pearson Education, Inc. All Rights Reserved. * 12 | * * 13 | * DISCLAIMER: The authors and publisher of this book have used their * 14 | * best efforts in preparing the book. These efforts include the * 15 | * development, research, and testing of the theories and programs * 16 | * to determine their effectiveness. The authors and publisher make * 17 | * no warranty of any kind, expressed or implied, with regard to these * 18 | * programs or to the documentation contained in these books. The authors * 19 | * and publisher shall not be liable in any event for incidental or * 20 | * consequential damages in connection with, or arising out of, the * 21 | * furnishing, performance, or use of these programs. * 22 | **************************************************************************/ 23 | -------------------------------------------------------------------------------- /examples/ch17/fig17_12/async.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/ch17/fig17_12/async.o -------------------------------------------------------------------------------- /examples/ch17/fig17_12/format.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/ch17/fig17_12/format.o -------------------------------------------------------------------------------- /examples/ch20/fig20_06/fig20_06.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/ch20/fig20_06/fig20_06.cpp -------------------------------------------------------------------------------- /examples/ch20/fig20_07.cpp: -------------------------------------------------------------------------------- 1 | // fig20_07.cpp 2 | // [[nodiscard]] attribute. 3 | 4 | [[nodiscard("Do not ignore! Otherwise, you won't know the cube of x.")]] 5 | int cube(int x) { 6 | return x * x * x; 7 | } 8 | 9 | int main() { 10 | cube(10); // generates a compiler warning 11 | } 12 | 13 | /************************************************************************** 14 | * (C) Copyright 1992-2022 by Deitel & Associates, Inc. and * 15 | * Pearson Education, Inc. All Rights Reserved. * 16 | * * 17 | * DISCLAIMER: The authors and publisher of this book have used their * 18 | * best efforts in preparing the book. These efforts include the * 19 | * development, research, and testing of the theories and programs * 20 | * to determine their effectiveness. The authors and publisher make * 21 | * no warranty of any kind, expressed or implied, with regard to these * 22 | * programs or to the documentation contained in these books. The authors * 23 | * and publisher shall not be liable in any event for incidental or * 24 | * consequential damages in connection with, or arising out of, the * 25 | * furnishing, performance, or use of these programs. * 26 | **************************************************************************/ 27 | -------------------------------------------------------------------------------- /examples/ch20/fig20_08.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/ch20/fig20_08.cpp -------------------------------------------------------------------------------- /examples/libraries/BigNumber/bin/BigNumber/lib/libBigNumber.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/libraries/BigNumber/bin/BigNumber/lib/libBigNumber.a -------------------------------------------------------------------------------- /examples/libraries/GSL/.clang-format: -------------------------------------------------------------------------------- 1 | ColumnLimit: 100 2 | 3 | UseTab: Never 4 | IndentWidth: 4 5 | AccessModifierOffset: -4 6 | NamespaceIndentation: Inner 7 | 8 | BreakBeforeBraces: Custom 9 | BraceWrapping: 10 | AfterNamespace: true 11 | AfterEnum: true 12 | AfterStruct: true 13 | AfterClass: true 14 | SplitEmptyFunction: false 15 | AfterControlStatement: true 16 | AfterFunction: true 17 | AfterUnion: true 18 | BeforeElse: true 19 | 20 | 21 | AlwaysBreakTemplateDeclarations: true 22 | BreakConstructorInitializersBeforeComma: true 23 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 24 | AllowShortBlocksOnASingleLine: true 25 | AllowShortFunctionsOnASingleLine: All 26 | AllowShortIfStatementsOnASingleLine: true 27 | AllowShortLoopsOnASingleLine: true 28 | 29 | PointerAlignment: Left 30 | AlignConsecutiveAssignments: false 31 | AlignTrailingComments: true 32 | 33 | SpaceAfterCStyleCast: true 34 | CommentPragmas: '^ NO-FORMAT:' 35 | -------------------------------------------------------------------------------- /examples/libraries/GSL/.gitignore: -------------------------------------------------------------------------------- 1 | CMakeFiles 2 | build 3 | tests/CMakeFiles 4 | tests/Debug 5 | *.opensdf 6 | *.sdf 7 | tests/*tests.dir 8 | *.vcxproj 9 | *.vcxproj.filters 10 | *.sln 11 | *.tlog 12 | Testing/Temporary/*.* 13 | CMakeCache.txt 14 | *.suo 15 | .vs/ 16 | .vscode/ 17 | -------------------------------------------------------------------------------- /examples/libraries/GSL/CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x64-Debug", 5 | "generator": "Ninja", 6 | "configurationType": "Debug", 7 | "inheritEnvironments": [ 8 | "msvc_x64_x64" 9 | ], 10 | "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", 11 | "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}", 12 | "cmakeCommandArgs": "-DGSL_CXX_STANDARD=17", 13 | "buildCommandArgs": "-v", 14 | "ctestCommandArgs": "", 15 | "codeAnalysisRuleset": "CppCoreCheckRules.ruleset" 16 | } 17 | ] 18 | } -------------------------------------------------------------------------------- /examples/libraries/GSL/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Microsoft Corporation. All rights reserved. 2 | 3 | This code is licensed under the MIT License (MIT). 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 copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/libraries/GSL/include/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Add include folders to the library and targets that consume it 3 | # the SYSTEM keyword suppresses warnings for users of the library 4 | # 5 | # By adding this directory as an include directory the user gets a 6 | # namespace effect. 7 | # 8 | # IE: 9 | # #include 10 | if(GSL_STANDALONE_PROJECT) 11 | target_include_directories(GSL INTERFACE 12 | $ 13 | $ 14 | ) 15 | else() 16 | target_include_directories(GSL SYSTEM INTERFACE 17 | $ 18 | $ 19 | ) 20 | endif() 21 | -------------------------------------------------------------------------------- /examples/libraries/GSL/include/gsl/gsl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2015 Microsoft Corporation. All rights reserved. 4 | // 5 | // This code is licensed under the MIT License (MIT). 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13 | // THE SOFTWARE. 14 | // 15 | /////////////////////////////////////////////////////////////////////////////// 16 | 17 | #ifndef GSL_GSL_H 18 | #define GSL_GSL_H 19 | 20 | #include // copy 21 | #include // Ensures/Expects 22 | #include // byte 23 | #include // owner, not_null 24 | #include // span 25 | #include // zstring, string_span, zstring_builder... 26 | #include // finally()/narrow_cast()... 27 | 28 | #ifdef __cpp_exceptions 29 | #include // narrow() 30 | #endif 31 | 32 | #endif // GSL_GSL_H 33 | -------------------------------------------------------------------------------- /examples/libraries/GSL/include/gsl/gsl_algorithm: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma message("This header will soon be removed. Use instead of ") 3 | #include 4 | -------------------------------------------------------------------------------- /examples/libraries/GSL/include/gsl/gsl_assert: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma message("This header will soon be removed. Use instead of ") 3 | #include 4 | -------------------------------------------------------------------------------- /examples/libraries/GSL/include/gsl/gsl_byte: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma message("This header will soon be removed. Use instead of ") 3 | #include 4 | -------------------------------------------------------------------------------- /examples/libraries/GSL/include/gsl/gsl_narrow: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma message("This header will soon be removed. Use instead of ") 3 | #include 4 | -------------------------------------------------------------------------------- /examples/libraries/GSL/include/gsl/gsl_util: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #pragma message("This header will soon be removed. Use instead of ") 3 | #include 4 | -------------------------------------------------------------------------------- /examples/libraries/GSL/pipelines/jobs.yml: -------------------------------------------------------------------------------- 1 | parameters: 2 | jobName: '' 3 | imageName: '' 4 | 5 | jobs: 6 | - job: 7 | displayName: ${{ parameters.imageName }} 8 | pool: 9 | vmImage: ${{ parameters.imageName }} 10 | strategy: 11 | matrix: 12 | 14_debug: 13 | GSL_CXX_STANDARD: '14' 14 | BUILD_TYPE: 'Debug' 15 | 14_release: 16 | GSL_CXX_STANDARD: '14' 17 | BUILD_TYPE: 'Release' 18 | 17_debug: 19 | GSL_CXX_STANDARD: '17' 20 | BUILD_TYPE: 'Debug' 21 | 17_release: 22 | GSL_CXX_STANDARD: '17' 23 | BUILD_TYPE: 'Release' 24 | continueOnError: false 25 | steps: 26 | - template: ./steps.yml 27 | -------------------------------------------------------------------------------- /examples/libraries/GSL/pipelines/steps.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - task: CMake@1 3 | name: Configure 4 | inputs: 5 | workingDirectory: build 6 | cmakeArgs: '-DCMAKE_CXX_STANDARD=$(GSL_CXX_STANDARD) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -Werror=dev .. ' 7 | 8 | - task: CMake@1 9 | name: Build 10 | inputs: 11 | workingDirectory: build 12 | cmakeArgs: '--build . ' 13 | 14 | - script: ctest . --output-on-failure --no-compress-output 15 | name: CTest 16 | workingDirectory: build 17 | failOnStderr: true 18 | -------------------------------------------------------------------------------- /examples/libraries/GSL/tests/CMakeLists.txt.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0.2) 2 | project(googletest-download NONE) 3 | 4 | include(ExternalProject) 5 | ExternalProject_Add(googletest 6 | GIT_REPOSITORY https://github.com/google/googletest.git 7 | GIT_TAG 389cb68b87193358358ae87cc56d257fd0d80189 8 | SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src" 9 | BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build" 10 | CONFIGURE_COMMAND "" 11 | BUILD_COMMAND "" 12 | INSTALL_COMMAND "" 13 | TEST_COMMAND "" 14 | ) 15 | -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | 15 | # Visual studio cruft 16 | *.opensdf 17 | *.sdf 18 | *.suo 19 | *.user 20 | */x64 21 | *\Debug* 22 | *\Release* 23 | *.log 24 | *.tlog* 25 | *.obj 26 | *.VC.db 27 | *.VC.VC.opendb 28 | *.pdb 29 | *.idb 30 | *\build_* 31 | 32 | # misc files mostly used for testing 33 | out.txt 34 | ptr.txt 35 | test.txt 36 | boost_serialize 37 | arr.txt 38 | performance 39 | include_renamed 40 | .ycm_extra_conf.py* 41 | doc/html 42 | rtti.txt 43 | doc/latex 44 | portability64 45 | portability32 46 | file.json 47 | out.xml 48 | cereal_version.out 49 | xml_ordering.out 50 | build 51 | /out/ -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/appveyor.yml: -------------------------------------------------------------------------------- 1 | # can use variables like {build} and {branch} 2 | version: 1.2.{build} 3 | pull_requests: 4 | do_not_increment_build_number: true 5 | 6 | branches: 7 | only: 8 | - master 9 | 10 | configuration: 11 | - Debug 12 | - Release 13 | 14 | environment: 15 | matrix: 16 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 17 | VS_VERSION_MAJOR: 12 18 | BOOST_ROOT: C:\Libraries\boost_1_58_0 19 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 20 | VS_VERSION_MAJOR: 14 21 | BOOST_ROOT: C:\Libraries\boost_1_60_0 22 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 23 | VS_VERSION_MAJOR: 15 24 | BOOST_ROOT: C:\Libraries\boost_1_66_0 25 | # - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 Preview 26 | # VS_VERSION_MAJOR: 16 27 | # BOOST_ROOT: C:\Libraries\boost_1_66_0 28 | 29 | platform: 30 | - Win32 31 | - x64 32 | 33 | before_build: "scripts\\appveyor.bat" 34 | 35 | build: 36 | parallel: true 37 | project: build/cereal.sln 38 | verbosity: minimal 39 | 40 | test_script: "scripts\\appveyor.bat test" 41 | 42 | artifacts: 43 | - path: build\Testing 44 | - path: out 45 | -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Doxygen) 2 | if(DOXYGEN_FOUND) 3 | 4 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doxygen.in" "${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg" @ONLY) 5 | add_custom_target(doc 6 | COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg" 7 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.." 8 | COMMENT "Generating API documentation with Doxygen" VERBATIM 9 | ) 10 | 11 | configure_file("${CMAKE_CURRENT_SOURCE_DIR}/../scripts/updatedoc.in" "${CMAKE_CURRENT_BINARY_DIR}/updatedoc.sh" @ONLY) 12 | add_custom_target(update-doc 13 | COMMAND "${CMAKE_CURRENT_BINARY_DIR}/updatedoc.sh" 14 | DEPENDS doc 15 | COMMENT "Copying documentation to gh-pages branch" VERBATIM 16 | ) 17 | 18 | endif(DOXYGEN_FOUND) -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/doc/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 19 | 20 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/sandbox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(sandbox_shared_lib) 2 | 3 | add_executable(sandbox sandbox.cpp) 4 | add_executable(sandbox_json sandbox_json.cpp) 5 | add_executable(sandbox_rtti sandbox_rtti.cpp) 6 | 7 | add_executable(sandbox_vs sandbox_vs.cpp) 8 | target_link_libraries(sandbox_vs sandbox_vs_dll) 9 | include_directories(sandbox_shared_lib) 10 | 11 | if((Boost_FOUND) AND NOT SKIP_PERFORMANCE_COMPARISON) 12 | add_executable(performance performance.cpp) 13 | if(MSVC) 14 | set_target_properties(performance PROPERTIES COMPILE_DEFINITIONS "BOOST_SERIALIZATION_DYN_LINK") 15 | endif() 16 | target_link_libraries(performance ${Boost_LIBRARIES}) 17 | endif() 18 | -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/sandbox/sandbox_shared_lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_library(sandbox_vs_dll SHARED base.cpp derived.cpp) 2 | -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/sandbox/sandbox_shared_lib/base.cpp: -------------------------------------------------------------------------------- 1 | #ifndef CEREAL_DLL_USE 2 | #define CEREAL_DLL_MAKE 3 | #endif 4 | #include "base.hpp" 5 | 6 | template void Base::serialize 7 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 8 | template void Base::serialize 9 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 10 | -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/sandbox/sandbox_shared_lib/base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #if defined (_WINDLL) 9 | #define DECLSPECIFIER __declspec(dllexport) 10 | #elif defined(MSC_VER) 11 | #define DECLSPECIFIER __declspec(dllimport) 12 | #else 13 | #define DECLSPECIFIER 14 | #endif 15 | 16 | int doit(); 17 | 18 | class VersionTest 19 | { 20 | public: 21 | int x; 22 | template 23 | void serialize( Archive & ar, const std::uint32_t /* version */ ) 24 | { ar( x ); } 25 | }; 26 | 27 | class Base 28 | { 29 | public: 30 | friend class cereal::access; 31 | 32 | template < class Archive > 33 | void serialize(Archive &, std::uint32_t const) {} 34 | virtual ~Base() {} 35 | }; 36 | 37 | extern template DECLSPECIFIER void Base::serialize 38 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 39 | 40 | extern template DECLSPECIFIER void Base::serialize 41 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 42 | 43 | CEREAL_CLASS_VERSION(VersionTest, 1) 44 | -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/sandbox/sandbox_shared_lib/derived.cpp: -------------------------------------------------------------------------------- 1 | #ifndef CEREAL_DLL_USE 2 | #define CEREAL_DLL_MAKE 3 | #endif 4 | #include "derived.hpp" 5 | 6 | template void Derived::serialize 7 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 8 | 9 | template void Derived::serialize 10 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 11 | -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/sandbox/sandbox_shared_lib/derived.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "base.hpp" 3 | class Derived : public Base 4 | { 5 | public: 6 | virtual ~Derived() {} 7 | 8 | private: 9 | friend class cereal::access; 10 | template 11 | void serialize(Archive & ar, std::uint32_t const) 12 | { 13 | ar(cereal::base_class(this)); 14 | } 15 | }; 16 | 17 | extern template DECLSPECIFIER void Derived::serialize 18 | ( cereal::XMLOutputArchive & ar, std::uint32_t const version ); 19 | extern template DECLSPECIFIER void Derived::serialize 20 | ( cereal::XMLInputArchive & ar, std::uint32_t const version ); 21 | 22 | CEREAL_REGISTER_TYPE(Derived) 23 | -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/scripts/add_rapidjson_prefix.sh: -------------------------------------------------------------------------------- 1 | # Applies renaming within all of the rapidjson source files to add a cereal prefix 2 | find ./../include/cereal/external/rapidjson/ -type f -name \*.h -exec sed -i "s/RAPIDJSON_/CEREAL_RAPIDJSON_/g" {} \; 3 | echo "Remember to backport any cereal specific changes not in this version of RapidJSON!" 4 | echo "See https://github.com/USCiLab/cereal/commits/develop/include/cereal/external/rapidjson" 5 | -------------------------------------------------------------------------------- /examples/libraries/cereal-1.3.0/scripts/renameincludes.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | destdir="include_renamed" 4 | 5 | echo -n "New prefix: " 6 | read newprefix 7 | 8 | cp -r include ${destdir} 9 | 10 | newprefix=$(echo ${newprefix} | sed -e 's/\//\\\//') 11 | 12 | find ${destdir} -name '*.hpp' -exec sed -i "s/#include 4 | 5 | using namespace std::chrono_literals; 6 | 7 | int main() { 8 | concurrencpp::runtime runtime; 9 | std::atomic_size_t counter = 1; 10 | concurrencpp::timer timer = runtime.timer_queue()->make_timer(1500ms, 2000ms, runtime.thread_pool_executor(), [&] { 11 | const auto c = counter.fetch_add(1); 12 | std::cout << "timer was invoked for the " << c << "th time" << std::endl; 13 | }); 14 | 15 | std::cout << "timer due time (ms): " << timer.get_due_time().count() << std::endl; 16 | std::cout << "timer frequency (ms): " << timer.get_frequency().count() << std::endl; 17 | std::cout << "timer-associated executor : " << timer.get_executor()->name << std::endl; 18 | 19 | std::this_thread::sleep_for(20s); 20 | 21 | std::cout << "main thread cancelling timer" << std::endl; 22 | timer.cancel(); 23 | 24 | std::this_thread::sleep_for(10s); 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/11_oneshot_timer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(11_oneshot_time LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(11_oneshot_time source/main.cpp) 12 | 13 | target_compile_features(11_oneshot_time PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(11_oneshot_time PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(11_oneshot_time) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/11_oneshot_timer/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include "concurrencpp/concurrencpp.h" 2 | 3 | #include 4 | 5 | using namespace std::chrono_literals; 6 | 7 | int main() { 8 | concurrencpp::runtime runtime; 9 | concurrencpp::timer timer = runtime.timer_queue()->make_one_shot_timer(3s, runtime.thread_executor(), [] { 10 | std::cout << "hello and goodbye" << std::endl; 11 | }); 12 | 13 | std::cout << "timer due time (ms): " << timer.get_due_time().count() << std::endl; 14 | std::cout << "timer frequency (ms): " << timer.get_frequency().count() << std::endl; 15 | std::cout << "timer-associated executor : " << timer.get_executor()->name << std::endl; 16 | 17 | std::this_thread::sleep_for(4s); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/12_delay_object/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(12_delay_object LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(12_delay_object source/main.cpp) 12 | 13 | target_compile_features(12_delay_object PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(12_delay_object PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(12_delay_object) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/12_delay_object/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "concurrencpp/concurrencpp.h" 4 | 5 | using namespace std::chrono_literals; 6 | 7 | concurrencpp::null_result delayed_task(std::shared_ptr tq, 8 | std::shared_ptr ex) { 9 | size_t counter = 1; 10 | 11 | while (true) { 12 | std::cout << "task was invoked " << counter << " times." << std::endl; 13 | counter++; 14 | 15 | co_await tq->make_delay_object(1500ms, ex); 16 | } 17 | } 18 | 19 | int main() { 20 | concurrencpp::runtime runtime; 21 | delayed_task(runtime.timer_queue(), runtime.thread_pool_executor()); 22 | 23 | std::this_thread::sleep_for(10s); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/13_generator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(13_generator LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(13_generator source/main.cpp) 12 | 13 | target_compile_features(13_generator PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(13_generator PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(13_generator) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/1_hello_world/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(1_hello_world LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(1_hello_world source/main.cpp) 12 | 13 | target_compile_features(1_hello_world PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(1_hello_world PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(1_hello_world) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/1_hello_world/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include "concurrencpp/concurrencpp.h" 2 | #include 3 | 4 | int main() { 5 | concurrencpp::runtime runtime; 6 | auto result = runtime.thread_executor()->submit([] { 7 | std::cout << "hello world" << std::endl; 8 | }); 9 | 10 | result.get(); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/2_concurrent_even_number_counting/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(2_concurrent_even_number_counting LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(2_concurrent_even_number_counting source/main.cpp) 12 | 13 | target_compile_features(2_concurrent_even_number_counting PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(2_concurrent_even_number_counting PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(2_concurrent_even_number_counting) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/3_async_file_processing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(3_async_file_processing LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(3_async_file_processing source/main.cpp) 12 | 13 | target_compile_features(3_async_file_processing PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(3_async_file_processing PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(3_async_file_processing) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/4_async_file_processing_version_2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(4_async_file_processing_version_2 LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(4_async_file_processing_version_2 source/main.cpp) 12 | 13 | target_compile_features(4_async_file_processing_version_2 PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(4_async_file_processing_version_2 PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(4_async_file_processing_version_2) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/5_prime_number_finder/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(5_prime_number_finder LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(5_prime_number_finder source/main.cpp) 12 | 13 | target_compile_features(5_prime_number_finder PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(5_prime_number_finder PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(5_prime_number_finder) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/6_manual_executor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(6_manual_executor LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(6_manual_executor source/main.cpp) 12 | 13 | target_compile_features(6_manual_executor PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(6_manual_executor PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(6_manual_executor) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/7_when_all/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(7_when_all LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(7_when_all source/main.cpp) 12 | 13 | target_compile_features(7_when_all PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(7_when_all PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(7_when_all) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/8_when_any/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(8_when_any LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(8_when_any source/main.cpp) 12 | 13 | target_compile_features(8_when_any PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(8_when_any PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(8_when_any) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/9_result_promise/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(9_result_promise LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(9_result_promise source/main.cpp) 12 | 13 | target_compile_features(9_result_promise PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(9_result_promise PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(9_result_promise) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/9_result_promise/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include "concurrencpp/concurrencpp.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | int main() { 9 | concurrencpp::result_promise promise; 10 | auto result = promise.get_result(); 11 | 12 | std::thread my_3_party_executor([promise = std::move(promise)]() mutable { 13 | std::this_thread::sleep_for(std::chrono::seconds(1)); // imitate real work 14 | 15 | // imitate a random failure 16 | std::srand(static_cast(::time(nullptr))); 17 | if (std::rand() % 100 < 90) { 18 | promise.set_result("hello world"); 19 | } else { 20 | promise.set_exception(std::make_exception_ptr(std::runtime_error("failure"))); 21 | } 22 | }); 23 | 24 | try { 25 | auto asynchronous_string = result.get(); 26 | std::cout << "result promise returned string: " << asynchronous_string << std::endl; 27 | 28 | } catch (const std::exception& e) { 29 | std::cerr << "An exception was thrown while executing asynchronous function: " << e.what() << std::endl; 30 | } 31 | 32 | my_3_party_executor.join(); 33 | } -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(concurrencppExamples LANGUAGES CXX) 4 | 5 | foreach(example IN ITEMS 6 | 1_hello_world 7 | 2_concurrent_even_number_counting 8 | 3_async_file_processing 9 | 4_async_file_processing_version_2 10 | 5_prime_number_finder 11 | 6_manual_executor 12 | 7_when_all 13 | 8_when_any 14 | 9_result_promise 15 | 10_regular_timer 16 | 11_oneshot_timer 17 | 12_delay_object 18 | 13_generator 19 | ) 20 | add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/${example}" 21 | "${CMAKE_CURRENT_BINARY_DIR}/${example}") 22 | endforeach() 23 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/concurrencpp.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_H 2 | #define CONCURRENCPP_H 3 | 4 | #include "concurrencpp/forward_declarations.h" 5 | #include "concurrencpp/platform_defs.h" 6 | 7 | #include "concurrencpp/timers/timer.h" 8 | #include "concurrencpp/timers/timer_queue.h" 9 | #include "concurrencpp/runtime/runtime.h" 10 | #include "concurrencpp/results/result.h" 11 | #include "concurrencpp/results/lazy_result.h" 12 | #include "concurrencpp/results/make_result.h" 13 | #include "concurrencpp/results/when_result.h" 14 | #include "concurrencpp/results/shared_result.h" 15 | #include "concurrencpp/results/shared_result_awaitable.h" 16 | #include "concurrencpp/results/promises.h" 17 | #include "concurrencpp/results/resume_on.h" 18 | #include "concurrencpp/results/generator.h" 19 | #include "concurrencpp/executors/executor_all.h" 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/coroutines/coroutine.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_COROUTINE_H 2 | #define CONCURRENCPP_COROUTINE_H 3 | 4 | #include "../platform_defs.h" 5 | 6 | #ifdef CRCPP_MSVC_COMPILER 7 | 8 | # include 9 | 10 | namespace concurrencpp::details { 11 | template 12 | using coroutine_handle = std::coroutine_handle; 13 | using suspend_never = std::suspend_never; 14 | using suspend_always = std::suspend_always; 15 | } // namespace concurrencpp::details 16 | 17 | #elif defined(CRCPP_CLANG_COMPILER) 18 | 19 | # include 20 | 21 | namespace concurrencpp::details { 22 | template 23 | using coroutine_handle = std::experimental::coroutine_handle; 24 | using suspend_never = std::experimental::suspend_never; 25 | using suspend_always = std::experimental::suspend_always; 26 | } // namespace concurrencpp::details 27 | 28 | #endif 29 | 30 | #endif -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/errors.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_ERRORS_H 2 | #define CONCURRENCPP_ERRORS_H 3 | 4 | #include 5 | 6 | namespace concurrencpp::errors { 7 | struct empty_object : public std::runtime_error { 8 | using runtime_error::runtime_error; 9 | }; 10 | 11 | struct empty_result : public empty_object { 12 | using empty_object::empty_object; 13 | }; 14 | 15 | struct empty_result_promise : public empty_object { 16 | using empty_object::empty_object; 17 | }; 18 | 19 | struct empty_awaitable : public empty_object { 20 | using empty_object::empty_object; 21 | }; 22 | 23 | struct empty_timer : public empty_object { 24 | using empty_object::empty_object; 25 | }; 26 | 27 | struct empty_generator : public empty_object { 28 | using empty_object::empty_object; 29 | }; 30 | 31 | struct broken_task : public std::runtime_error { 32 | using runtime_error::runtime_error; 33 | }; 34 | 35 | struct result_already_retrieved : public std::runtime_error { 36 | using runtime_error::runtime_error; 37 | }; 38 | 39 | struct runtime_shutdown : public std::runtime_error { 40 | using runtime_error::runtime_error; 41 | }; 42 | } // namespace concurrencpp::errors 43 | 44 | #endif // ERRORS_H 45 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/executors/constants.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_EXECUTORS_CONSTS_H 2 | #define CONCURRENCPP_EXECUTORS_CONSTS_H 3 | 4 | #include 5 | 6 | namespace concurrencpp::details::consts { 7 | inline const char* k_inline_executor_name = "concurrencpp::inline_executor"; 8 | constexpr int k_inline_executor_max_concurrency_level = 0; 9 | 10 | inline const char* k_thread_executor_name = "concurrencpp::thread_executor"; 11 | constexpr int k_thread_executor_max_concurrency_level = std::numeric_limits::max(); 12 | 13 | inline const char* k_thread_pool_executor_name = "concurrencpp::thread_pool_executor"; 14 | inline const char* k_background_executor_name = "concurrencpp::background_executor"; 15 | 16 | constexpr int k_worker_thread_max_concurrency_level = 1; 17 | inline const char* k_worker_thread_executor_name = "concurrencpp::worker_thread_executor"; 18 | 19 | inline const char* k_manual_executor_name = "concurrencpp::manual_executor"; 20 | constexpr int k_manual_executor_max_concurrency_level = std::numeric_limits::max(); 21 | 22 | inline const char* k_executor_shutdown_err_msg = " - shutdown has been called on this executor."; 23 | } // namespace concurrencpp::details::consts 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/executors/executor_all.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_EXECUTORS_ALL_H 2 | #define CONCURRENCPP_EXECUTORS_ALL_H 3 | 4 | #include "concurrencpp/executors/derivable_executor.h" 5 | #include "concurrencpp/executors/inline_executor.h" 6 | #include "concurrencpp/executors/thread_pool_executor.h" 7 | #include "concurrencpp/executors/thread_executor.h" 8 | #include "concurrencpp/executors/worker_thread_executor.h" 9 | #include "concurrencpp/executors/manual_executor.h" 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/forward_declarations.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_FORWARD_DECLARATIONS_H 2 | #define CONCURRENCPP_FORWARD_DECLARATIONS_H 3 | 4 | namespace concurrencpp { 5 | struct null_result; 6 | 7 | template 8 | class result; 9 | 10 | template 11 | class lazy_result; 12 | 13 | template 14 | class shared_result; 15 | 16 | template 17 | class result_promise; 18 | 19 | class runtime; 20 | 21 | class timer_queue; 22 | class timer; 23 | 24 | class executor; 25 | class inline_executor; 26 | class thread_pool_executor; 27 | class thread_executor; 28 | class worker_thread_executor; 29 | class manual_executor; 30 | 31 | template 32 | class generator; 33 | } // namespace concurrencpp 34 | 35 | #endif // FORWARD_DECLARATIONS_H 36 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/platform_defs.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_PLATFORM_DEFS_H 2 | #define CONCURRENCPP_PLATFORM_DEFS_H 3 | 4 | #if defined(_WIN32) 5 | # define CRCPP_WIN_OS 6 | #elif defined(unix) || defined(__unix__) || defined(__unix) 7 | # define CRCPP_UNIX_OS 8 | #elif defined(__APPLE__) || defined(__MACH__) 9 | # define CRCPP_MAC_OS 10 | #elif defined(__FreeBSD__) 11 | # define CRCPP_FREE_BSD_OS 12 | #elif defined(__ANDROID__) 13 | # define CRCPP_ANDROID_OS 14 | #endif 15 | 16 | #if defined(__clang__) 17 | # define CRCPP_CLANG_COMPILER 18 | #elif defined(__GNUC__) || defined(__GNUG__) 19 | # define CRCPP_GCC_COMPILER 20 | #elif defined(_MSC_VER) 21 | # define CRCPP_MSVC_COMPILER 22 | #endif 23 | 24 | #if !defined(NDEBUG) || defined(_DEBUG) 25 | # define CRCPP_DEBUG_MODE 26 | #endif 27 | 28 | #include 29 | 30 | #if defined(_LIBCPP_VERSION) 31 | # define CRCPP_LIBCPP_LIB 32 | #endif 33 | 34 | #endif // PLATFORM_DEFS_H 35 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/results/impl/return_value_struct.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_RETURN_VALUE_STRUCT_H 2 | #define CONCURRENCPP_RETURN_VALUE_STRUCT_H 3 | 4 | #include 5 | 6 | namespace concurrencpp::details { 7 | template 8 | struct return_value_struct { 9 | template 10 | void return_value(return_type&& value) { 11 | auto self = static_cast(this); 12 | self->set_result(std::forward(value)); 13 | } 14 | }; 15 | 16 | template 17 | struct return_value_struct { 18 | void return_void() noexcept { 19 | auto self = static_cast(this); 20 | self->set_result(); 21 | } 22 | }; 23 | } // namespace concurrencpp::details 24 | 25 | #endif -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/runtime/constants.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_CONSTANTS_H 2 | #define CONCURRENCPP_CONSTANTS_H 3 | 4 | #include 5 | 6 | namespace concurrencpp::details::consts { 7 | constexpr static size_t k_cpu_threadpool_worker_count_factor = 1; 8 | constexpr static size_t k_background_threadpool_worker_count_factor = 4; 9 | constexpr static size_t k_max_threadpool_worker_waiting_time_sec = 2 * 60; 10 | constexpr static size_t k_default_number_of_cores = 8; 11 | constexpr static size_t k_max_timer_queue_worker_waiting_time_sec = 2 * 60; 12 | 13 | constexpr static unsigned int k_concurrencpp_version_major = 0; 14 | constexpr static unsigned int k_concurrencpp_version_minor = 1; 15 | constexpr static unsigned int k_concurrencpp_version_revision = 4; 16 | } // namespace concurrencpp::details::consts 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/threads/cache_line.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_CACHE_LINE_H 2 | #define CONCURRENCPP_CACHE_LINE_H 3 | 4 | #include "concurrencpp/platform_defs.h" 5 | 6 | #include 7 | 8 | #if !defined(CRCPP_MAC_OS) && defined(__cpp_lib_hardware_interference_size) 9 | # define CRCPP_CACHE_LINE_ALIGNMENT std::hardware_destructive_interference_size 10 | #else 11 | # define CRCPP_CACHE_LINE_ALIGNMENT 64 12 | #endif 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/threads/thread.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_THREAD_H 2 | #define CONCURRENCPP_THREAD_H 3 | 4 | #include 5 | #include 6 | 7 | namespace concurrencpp::details { 8 | class thread { 9 | 10 | private: 11 | std::thread m_thread; 12 | 13 | static void set_name(std::string_view name) noexcept; 14 | 15 | public: 16 | thread() noexcept = default; 17 | thread(thread&&) noexcept = default; 18 | 19 | template 20 | thread(std::string name, callable_type&& callable) { 21 | m_thread = std::thread([name = std::move(name), callable = std::forward(callable)]() mutable { 22 | set_name(name); 23 | callable(); 24 | }); 25 | } 26 | 27 | thread& operator=(thread&& rhs) noexcept = default; 28 | 29 | std::thread::id get_id() const noexcept; 30 | 31 | static std::uintptr_t get_current_virtual_id() noexcept; 32 | 33 | bool joinable() const noexcept; 34 | void join(); 35 | 36 | static size_t hardware_concurrency() noexcept; 37 | }; 38 | } // namespace concurrencpp::details 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/include/concurrencpp/timers/constants.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_TIMER_CONSTS_H 2 | #define CONCURRENCPP_TIMER_CONSTS_H 3 | 4 | namespace concurrencpp::details::consts { 5 | inline const char* k_timer_empty_get_due_time_err_msg = "timer::get_due_time() - timer is empty."; 6 | inline const char* k_timer_empty_get_frequency_err_msg = "timer::get_frequency() - timer is empty."; 7 | inline const char* k_timer_empty_get_executor_err_msg = "timer::get_executor() - timer is empty."; 8 | inline const char* k_timer_empty_get_timer_queue_err_msg = "timer::get_timer_queue() - timer is empty."; 9 | inline const char* k_timer_empty_set_frequency_err_msg = "timer::set_frequency() - timer is empty."; 10 | 11 | inline const char* k_timer_queue_make_timer_executor_null_err_msg = "timer_queue::make_timer() - executor is null."; 12 | inline const char* k_timer_queue_make_oneshot_timer_executor_null_err_msg = 13 | "timer_queue::make_one_shot_timer() - executor is null."; 14 | inline const char* k_timer_queue_make_delay_object_executor_null_err_msg = "timer_queue::make_delay_object() - executor is null."; 15 | inline const char* k_timer_queue_shutdown_err_msg = "timer_queue has been shut down."; 16 | } // namespace concurrencpp::details::consts 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/sandbox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(sandbox LANGUAGES CXX) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/..") 7 | FetchContent_MakeAvailable(concurrencpp) 8 | 9 | include(../cmake/coroutineOptions.cmake) 10 | 11 | add_executable(sandbox main.cpp) 12 | 13 | target_compile_features(sandbox PRIVATE cxx_std_20) 14 | 15 | target_link_libraries(sandbox PRIVATE concurrencpp::concurrencpp) 16 | 17 | target_coroutine_options(sandbox) 18 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/sandbox/main.cpp: -------------------------------------------------------------------------------- 1 | #include "concurrencpp/concurrencpp.h" 2 | 3 | #include 4 | 5 | int main() { 6 | concurrencpp::runtime runtime; 7 | auto result = runtime.thread_pool_executor()->submit([] { 8 | std::cout << "hello world" << std::endl; 9 | }); 10 | 11 | result.get(); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/source/executors/executor.cpp: -------------------------------------------------------------------------------- 1 | #include "concurrencpp/executors/executor.h" 2 | #include "concurrencpp/executors/constants.h" 3 | 4 | #include "concurrencpp/errors.h" 5 | #include "concurrencpp/threads/thread.h" 6 | 7 | void concurrencpp::details::throw_runtime_shutdown_exception(std::string_view executor_name) { 8 | const auto error_msg = std::string(executor_name) + consts::k_executor_shutdown_err_msg; 9 | throw errors::runtime_shutdown(error_msg); 10 | } 11 | 12 | std::string concurrencpp::details::make_executor_worker_name(std::string_view executor_name) { 13 | return std::string(executor_name) + " worker"; 14 | } 15 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/source/results/promises.cpp: -------------------------------------------------------------------------------- 1 | #include "concurrencpp/results/promises.h" 2 | #include "concurrencpp/coroutines/coroutine.h" 3 | 4 | using concurrencpp::details::coroutine_per_thread_data; 5 | 6 | thread_local coroutine_per_thread_data coroutine_per_thread_data::s_tl_per_thread_data; 7 | 8 | void concurrencpp::details::initial_accumulating_awaiter::await_suspend(coroutine_handle handle) noexcept { 9 | m_await_context.set_coro_handle(handle); 10 | 11 | auto& per_thread_data = coroutine_per_thread_data::s_tl_per_thread_data; 12 | auto accumulator = std::exchange(per_thread_data.accumulator, nullptr); 13 | 14 | assert(accumulator != nullptr); 15 | assert(accumulator->capacity() > accumulator->size()); // so it's always noexcept 16 | accumulator->emplace_back(await_via_functor {&m_await_context}); 17 | } 18 | 19 | void concurrencpp::details::initial_accumulating_awaiter::await_resume() { 20 | m_await_context.throw_if_interrupted(); 21 | } 22 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/test/include/infra/tester.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_TESTER_H 2 | #define CONCURRENCPP_TESTER_H 3 | 4 | #include 5 | #include 6 | 7 | namespace concurrencpp::tests { 8 | class test_step { 9 | 10 | private: 11 | const char* m_step_name; 12 | std::function m_step; 13 | 14 | public: 15 | test_step(const char* step_name, std::function callable); 16 | 17 | void launch_test_step() noexcept; 18 | }; 19 | 20 | class tester { 21 | 22 | private: 23 | const char* m_test_name; 24 | std::deque m_steps; 25 | 26 | public: 27 | tester(const char* test_name) noexcept; 28 | 29 | void launch_test() noexcept; 30 | void add_step(const char* step_name, std::function callable); 31 | }; 32 | 33 | } // namespace concurrencpp::tests 34 | 35 | #endif // CONCURRENCPP_TESTER_H 36 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/test/include/utils/custom_exception.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_CUSTOM_EXCEPTION_H 2 | #define CONCURRENCPP_CUSTOM_EXCEPTION_H 3 | 4 | #include 5 | #include 6 | 7 | namespace concurrencpp::tests { 8 | struct custom_exception : public std::exception { 9 | const intptr_t id; 10 | 11 | custom_exception(intptr_t id) noexcept : id(id) {} 12 | }; 13 | } // namespace concurrencpp::tests 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/test/include/utils/executor_shutdowner.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_EXECUTOR_TEST_HELPERS_H 2 | #define CONCURRENCPP_EXECUTOR_TEST_HELPERS_H 3 | 4 | #include "concurrencpp/executors/executor.h" 5 | 6 | namespace concurrencpp::tests { 7 | struct executor_shutdowner { 8 | std::shared_ptr executor; 9 | 10 | executor_shutdowner(std::shared_ptr executor) noexcept : executor(std::move(executor)) {} 11 | 12 | ~executor_shutdowner() noexcept { 13 | executor->shutdown(); 14 | } 15 | }; 16 | } // namespace concurrencpp::tests 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/test/include/utils/random.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_RANDOM_H 2 | #define CONCURRENCPP_RANDOM_H 3 | 4 | #include 5 | 6 | namespace concurrencpp::tests { 7 | class random { 8 | 9 | private: 10 | std::random_device rd; 11 | std::mt19937 mt; 12 | std::uniform_int_distribution dist; 13 | 14 | public: 15 | random() noexcept : mt(rd()), dist(-1'000'000, 1'000'000) {} 16 | 17 | intptr_t operator()() { 18 | return dist(mt); 19 | } 20 | 21 | int64_t operator()(int64_t min, int64_t max) { 22 | const auto r = (*this)(); 23 | const auto upper_limit = max - min + 1; 24 | return std::abs(r) % upper_limit + min; 25 | } 26 | }; 27 | } // namespace concurrencpp::tests 28 | 29 | #endif // CONCURRENCPP_RANDOM_H 30 | -------------------------------------------------------------------------------- /examples/libraries/concurrencpp/test/include/utils/throwing_executor.h: -------------------------------------------------------------------------------- 1 | #ifndef CONCURRENCPP_RESULT_TEST_EXECUTORS_H 2 | #define CONCURRENCPP_RESULT_TEST_EXECUTORS_H 3 | 4 | #include "concurrencpp/executors/executor.h" 5 | 6 | namespace concurrencpp::tests { 7 | struct executor_enqueue_exception {}; 8 | 9 | struct throwing_executor : public concurrencpp::executor { 10 | throwing_executor() : executor("throwing_executor") {} 11 | 12 | void enqueue(concurrencpp::task) override { 13 | throw executor_enqueue_exception(); 14 | } 15 | 16 | void enqueue(std::span) override { 17 | throw executor_enqueue_exception(); 18 | } 19 | 20 | int max_concurrency_level() const noexcept override { 21 | return 0; 22 | } 23 | 24 | bool shutdown_requested() const noexcept override { 25 | return false; 26 | } 27 | 28 | void shutdown() noexcept override { 29 | // do nothing 30 | } 31 | }; 32 | } // namespace concurrencpp::tests 33 | 34 | #endif // CONCURRENCPP_RESULT_HELPERS_H 35 | -------------------------------------------------------------------------------- /examples/libraries/fmt/.clang-format: -------------------------------------------------------------------------------- 1 | # Run manually to reformat a file: 2 | # clang-format -i --style=file 3 | Language: Cpp 4 | BasedOnStyle: Google 5 | IndentPPDirectives: AfterHash 6 | IndentCaseLabels: false 7 | AlwaysBreakTemplateDeclarations: false 8 | DerivePointerAlignment: false 9 | -------------------------------------------------------------------------------- /examples/libraries/fmt/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /examples/libraries/fmt/.github/workflows/doc.yml: -------------------------------------------------------------------------------- 1 | name: doc 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | # Use Ubuntu 20.04 because doxygen 1.8.13 from Ubuntu 18.04 is broken. 8 | runs-on: ubuntu-20.04 9 | 10 | steps: 11 | - uses: actions/checkout@v2 12 | 13 | - name: Create Build Environment 14 | run: | 15 | sudo apt update 16 | sudo apt install doxygen python3-virtualenv 17 | sudo npm install -g less clean-css 18 | cmake -E make_directory ${{runner.workspace}}/build 19 | 20 | - name: Build 21 | working-directory: ${{runner.workspace}}/build 22 | env: 23 | KEY: ${{secrets.KEY}} 24 | run: $GITHUB_WORKSPACE/support/build-docs.py 25 | -------------------------------------------------------------------------------- /examples/libraries/fmt/.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: macos 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: macos-10.15 8 | strategy: 9 | matrix: 10 | build_type: [Debug, Release] 11 | include: 12 | - shared: -DBUILD_SHARED_LIBS=ON 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - name: Create Build Environment 18 | run: cmake -E make_directory ${{runner.workspace}}/build 19 | 20 | - name: Configure 21 | working-directory: ${{runner.workspace}}/build 22 | run: | 23 | cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{matrix.shared}} \ 24 | -DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_VISIBILITY_INLINES_HIDDEN=ON \ 25 | -DFMT_DOC=OFF -DFMT_PEDANTIC=ON -DFMT_WERROR=ON $GITHUB_WORKSPACE 26 | 27 | - name: Build 28 | working-directory: ${{runner.workspace}}/build 29 | run: | 30 | threads=`sysctl -n hw.logicalcpu` 31 | cmake --build . --config ${{matrix.build_type}} --parallel $threads 32 | 33 | - name: Test 34 | working-directory: ${{runner.workspace}}/build 35 | run: ctest -C ${{matrix.build_type}} 36 | env: 37 | CTEST_OUTPUT_ON_FAILURE: True 38 | -------------------------------------------------------------------------------- /examples/libraries/fmt/.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | .vs/ 3 | 4 | *.iml 5 | .idea/ 6 | .externalNativeBuild/ 7 | .gradle/ 8 | gradle/ 9 | gradlew* 10 | local.properties 11 | build/ 12 | support/.cxx 13 | 14 | bin/ 15 | /_CPack_Packages 16 | /CMakeScripts 17 | /doc/doxyxml 18 | /doc/html 19 | /doc/node_modules 20 | virtualenv 21 | /Testing 22 | /install_manifest.txt 23 | *~ 24 | *.a 25 | *.so* 26 | *.xcodeproj 27 | *.zip 28 | cmake_install.cmake 29 | CPack*.cmake 30 | fmt-*.cmake 31 | CTestTestfile.cmake 32 | CMakeCache.txt 33 | CMakeFiles 34 | FMT.build 35 | Makefile 36 | run-msbuild.bat 37 | fmt.pc 38 | -------------------------------------------------------------------------------- /examples/libraries/fmt/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing to {fmt} 2 | ===================== 3 | 4 | By submitting a pull request or a patch, you represent that you have the right 5 | to license your contribution to the {fmt} project owners and the community, 6 | agree that your contributions are licensed under the {fmt} license, and agree 7 | to future changes to the licensing. 8 | 9 | All C++ code must adhere to [Google C++ Style Guide]( 10 | https://google.github.io/styleguide/cppguide.html) with the following 11 | exceptions: 12 | 13 | * Exceptions are permitted 14 | * snake_case should be used instead of UpperCamelCase for function and type 15 | names 16 | 17 | All documentation must adhere to the [Google Developer Documentation Style 18 | Guide](https://developers.google.com/style). 19 | 20 | Thanks for contributing! 21 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_program(DOXYGEN doxygen) 2 | if (NOT DOXYGEN) 3 | message(STATUS "Target 'doc' disabled (requires doxygen)") 4 | return () 5 | endif () 6 | 7 | find_package(PythonInterp QUIET REQUIRED) 8 | 9 | add_custom_target(doc 10 | COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/build.py 11 | ${FMT_VERSION} 12 | SOURCES api.rst syntax.rst usage.rst build.py conf.py _templates/layout.html) 13 | 14 | include(GNUInstallDirs) 15 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ 16 | DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/fmt OPTIONAL 17 | PATTERN ".doctrees" EXCLUDE) 18 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/_static/breathe.css: -------------------------------------------------------------------------------- 1 | 2 | /* -- breathe specific styles ----------------------------------------------- */ 3 | 4 | /* So enum value descriptions are displayed inline to the item */ 5 | .breatheenumvalues li tt + p { 6 | display: inline; 7 | } 8 | 9 | /* So parameter descriptions are displayed inline to the item */ 10 | .breatheparameterlist li tt + p { 11 | display: inline; 12 | } 13 | 14 | .container .breathe-sectiondef { 15 | width: inherit; 16 | } 17 | 18 | .github-btn { 19 | border: 0; 20 | overflow: hidden; 21 | } 22 | 23 | .jumbotron { 24 | background-size: 100% 4px; 25 | background-repeat: repeat-y; 26 | color: white; 27 | text-align: center; 28 | } 29 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/_static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/libraries/fmt/doc/_static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/_static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/libraries/fmt/doc/_static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/_static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/libraries/fmt/doc/_static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/basic-bootstrap/README: -------------------------------------------------------------------------------- 1 | Sphinx basic theme with Bootstrap support. Modifications are kept to 2 | a minimum to simplify integration in case of changes to Sphinx theming. 3 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/basic-bootstrap/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/bootstrap.less: -------------------------------------------------------------------------------- 1 | // Core variables and mixins 2 | @import "variables.less"; 3 | @import "mixins.less"; 4 | 5 | // Reset and dependencies 6 | @import "normalize.less"; 7 | @import "print.less"; 8 | @import "glyphicons.less"; 9 | 10 | // Core CSS 11 | @import "scaffolding.less"; 12 | @import "type.less"; 13 | @import "code.less"; 14 | @import "grid.less"; 15 | @import "tables.less"; 16 | @import "forms.less"; 17 | @import "buttons.less"; 18 | 19 | // Components 20 | @import "component-animations.less"; 21 | @import "dropdowns.less"; 22 | @import "button-groups.less"; 23 | @import "input-groups.less"; 24 | @import "navs.less"; 25 | @import "navbar.less"; 26 | @import "breadcrumbs.less"; 27 | @import "pagination.less"; 28 | @import "pager.less"; 29 | @import "labels.less"; 30 | @import "badges.less"; 31 | @import "jumbotron.less"; 32 | @import "thumbnails.less"; 33 | @import "alerts.less"; 34 | @import "progress-bars.less"; 35 | @import "media.less"; 36 | @import "list-group.less"; 37 | @import "panels.less"; 38 | @import "responsive-embed.less"; 39 | @import "wells.less"; 40 | @import "close.less"; 41 | 42 | // Components w/ JavaScript 43 | @import "modals.less"; 44 | @import "tooltip.less"; 45 | @import "popovers.less"; 46 | @import "carousel.less"; 47 | 48 | // Utility classes 49 | @import "utilities.less"; 50 | @import "responsive-utilities.less"; 51 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/breadcrumbs.less: -------------------------------------------------------------------------------- 1 | // 2 | // Breadcrumbs 3 | // -------------------------------------------------- 4 | 5 | 6 | .breadcrumb { 7 | padding: @breadcrumb-padding-vertical @breadcrumb-padding-horizontal; 8 | margin-bottom: @line-height-computed; 9 | list-style: none; 10 | background-color: @breadcrumb-bg; 11 | border-radius: @border-radius-base; 12 | 13 | > li { 14 | display: inline-block; 15 | 16 | + li:before { 17 | content: "@{breadcrumb-separator}\00a0"; // Unicode space added since inline-block means non-collapsing white-space 18 | padding: 0 5px; 19 | color: @breadcrumb-color; 20 | } 21 | } 22 | 23 | > .active { 24 | color: @breadcrumb-active-color; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/close.less: -------------------------------------------------------------------------------- 1 | // 2 | // Close icons 3 | // -------------------------------------------------- 4 | 5 | 6 | .close { 7 | float: right; 8 | font-size: (@font-size-base * 1.5); 9 | font-weight: @close-font-weight; 10 | line-height: 1; 11 | color: @close-color; 12 | text-shadow: @close-text-shadow; 13 | .opacity(.2); 14 | 15 | &:hover, 16 | &:focus { 17 | color: @close-color; 18 | text-decoration: none; 19 | cursor: pointer; 20 | .opacity(.5); 21 | } 22 | 23 | // Additional properties for button version 24 | // iOS requires the button element instead of an anchor tag. 25 | // If you want the anchor version, it requires `href="#"`. 26 | // See https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile 27 | button& { 28 | padding: 0; 29 | cursor: pointer; 30 | background: transparent; 31 | border: 0; 32 | -webkit-appearance: none; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/component-animations.less: -------------------------------------------------------------------------------- 1 | // 2 | // Component animations 3 | // -------------------------------------------------- 4 | 5 | // Heads up! 6 | // 7 | // We don't use the `.opacity()` mixin here since it causes a bug with text 8 | // fields in IE7-8. Source: https://github.com/twbs/bootstrap/pull/3552. 9 | 10 | .fade { 11 | opacity: 0; 12 | .transition(opacity .15s linear); 13 | &.in { 14 | opacity: 1; 15 | } 16 | } 17 | 18 | .collapse { 19 | display: none; 20 | 21 | &.in { display: block; } 22 | tr&.in { display: table-row; } 23 | tbody&.in { display: table-row-group; } 24 | } 25 | 26 | .collapsing { 27 | position: relative; 28 | height: 0; 29 | overflow: hidden; 30 | .transition-property(~"height, visibility"); 31 | .transition-duration(.35s); 32 | .transition-timing-function(ease); 33 | } 34 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/jumbotron.less: -------------------------------------------------------------------------------- 1 | // 2 | // Jumbotron 3 | // -------------------------------------------------- 4 | 5 | 6 | .jumbotron { 7 | padding: @jumbotron-padding (@jumbotron-padding / 2); 8 | margin-bottom: @jumbotron-padding; 9 | color: @jumbotron-color; 10 | background-color: @jumbotron-bg; 11 | 12 | h1, 13 | .h1 { 14 | color: @jumbotron-heading-color; 15 | } 16 | 17 | p { 18 | margin-bottom: (@jumbotron-padding / 2); 19 | font-size: @jumbotron-font-size; 20 | font-weight: 200; 21 | } 22 | 23 | > hr { 24 | border-top-color: darken(@jumbotron-bg, 10%); 25 | } 26 | 27 | .tb-container &, 28 | .container-fluid & { 29 | border-radius: @border-radius-large; // Only round corners at higher resolutions if contained in a container 30 | } 31 | 32 | .tb-container { 33 | max-width: 100%; 34 | } 35 | 36 | @media screen and (min-width: @screen-sm-min) { 37 | padding: (@jumbotron-padding * 1.6) 0; 38 | 39 | .tb-container &, 40 | .container-fluid & { 41 | padding-left: (@jumbotron-padding * 2); 42 | padding-right: (@jumbotron-padding * 2); 43 | } 44 | 45 | h1, 46 | .h1 { 47 | font-size: (@font-size-base * 4.5); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/media.less: -------------------------------------------------------------------------------- 1 | .media { 2 | // Proper spacing between instances of .media 3 | margin-top: 15px; 4 | 5 | &:first-child { 6 | margin-top: 0; 7 | } 8 | } 9 | 10 | .media, 11 | .media-body { 12 | zoom: 1; 13 | overflow: hidden; 14 | } 15 | 16 | .media-body { 17 | width: 10000px; 18 | } 19 | 20 | .media-object { 21 | display: block; 22 | } 23 | 24 | .media-right, 25 | .media > .pull-right { 26 | padding-left: 10px; 27 | } 28 | 29 | .media-left, 30 | .media > .pull-left { 31 | padding-right: 10px; 32 | } 33 | 34 | .media-left, 35 | .media-right, 36 | .media-body { 37 | display: table-cell; 38 | vertical-align: top; 39 | } 40 | 41 | .media-middle { 42 | vertical-align: middle; 43 | } 44 | 45 | .media-bottom { 46 | vertical-align: bottom; 47 | } 48 | 49 | // Reset margins on headings for tighter default spacing 50 | .media-heading { 51 | margin-top: 0; 52 | margin-bottom: 5px; 53 | } 54 | 55 | // Media list variation 56 | // 57 | // Undo default ul/ol styles 58 | .media-list { 59 | padding-left: 0; 60 | list-style: none; 61 | } 62 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins.less: -------------------------------------------------------------------------------- 1 | // Mixins 2 | // -------------------------------------------------- 3 | 4 | // Utilities 5 | @import "mixins/hide-text.less"; 6 | @import "mixins/opacity.less"; 7 | @import "mixins/image.less"; 8 | @import "mixins/labels.less"; 9 | @import "mixins/reset-filter.less"; 10 | @import "mixins/resize.less"; 11 | @import "mixins/responsive-visibility.less"; 12 | @import "mixins/size.less"; 13 | @import "mixins/tab-focus.less"; 14 | @import "mixins/text-emphasis.less"; 15 | @import "mixins/text-overflow.less"; 16 | @import "mixins/vendor-prefixes.less"; 17 | 18 | // Components 19 | @import "mixins/alerts.less"; 20 | @import "mixins/buttons.less"; 21 | @import "mixins/panels.less"; 22 | @import "mixins/pagination.less"; 23 | @import "mixins/list-group.less"; 24 | @import "mixins/nav-divider.less"; 25 | @import "mixins/forms.less"; 26 | @import "mixins/progress-bar.less"; 27 | @import "mixins/table-row.less"; 28 | 29 | // Skins 30 | @import "mixins/background-variant.less"; 31 | @import "mixins/border-radius.less"; 32 | @import "mixins/gradients.less"; 33 | 34 | // Layout 35 | @import "mixins/clearfix.less"; 36 | @import "mixins/center-block.less"; 37 | @import "mixins/nav-vertical-align.less"; 38 | @import "mixins/grid-framework.less"; 39 | @import "mixins/grid.less"; 40 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/alerts.less: -------------------------------------------------------------------------------- 1 | // Alerts 2 | 3 | .alert-variant(@background; @border; @text-color) { 4 | background-color: @background; 5 | border-color: @border; 6 | color: @text-color; 7 | 8 | hr { 9 | border-top-color: darken(@border, 5%); 10 | } 11 | .alert-link { 12 | color: darken(@text-color, 10%); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/background-variant.less: -------------------------------------------------------------------------------- 1 | // Contextual backgrounds 2 | 3 | .bg-variant(@color) { 4 | background-color: @color; 5 | a&:hover { 6 | background-color: darken(@color, 10%); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/border-radius.less: -------------------------------------------------------------------------------- 1 | // Single side border-radius 2 | 3 | .border-top-radius(@radius) { 4 | border-top-right-radius: @radius; 5 | border-top-left-radius: @radius; 6 | } 7 | .border-right-radius(@radius) { 8 | border-bottom-right-radius: @radius; 9 | border-top-right-radius: @radius; 10 | } 11 | .border-bottom-radius(@radius) { 12 | border-bottom-right-radius: @radius; 13 | border-bottom-left-radius: @radius; 14 | } 15 | .border-left-radius(@radius) { 16 | border-bottom-left-radius: @radius; 17 | border-top-left-radius: @radius; 18 | } 19 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/buttons.less: -------------------------------------------------------------------------------- 1 | // Button variants 2 | // 3 | // Easily pump out default styles, as well as :hover, :focus, :active, 4 | // and disabled options for all buttons 5 | 6 | .button-variant(@color; @background; @border) { 7 | color: @color; 8 | background-color: @background; 9 | border-color: @border; 10 | 11 | &:hover, 12 | &:focus, 13 | &.focus, 14 | &:active, 15 | &.active, 16 | .open > .dropdown-toggle& { 17 | color: @color; 18 | background-color: darken(@background, 10%); 19 | border-color: darken(@border, 12%); 20 | } 21 | &:active, 22 | &.active, 23 | .open > .dropdown-toggle& { 24 | background-image: none; 25 | } 26 | &.disabled, 27 | &[disabled], 28 | fieldset[disabled] & { 29 | &, 30 | &:hover, 31 | &:focus, 32 | &.focus, 33 | &:active, 34 | &.active { 35 | background-color: @background; 36 | border-color: @border; 37 | } 38 | } 39 | 40 | .badge { 41 | color: @background; 42 | background-color: @color; 43 | } 44 | } 45 | 46 | // Button sizes 47 | .button-size(@padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) { 48 | padding: @padding-vertical @padding-horizontal; 49 | font-size: @font-size; 50 | line-height: @line-height; 51 | border-radius: @border-radius; 52 | } 53 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/center-block.less: -------------------------------------------------------------------------------- 1 | // Center-align a block level element 2 | 3 | .center-block() { 4 | display: block; 5 | margin-left: auto; 6 | margin-right: auto; 7 | } 8 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/clearfix.less: -------------------------------------------------------------------------------- 1 | // Clearfix 2 | // 3 | // For modern browsers 4 | // 1. The space content is one way to avoid an Opera bug when the 5 | // contenteditable attribute is included anywhere else in the document. 6 | // Otherwise it causes space to appear at the top and bottom of elements 7 | // that are clearfixed. 8 | // 2. The use of `table` rather than `block` is only necessary if using 9 | // `:before` to contain the top-margins of child elements. 10 | // 11 | // Source: http://nicolasgallagher.com/micro-clearfix-hack/ 12 | 13 | .clearfix() { 14 | &:before, 15 | &:after { 16 | content: " "; // 1 17 | display: table; // 2 18 | } 19 | &:after { 20 | clear: both; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/hide-text.less: -------------------------------------------------------------------------------- 1 | // CSS image replacement 2 | // 3 | // Heads up! v3 launched with with only `.hide-text()`, but per our pattern for 4 | // mixins being reused as classes with the same name, this doesn't hold up. As 5 | // of v3.0.1 we have added `.text-hide()` and deprecated `.hide-text()`. 6 | // 7 | // Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757 8 | 9 | // Deprecated as of v3.0.1 (will be removed in v4) 10 | .hide-text() { 11 | font: ~"0/0" a; 12 | color: transparent; 13 | text-shadow: none; 14 | background-color: transparent; 15 | border: 0; 16 | } 17 | 18 | // New mixin to use as of v3.0.1 19 | .text-hide() { 20 | .hide-text(); 21 | } 22 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/image.less: -------------------------------------------------------------------------------- 1 | // Image Mixins 2 | // - Responsive image 3 | // - Retina image 4 | 5 | 6 | // Responsive image 7 | // 8 | // Keep images from scaling beyond the width of their parents. 9 | .img-responsive(@display: block) { 10 | display: @display; 11 | max-width: 100%; // Part 1: Set a maximum relative to the parent 12 | height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching 13 | } 14 | 15 | 16 | // Retina image 17 | // 18 | // Short retina mixin for setting background-image and -size. Note that the 19 | // spelling of `min--moz-device-pixel-ratio` is intentional. 20 | .img-retina(@file-1x; @file-2x; @width-1x; @height-1x) { 21 | background-image: url("@{file-1x}"); 22 | 23 | @media 24 | only screen and (-webkit-min-device-pixel-ratio: 2), 25 | only screen and ( min--moz-device-pixel-ratio: 2), 26 | only screen and ( -o-min-device-pixel-ratio: 2/1), 27 | only screen and ( min-device-pixel-ratio: 2), 28 | only screen and ( min-resolution: 192dpi), 29 | only screen and ( min-resolution: 2dppx) { 30 | background-image: url("@{file-2x}"); 31 | background-size: @width-1x @height-1x; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/labels.less: -------------------------------------------------------------------------------- 1 | // Labels 2 | 3 | .label-variant(@color) { 4 | background-color: @color; 5 | 6 | &[href] { 7 | &:hover, 8 | &:focus { 9 | background-color: darken(@color, 10%); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/list-group.less: -------------------------------------------------------------------------------- 1 | // List Groups 2 | 3 | .list-group-item-variant(@state; @background; @color) { 4 | .list-group-item-@{state} { 5 | color: @color; 6 | background-color: @background; 7 | 8 | a& { 9 | color: @color; 10 | 11 | .list-group-item-heading { 12 | color: inherit; 13 | } 14 | 15 | &:hover, 16 | &:focus { 17 | color: @color; 18 | background-color: darken(@background, 5%); 19 | } 20 | &.active, 21 | &.active:hover, 22 | &.active:focus { 23 | color: #fff; 24 | background-color: @color; 25 | border-color: @color; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/nav-divider.less: -------------------------------------------------------------------------------- 1 | // Horizontal dividers 2 | // 3 | // Dividers (basically an hr) within dropdowns and nav lists 4 | 5 | .nav-divider(@color: #e5e5e5) { 6 | height: 1px; 7 | margin: ((@line-height-computed / 2) - 1) 0; 8 | overflow: hidden; 9 | background-color: @color; 10 | } 11 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/nav-vertical-align.less: -------------------------------------------------------------------------------- 1 | // Navbar vertical align 2 | // 3 | // Vertically center elements in the navbar. 4 | // Example: an element has a height of 30px, so write out `.navbar-vertical-align(30px);` to calculate the appropriate top margin. 5 | 6 | .navbar-vertical-align(@element-height) { 7 | margin-top: ((@navbar-height - @element-height) / 2); 8 | margin-bottom: ((@navbar-height - @element-height) / 2); 9 | } 10 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/opacity.less: -------------------------------------------------------------------------------- 1 | // Opacity 2 | 3 | .opacity(@opacity) { 4 | opacity: @opacity; 5 | // IE8 filter 6 | @opacity-ie: (@opacity * 100); 7 | filter: ~"alpha(opacity=@{opacity-ie})"; 8 | } 9 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/pagination.less: -------------------------------------------------------------------------------- 1 | // Pagination 2 | 3 | .pagination-size(@padding-vertical; @padding-horizontal; @font-size; @border-radius) { 4 | > li { 5 | > a, 6 | > span { 7 | padding: @padding-vertical @padding-horizontal; 8 | font-size: @font-size; 9 | } 10 | &:first-child { 11 | > a, 12 | > span { 13 | .border-left-radius(@border-radius); 14 | } 15 | } 16 | &:last-child { 17 | > a, 18 | > span { 19 | .border-right-radius(@border-radius); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/panels.less: -------------------------------------------------------------------------------- 1 | // Panels 2 | 3 | .panel-variant(@border; @heading-text-color; @heading-bg-color; @heading-border) { 4 | border-color: @border; 5 | 6 | & > .panel-heading { 7 | color: @heading-text-color; 8 | background-color: @heading-bg-color; 9 | border-color: @heading-border; 10 | 11 | + .panel-collapse > .panel-body { 12 | border-top-color: @border; 13 | } 14 | .badge { 15 | color: @heading-bg-color; 16 | background-color: @heading-text-color; 17 | } 18 | } 19 | & > .panel-footer { 20 | + .panel-collapse > .panel-body { 21 | border-bottom-color: @border; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/progress-bar.less: -------------------------------------------------------------------------------- 1 | // Progress bars 2 | 3 | .progress-bar-variant(@color) { 4 | background-color: @color; 5 | 6 | // Deprecated parent class requirement as of v3.2.0 7 | .progress-striped & { 8 | #gradient > .striped(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/reset-filter.less: -------------------------------------------------------------------------------- 1 | // Reset filters for IE 2 | // 3 | // When you need to remove a gradient background, do not forget to use this to reset 4 | // the IE filter for IE9 and below. 5 | 6 | .reset-filter() { 7 | filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)")); 8 | } 9 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/resize.less: -------------------------------------------------------------------------------- 1 | // Resize anything 2 | 3 | .resizable(@direction) { 4 | resize: @direction; // Options: horizontal, vertical, both 5 | overflow: auto; // Per CSS3 UI, `resize` only applies when `overflow` isn't `visible` 6 | } 7 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/responsive-visibility.less: -------------------------------------------------------------------------------- 1 | // Responsive utilities 2 | 3 | // 4 | // More easily include all the states for responsive-utilities.less. 5 | .responsive-visibility() { 6 | display: block !important; 7 | table& { display: table; } 8 | tr& { display: table-row !important; } 9 | th&, 10 | td& { display: table-cell !important; } 11 | } 12 | 13 | .responsive-invisibility() { 14 | display: none !important; 15 | } 16 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/size.less: -------------------------------------------------------------------------------- 1 | // Sizing shortcuts 2 | 3 | .size(@width; @height) { 4 | width: @width; 5 | height: @height; 6 | } 7 | 8 | .square(@size) { 9 | .size(@size; @size); 10 | } 11 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/tab-focus.less: -------------------------------------------------------------------------------- 1 | // WebKit-style focus 2 | 3 | .tab-focus() { 4 | // Default 5 | outline: thin dotted; 6 | // WebKit 7 | outline: 5px auto -webkit-focus-ring-color; 8 | outline-offset: -2px; 9 | } 10 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/table-row.less: -------------------------------------------------------------------------------- 1 | // Tables 2 | 3 | .table-row-variant(@state; @background) { 4 | // Exact selectors below required to override `.table-striped` and prevent 5 | // inheritance to nested tables. 6 | .table > thead > tr, 7 | .table > tbody > tr, 8 | .table > tfoot > tr { 9 | > td.@{state}, 10 | > th.@{state}, 11 | &.@{state} > td, 12 | &.@{state} > th { 13 | background-color: @background; 14 | } 15 | } 16 | 17 | // Hover states for `.table-hover` 18 | // Note: this is not available for cells or rows within `thead` or `tfoot`. 19 | .table-hover > tbody > tr { 20 | > td.@{state}:hover, 21 | > th.@{state}:hover, 22 | &.@{state}:hover > td, 23 | &:hover > .@{state}, 24 | &.@{state}:hover > th { 25 | background-color: darken(@background, 5%); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/text-emphasis.less: -------------------------------------------------------------------------------- 1 | // Typography 2 | 3 | .text-emphasis-variant(@color) { 4 | color: @color; 5 | a&:hover { 6 | color: darken(@color, 10%); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/mixins/text-overflow.less: -------------------------------------------------------------------------------- 1 | // Text overflow 2 | // Requires inline-block or block for proper styling 3 | 4 | .text-overflow() { 5 | overflow: hidden; 6 | text-overflow: ellipsis; 7 | white-space: nowrap; 8 | } 9 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/pager.less: -------------------------------------------------------------------------------- 1 | // 2 | // Pager pagination 3 | // -------------------------------------------------- 4 | 5 | 6 | .pager { 7 | padding-left: 0; 8 | margin: @line-height-computed 0; 9 | list-style: none; 10 | text-align: center; 11 | &:extend(.clearfix all); 12 | li { 13 | display: inline; 14 | > a, 15 | > span { 16 | display: inline-block; 17 | padding: 5px 14px; 18 | background-color: @pager-bg; 19 | border: 1px solid @pager-border; 20 | border-radius: @pager-border-radius; 21 | } 22 | 23 | > a:hover, 24 | > a:focus { 25 | text-decoration: none; 26 | background-color: @pager-hover-bg; 27 | } 28 | } 29 | 30 | .next { 31 | > a, 32 | > span { 33 | float: right; 34 | } 35 | } 36 | 37 | .previous { 38 | > a, 39 | > span { 40 | float: left; 41 | } 42 | } 43 | 44 | .disabled { 45 | > a, 46 | > a:hover, 47 | > a:focus, 48 | > span { 49 | color: @pager-disabled-color; 50 | background-color: @pager-bg; 51 | cursor: @cursor-disabled; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/responsive-embed.less: -------------------------------------------------------------------------------- 1 | // Embeds responsive 2 | // 3 | // Credit: Nicolas Gallagher and SUIT CSS. 4 | 5 | .embed-responsive { 6 | position: relative; 7 | display: block; 8 | height: 0; 9 | padding: 0; 10 | overflow: hidden; 11 | 12 | .embed-responsive-item, 13 | iframe, 14 | embed, 15 | object, 16 | video { 17 | position: absolute; 18 | top: 0; 19 | left: 0; 20 | bottom: 0; 21 | height: 100%; 22 | width: 100%; 23 | border: 0; 24 | } 25 | } 26 | 27 | // Modifier class for 16:9 aspect ratio 28 | .embed-responsive-16by9 { 29 | padding-bottom: 56.25%; 30 | } 31 | 32 | // Modifier class for 4:3 aspect ratio 33 | .embed-responsive-4by3 { 34 | padding-bottom: 75%; 35 | } 36 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/thumbnails.less: -------------------------------------------------------------------------------- 1 | // 2 | // Thumbnails 3 | // -------------------------------------------------- 4 | 5 | 6 | // Mixin and adjust the regular image class 7 | .thumbnail { 8 | display: block; 9 | padding: @thumbnail-padding; 10 | margin-bottom: @line-height-computed; 11 | line-height: @line-height-base; 12 | background-color: @thumbnail-bg; 13 | border: 1px solid @thumbnail-border; 14 | border-radius: @thumbnail-border-radius; 15 | .transition(border .2s ease-in-out); 16 | 17 | > img, 18 | a > img { 19 | &:extend(.img-responsive); 20 | margin-left: auto; 21 | margin-right: auto; 22 | } 23 | 24 | // Add a hover state for linked versions only 25 | a&:hover, 26 | a&:focus, 27 | a&.active { 28 | border-color: @link-color; 29 | } 30 | 31 | // Image captions 32 | .caption { 33 | padding: @thumbnail-caption-padding; 34 | color: @thumbnail-caption-color; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/utilities.less: -------------------------------------------------------------------------------- 1 | // 2 | // Utility classes 3 | // -------------------------------------------------- 4 | 5 | 6 | // Floats 7 | // ------------------------- 8 | 9 | .clearfix { 10 | .clearfix(); 11 | } 12 | .center-block { 13 | .center-block(); 14 | } 15 | .pull-right { 16 | float: right !important; 17 | } 18 | .pull-left { 19 | float: left !important; 20 | } 21 | 22 | 23 | // Toggling content 24 | // ------------------------- 25 | 26 | // Note: Deprecated .hide in favor of .hidden or .sr-only (as appropriate) in v3.0.1 27 | .hide { 28 | display: none !important; 29 | } 30 | .show { 31 | display: block !important; 32 | } 33 | .invisible { 34 | visibility: hidden; 35 | } 36 | .text-hide { 37 | .text-hide(); 38 | } 39 | 40 | 41 | // Hide from screenreaders and browsers 42 | // 43 | // Credit: HTML5 Boilerplate 44 | 45 | .hidden { 46 | display: none !important; 47 | } 48 | 49 | 50 | // For Affix plugin 51 | // ------------------------- 52 | 53 | .affix { 54 | position: fixed; 55 | } 56 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/bootstrap/wells.less: -------------------------------------------------------------------------------- 1 | // 2 | // Wells 3 | // -------------------------------------------------- 4 | 5 | 6 | // Base class 7 | .well { 8 | min-height: 20px; 9 | padding: 19px; 10 | margin-bottom: 20px; 11 | background-color: @well-bg; 12 | border: 1px solid @well-border; 13 | border-radius: @border-radius-base; 14 | .box-shadow(inset 0 1px 1px rgba(0,0,0,.05)); 15 | blockquote { 16 | border-color: #ddd; 17 | border-color: rgba(0,0,0,.15); 18 | } 19 | } 20 | 21 | // Sizes 22 | .well-lg { 23 | padding: 24px; 24 | border-radius: @border-radius-large; 25 | } 26 | .well-sm { 27 | padding: 9px; 28 | border-radius: @border-radius-small; 29 | } 30 | -------------------------------------------------------------------------------- /examples/libraries/fmt/doc/contents.rst: -------------------------------------------------------------------------------- 1 | ######## 2 | Contents 3 | ######## 4 | 5 | .. toctree:: 6 | :maxdepth: 2 7 | 8 | usage 9 | api 10 | syntax 11 | -------------------------------------------------------------------------------- /examples/libraries/fmt/include/fmt/locale.h: -------------------------------------------------------------------------------- 1 | #include "xchar.h" 2 | #warning fmt/locale.h is deprecated, include fmt/format.h or fmt/xchar.h instead 3 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_MODULE := fmt_static 5 | LOCAL_MODULE_FILENAME := libfmt 6 | 7 | LOCAL_SRC_FILES := ../src/format.cc 8 | 9 | LOCAL_C_INCLUDES := $(LOCAL_PATH) 10 | LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) 11 | 12 | LOCAL_CFLAGS += -std=c++11 -fexceptions 13 | 14 | include $(BUILD_STATIC_LIBRARY) 15 | 16 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/README: -------------------------------------------------------------------------------- 1 | This directory contains build support files such as 2 | 3 | * CMake modules 4 | * Build scripts 5 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # A vagrant config for testing against gcc-4.8. 5 | Vagrant.configure("2") do |config| 6 | config.vm.box = "ubuntu/xenial64" 7 | config.disksize.size = '15GB' 8 | 9 | config.vm.provider "virtualbox" do |vb| 10 | vb.memory = "4096" 11 | end 12 | 13 | config.vm.provision "shell", inline: <<-SHELL 14 | apt-get update 15 | apt-get install -y g++ make wget git 16 | wget -q https://github.com/Kitware/CMake/releases/download/v3.14.4/cmake-3.14.4-Linux-x86_64.tar.gz 17 | tar xzf cmake-3.14.4-Linux-x86_64.tar.gz 18 | ln -s `pwd`/cmake-3.14.4-Linux-x86_64/bin/cmake /usr/local/bin 19 | SHELL 20 | end 21 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/appveyor.yml: -------------------------------------------------------------------------------- 1 | configuration: 2 | - Debug 3 | - Release 4 | 5 | clone_depth: 1 6 | 7 | image: 8 | - Visual Studio 2015 9 | 10 | platform: 11 | - x64 12 | 13 | environment: 14 | CTEST_OUTPUT_ON_FAILURE: 1 15 | MSVC_DEFAULT_OPTIONS: ON 16 | BUILD: msvc 17 | 18 | before_build: 19 | - mkdir build 20 | - cd build 21 | 22 | build_script: 23 | - python ../support/appveyor-build.py 24 | 25 | on_failure: 26 | - appveyor PushArtifact Testing/Temporary/LastTest.log 27 | - appveyor AddTest test 28 | 29 | # Uncomment this to debug AppVeyor failures. 30 | #on_finish: 31 | # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) 32 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/cmake/FindSetEnv.cmake: -------------------------------------------------------------------------------- 1 | # A CMake script to find SetEnv.cmd. 2 | 3 | find_program(WINSDK_SETENV NAMES SetEnv.cmd 4 | PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]/bin") 5 | if (WINSDK_SETENV AND PRINT_PATH) 6 | execute_process(COMMAND ${CMAKE_COMMAND} -E echo "${WINSDK_SETENV}") 7 | endif () 8 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/cmake/JoinPaths.cmake: -------------------------------------------------------------------------------- 1 | # This module provides function for joining paths 2 | # known from from most languages 3 | # 4 | # Original license: 5 | # SPDX-License-Identifier: (MIT OR CC0-1.0) 6 | # Explicit permission given to distribute this module under 7 | # the terms of the project as described in /LICENSE.rst. 8 | # Copyright 2020 Jan Tojnar 9 | # https://github.com/jtojnar/cmake-snips 10 | # 11 | # Modelled after Python’s os.path.join 12 | # https://docs.python.org/3.7/library/os.path.html#os.path.join 13 | # Windows not supported 14 | function(join_paths joined_path first_path_segment) 15 | set(temp_path "${first_path_segment}") 16 | foreach(current_segment IN LISTS ARGN) 17 | if(NOT ("${current_segment}" STREQUAL "")) 18 | if(IS_ABSOLUTE "${current_segment}") 19 | set(temp_path "${current_segment}") 20 | else() 21 | set(temp_path "${temp_path}/${current_segment}") 22 | endif() 23 | endif() 24 | endforeach() 25 | set(${joined_path} "${temp_path}" PARENT_SCOPE) 26 | endfunction() 27 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/cmake/fmt-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include(${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake) 4 | check_required_components(fmt) 5 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/cmake/fmt.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@ 3 | libdir=@libdir_for_pc_file@ 4 | includedir=@includedir_for_pc_file@ 5 | 6 | Name: fmt 7 | Description: A modern formatting library 8 | Version: @FMT_VERSION@ 9 | Libs: -L${libdir} -l@FMT_LIB_NAME@ 10 | Cflags: -I${includedir} 11 | 12 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/rtd/conf.py: -------------------------------------------------------------------------------- 1 | # Sphinx configuration for readthedocs. 2 | 3 | import os, sys 4 | 5 | master_doc = 'index' 6 | html_theme = 'theme' 7 | html_theme_path = ["."] 8 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/rtd/index.rst: -------------------------------------------------------------------------------- 1 | If you are not redirected automatically, follow the 2 | `link to the fmt documentation `_. 3 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/rtd/theme/layout.html: -------------------------------------------------------------------------------- 1 | {% extends "basic/layout.html" %} 2 | 3 | {% block extrahead %} 4 | 5 | 6 | 9 | Page Redirection 10 | {% endblock %} 11 | 12 | {% block document %} 13 | If you are not redirected automatically, follow the link to the fmt documentation. 14 | {% endblock %} 15 | 16 | {% block footer %} 17 | {% endblock %} 18 | -------------------------------------------------------------------------------- /examples/libraries/fmt/support/rtd/theme/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/add-subdirectory-test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1...3.18) 2 | 3 | project(fmt-test CXX) 4 | 5 | add_subdirectory(../.. fmt) 6 | 7 | add_executable(library-test main.cc) 8 | target_include_directories(library-test PUBLIC SYSTEM .) 9 | target_compile_options(library-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) 10 | target_link_libraries(library-test fmt::fmt) 11 | 12 | if (TARGET fmt::fmt-header-only) 13 | add_executable(header-only-test main.cc) 14 | target_include_directories(header-only-test PUBLIC SYSTEM .) 15 | target_compile_options(header-only-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) 16 | target_link_libraries(header-only-test fmt::fmt-header-only) 17 | endif () 18 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/add-subdirectory-test/main.cc: -------------------------------------------------------------------------------- 1 | #include "fmt/core.h" 2 | 3 | int main(int argc, char** argv) { 4 | for (int i = 0; i < argc; ++i) fmt::print("{}: {}\n", i, argv[i]); 5 | } 6 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/assert-test.cc: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - FMT_ASSERT test 2 | // 3 | // It is a separate test to minimize the number of EXPECT_DEBUG_DEATH checks 4 | // which are slow on some platforms. In other tests FMT_ASSERT is made to throw 5 | // an exception which is much faster and easier to check. 6 | // 7 | // Copyright (c) 2012 - present, Victor Zverovich 8 | // All rights reserved. 9 | // 10 | // For the license information refer to format.h. 11 | 12 | #include "fmt/core.h" 13 | #include "gtest/gtest.h" 14 | 15 | TEST(assert_test, fail) { 16 | #if GTEST_HAS_DEATH_TEST 17 | EXPECT_DEBUG_DEATH(FMT_ASSERT(false, "don't panic!"), "don't panic!"); 18 | #else 19 | fmt::print("warning: death tests are not supported\n"); 20 | #endif 21 | } 22 | 23 | TEST(assert_test, dangling_else) { 24 | bool test_condition = false; 25 | bool executed_else = false; 26 | if (test_condition) 27 | FMT_ASSERT(true, ""); 28 | else 29 | executed_else = true; 30 | EXPECT_TRUE(executed_else); 31 | } 32 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/cuda-test/cpp14.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // The purpose of this part is to ensure NVCC's host compiler also supports 4 | // the standard version. See 'cuda-cpp14.cu'. 5 | // 6 | // https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros 7 | static_assert(__cplusplus >= 201402L, "expect C++ 2014 for host compiler"); 8 | 9 | auto make_message_cpp() -> std::string { 10 | return fmt::format("host compiler \t: __cplusplus == {}", __cplusplus); 11 | } 12 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/cuda-test/cuda-cpp14.cu: -------------------------------------------------------------------------------- 1 | // Direct NVCC command line example: 2 | // 3 | // nvcc ./cuda-cpp14.cu -x cu -I"../include" -l"fmtd" -L"../build/Debug" \ 4 | // -std=c++14 -Xcompiler /std:c++14 -Xcompiler /Zc:__cplusplus 5 | 6 | // Ensure that we are using the latest C++ standard for NVCC 7 | // The version is C++14 8 | // 9 | // https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#c-cplusplus-language-support 10 | // https://en.cppreference.com/w/cpp/preprocessor/replace#Predefined_macros 11 | static_assert(__cplusplus >= 201402L, "expect C++ 2014 for nvcc"); 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | extern auto make_message_cpp() -> std::string; 19 | extern auto make_message_cuda() -> std::string; 20 | 21 | int main() { 22 | std::cout << make_message_cuda() << std::endl; 23 | std::cout << make_message_cpp() << std::endl; 24 | } 25 | 26 | auto make_message_cuda() -> std::string { 27 | return fmt::format("nvcc compiler \t: __cplusplus == {}", __cplusplus); 28 | } 29 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/find-package-test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1...3.18) 2 | 3 | project(fmt-test) 4 | 5 | find_package(FMT REQUIRED) 6 | 7 | add_executable(library-test main.cc) 8 | target_link_libraries(library-test fmt::fmt) 9 | target_compile_options(library-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) 10 | target_include_directories(library-test PUBLIC SYSTEM .) 11 | 12 | if (TARGET fmt::fmt-header-only) 13 | add_executable(header-only-test main.cc) 14 | target_link_libraries(header-only-test fmt::fmt-header-only) 15 | target_compile_options(header-only-test PRIVATE ${PEDANTIC_COMPILE_FLAGS}) 16 | target_include_directories(header-only-test PUBLIC SYSTEM .) 17 | endif () 18 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/find-package-test/main.cc: -------------------------------------------------------------------------------- 1 | #include "fmt/format.h" 2 | 3 | int main(int argc, char** argv) { 4 | for(int i = 0; i < argc; ++i) 5 | fmt::print("{}: {}\n", i, argv[i]); 6 | } 7 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/fuzzing/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore artifacts from the build.sh script 2 | build-*/ 3 | 4 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/fuzzing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, Paul Dreik 2 | # License: see LICENSE.rst in the fmt root directory 3 | 4 | # Link in the main function. Useful for reproducing, kcov, gdb, afl, valgrind. 5 | # (Note that libFuzzer can also reproduce, just pass it the files.) 6 | option(FMT_FUZZ_LINKMAIN "Enables the reproduce mode, instead of libFuzzer" On) 7 | 8 | # For oss-fuzz - insert $LIB_FUZZING_ENGINE into the link flags, but only for 9 | # the fuzz targets, otherwise the CMake configuration step fails. 10 | set(FMT_FUZZ_LDFLAGS "" CACHE STRING "LDFLAGS for the fuzz targets") 11 | 12 | # Adds a binary for reproducing, i.e. no fuzzing, just enables replaying data 13 | # through the fuzzers. 14 | function(add_fuzzer source) 15 | get_filename_component(basename ${source} NAME_WE) 16 | set(name ${basename}-fuzzer) 17 | add_executable(${name} ${source} fuzzer-common.h) 18 | if (FMT_FUZZ_LINKMAIN) 19 | target_sources(${name} PRIVATE main.cc) 20 | endif () 21 | target_link_libraries(${name} PRIVATE fmt) 22 | if (FMT_FUZZ_LDFLAGS) 23 | target_link_libraries(${name} PRIVATE ${FMT_FUZZ_LDFLAGS}) 24 | endif () 25 | target_compile_features(${name} PRIVATE cxx_generic_lambdas) 26 | endfunction() 27 | 28 | foreach (source chrono-duration.cc float.cc named-arg.cc one-arg.cc two-args.cc) 29 | add_fuzzer(${source}) 30 | endforeach () 31 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/fuzzing/README.md: -------------------------------------------------------------------------------- 1 | # Running the fuzzers locally 2 | 3 | There is a [helper script](build.sh) to build the fuzzers, which has only been 4 | tested on Debian and Ubuntu linux so far. There should be no problems fuzzing on 5 | Windows (using clang>=8) or on Mac, but the script will probably not work out of 6 | the box. 7 | 8 | Something along 9 | ```sh 10 | mkdir build 11 | cd build 12 | export CXX=clang++ 13 | export CXXFLAGS="-fsanitize=fuzzer-no-link -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION= -g" 14 | cmake .. -DFMT_SAFE_DURATION_CAST=On -DFMT_FUZZ=On -DFMT_FUZZ_LINKMAIN=Off -DFMT_FUZZ_LDFLAGS="-fsanitize=fuzzer" 15 | cmake --build . 16 | ``` 17 | should work to build the fuzzers for all platforms which clang supports. 18 | 19 | Execute a fuzzer with for instance 20 | ```sh 21 | cd build 22 | export UBSAN_OPTIONS=halt_on_error=1 23 | mkdir out_chrono 24 | bin/fuzzer_chrono_duration out_chrono 25 | ``` 26 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/fuzzing/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "fuzzer-common.h" 6 | 7 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); 8 | 9 | int main(int argc, char** argv) { 10 | for (int i = 1; i < argc; ++i) { 11 | std::ifstream in(argv[i]); 12 | assert(in); 13 | in.seekg(0, std::ios_base::end); 14 | const auto size = in.tellg(); 15 | assert(size >= 0); 16 | in.seekg(0, std::ios_base::beg); 17 | std::vector buf(static_cast(size)); 18 | in.read(buf.data(), size); 19 | assert(in.gcount() == size); 20 | LLVMFuzzerTestOneInput(as_bytes(buf.data()), buf.size()); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/gtest/.clang-format: -------------------------------------------------------------------------------- 1 | # Disable clang-format here 2 | DisableFormat: true 3 | SortIncludes: Never 4 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/header-only-test.cc: -------------------------------------------------------------------------------- 1 | // Header-only configuration test 2 | 3 | #include "fmt/core.h" 4 | 5 | #ifndef FMT_HEADER_ONLY 6 | # error "Not in the header-only mode." 7 | #endif 8 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/static-export-test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1...3.18) 2 | 3 | project(fmt-link CXX) 4 | 5 | set(BUILD_SHARED_LIBS OFF) 6 | set(CMAKE_VISIBILITY_INLINES_HIDDEN TRUE) 7 | set(CMAKE_CXX_VISIBILITY_PRESET "hidden") 8 | 9 | # Broken LTO on GCC 4 10 | if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5) 11 | set(BROKEN_LTO ON) 12 | endif () 13 | 14 | if (NOT BROKEN_LTO AND CMAKE_VERSION VERSION_GREATER "3.8") 15 | # CMake 3.9+ 16 | include(CheckIPOSupported) 17 | check_ipo_supported(RESULT HAVE_IPO) 18 | if (HAVE_IPO) 19 | set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) 20 | endif () 21 | endif () 22 | 23 | add_subdirectory(../.. fmt) 24 | set_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON) 25 | 26 | add_library(library-test SHARED library.cc) 27 | target_link_libraries(library-test PRIVATE fmt::fmt) 28 | 29 | add_executable(exe-test main.cc) 30 | target_link_libraries(exe-test PRIVATE library-test) 31 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/static-export-test/library.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | __attribute__((visibility("default"))) std::string foo() { 4 | return fmt::format(FMT_COMPILE("foo bar {}"), 4242); 5 | } 6 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/static-export-test/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern std::string foo(); 5 | 6 | int main() { std::cout << foo() << std::endl; } 7 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/test-assert.h: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - test version of FMT_ASSERT 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #ifndef FMT_TEST_ASSERT_H_ 9 | #define FMT_TEST_ASSERT_H_ 10 | 11 | #include 12 | 13 | void throw_assertion_failure(const char* message); 14 | #define FMT_ASSERT(condition, message) \ 15 | if (!(condition)) throw_assertion_failure(message); 16 | 17 | #include "gtest/gtest.h" 18 | 19 | class assertion_failure : public std::logic_error { 20 | public: 21 | explicit assertion_failure(const char* message) : std::logic_error(message) {} 22 | 23 | private: 24 | virtual void avoid_weak_vtable(); 25 | }; 26 | 27 | void assertion_failure::avoid_weak_vtable() {} 28 | 29 | // We use a separate function (rather than throw directly from FMT_ASSERT) to 30 | // avoid GCC's -Wterminate warning when FMT_ASSERT is used in a destructor. 31 | inline void throw_assertion_failure(const char* message) { 32 | throw assertion_failure(message); 33 | } 34 | 35 | // Expects an assertion failure. 36 | #define EXPECT_ASSERT(stmt, message) \ 37 | FMT_TEST_THROW_(stmt, assertion_failure, message, GTEST_NONFATAL_FAILURE_) 38 | 39 | #endif // FMT_TEST_ASSERT_H_ 40 | -------------------------------------------------------------------------------- /examples/libraries/fmt/test/util.cc: -------------------------------------------------------------------------------- 1 | // Formatting library for C++ - test utilities 2 | // 3 | // Copyright (c) 2012 - present, Victor Zverovich 4 | // All rights reserved. 5 | // 6 | // For the license information refer to format.h. 7 | 8 | #include "util.h" 9 | 10 | #include 11 | 12 | const char* const file_content = "Don't panic!"; 13 | 14 | fmt::buffered_file open_buffered_file(FILE** fp) { 15 | #if FMT_USE_FCNTL 16 | fmt::file read_end, write_end; 17 | fmt::file::pipe(read_end, write_end); 18 | write_end.write(file_content, std::strlen(file_content)); 19 | write_end.close(); 20 | fmt::buffered_file f = read_end.fdopen("r"); 21 | if (fp) *fp = f.get(); 22 | #else 23 | fmt::buffered_file f("test-file", "w"); 24 | fputs(file_content, f.get()); 25 | if (fp) *fp = f.get(); 26 | #endif 27 | return f; 28 | } 29 | 30 | std::locale do_get_locale(const char* name) { 31 | try { 32 | return std::locale(name); 33 | } catch (const std::runtime_error&) { 34 | } 35 | return std::locale::classic(); 36 | } 37 | 38 | std::locale get_locale(const char* name, const char* alt_name) { 39 | auto loc = do_get_locale(name); 40 | if (loc == std::locale::classic() && alt_name) { 41 | loc = do_get_locale(alt_name); 42 | } 43 | if (loc == std::locale::classic()) 44 | fmt::print(stderr, "{} locale is missing.\n", name); 45 | return loc; 46 | } 47 | -------------------------------------------------------------------------------- /examples/libraries/generator/CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x64-Debug", 5 | "generator": "Ninja", 6 | "configurationType": "Debug", 7 | "inheritEnvironments": [ "msvc_x64_x64" ], 8 | "buildRoot": "${projectDir}\\out\\build\\${name}", 9 | "installRoot": "${projectDir}\\out\\install\\${name}", 10 | "cmakeCommandArgs": "", 11 | "buildCommandArgs": "", 12 | "ctestCommandArgs": "" 13 | }, 14 | { 15 | "name": "WSL-GCC-Debug", 16 | "generator": "Ninja", 17 | "configurationType": "Debug", 18 | "buildRoot": "${projectDir}\\out\\build\\${name}", 19 | "installRoot": "${projectDir}\\out\\install\\${name}", 20 | "cmakeExecutable": "cmake", 21 | "cmakeCommandArgs": "-DCMAKE_CXX_COMPILER=g++-10", 22 | "buildCommandArgs": "", 23 | "ctestCommandArgs": "", 24 | "inheritEnvironments": [ "linux_x64" ], 25 | "wslPath": "${defaultWSLPath}", 26 | "addressSanitizerRuntimeFlags": "detect_leaks=0" 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /examples/libraries/generator/cmake/tl-generator-config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/tl-generator-targets.cmake") -------------------------------------------------------------------------------- /examples/libraries/generator/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator", 3 | "version-semver": "0.3.0", 4 | "maintainers": [ "Sy Brand (tartanllama@gmail.com)" ], 5 | "description": "C++20 generator implementation on coroutines" 6 | } 7 | -------------------------------------------------------------------------------- /examples/libraries/miniz-cpp/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *~ 3 | build/ 4 | -------------------------------------------------------------------------------- /examples/libraries/miniz-cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | project(miniz-cpp) 3 | 4 | set(CMAKE_CXX_STANDARD 14) 5 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 6 | 7 | set(TEST_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/tests/test.cpp) 8 | 9 | add_executable(miniz-cpp.test ${TEST_SOURCE}) 10 | target_include_directories(miniz-cpp.test 11 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) 12 | 13 | set(EXAMPLE_SOURCES 14 | ${CMAKE_CURRENT_SOURCE_DIR}/examples/pipe.cpp 15 | ${CMAKE_CURRENT_SOURCE_DIR}/examples/read.cpp 16 | ${CMAKE_CURRENT_SOURCE_DIR}/examples/write.cpp) 17 | 18 | foreach(EXAMPLE_SOURCE IN ITEMS ${EXAMPLE_SOURCES}) 19 | get_filename_component(EXAMPLE_NAME ${EXAMPLE_SOURCE} NAME_WE) 20 | set(EXAMPLE_EXECUTABLE example-${EXAMPLE_NAME}) 21 | 22 | add_executable(${EXAMPLE_EXECUTABLE} ${EXAMPLE_SOURCE}) 23 | 24 | target_include_directories(${EXAMPLE_EXECUTABLE} 25 | PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) 26 | endforeach() 27 | -------------------------------------------------------------------------------- /examples/libraries/miniz-cpp/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2017 Thomas Fussell 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 13 | all 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 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /examples/libraries/miniz-cpp/README.md: -------------------------------------------------------------------------------- 1 | miniz-cpp 2 | ========= 3 | 4 | A cross-platform header-only library for reading and writing ZIP files using a nice simple API similar to [Python's zipfile](https://docs.python.org/3/library/zipfile.html). See [examples/](https://github.com/tfussell/miniz-cpp/tree/master/examples) for a demonstration of the use of the library. -------------------------------------------------------------------------------- /examples/libraries/miniz-cpp/examples/read.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | if(argc <= 1) 7 | { 8 | std::cout << "usage: " << argv[0] << " filename" << std::endl; 9 | return 0; 10 | } 11 | 12 | miniz_cpp::zip_file file(argv[1]); 13 | file.printdir(); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /examples/libraries/miniz-cpp/examples/write.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | if(argc <= 1) 7 | { 8 | std::cout << "usage: " << argv[0] << " filename" << std::endl; 9 | return 0; 10 | } 11 | 12 | miniz_cpp::zip_file file; 13 | 14 | file.writestr("file1.txt", "this is file 1"); 15 | file.writestr("file2.txt", "this is file 2"); 16 | file.writestr("file3.txt", "this is file 3"); 17 | file.writestr("file4.txt", "this is file 4"); 18 | file.writestr("file5.txt", "this is file 5"); 19 | 20 | file.save(argv[1]); 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/.github/workflows/linux.yml: -------------------------------------------------------------------------------- 1 | name: Linux 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | linux-build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout 10 | uses: actions/checkout@v1 11 | - name: Build Linux 12 | run: ./make.sh all 13 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/.github/workflows/macos.yml: -------------------------------------------------------------------------------- 1 | name: macOS 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | mac-build: 7 | runs-on: macos-latest 8 | steps: 9 | - name: Checkout 10 | uses: actions/checkout@v1 11 | - name: Build macOS 12 | run: ./make.sh all 13 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/.github/workflows/windows.yml: -------------------------------------------------------------------------------- 1 | name: Windows 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | windows-build: 7 | runs-on: windows-latest 8 | steps: 9 | - name: Checkout 10 | uses: actions/checkout@v1 11 | - name: Add msbuild to PATH 12 | uses: microsoft/setup-msbuild@v1.0.2 13 | - name: Build Windows 14 | shell: cmd 15 | run: .\winmake.bat all 16 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/doc/README.md: -------------------------------------------------------------------------------- 1 | # API Documentation 2 | - [class rapidcsv::Document](rapidcsv_Document.md) 3 | - [class rapidcsv::LabelParams](rapidcsv_LabelParams.md) 4 | - [class rapidcsv::SeparatorParams](rapidcsv_SeparatorParams.md) 5 | - [class rapidcsv::ConverterParams](rapidcsv_ConverterParams.md) 6 | - [class rapidcsv::LineReaderParams](rapidcsv_LineReaderParams.md) 7 | - [class rapidcsv::no_converter](rapidcsv_no_converter.md) 8 | - [class rapidcsv::Converter< T >](rapidcsv_Converter.md) 9 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/doc/rapidcsv_ConverterParams.md: -------------------------------------------------------------------------------- 1 | ## class rapidcsv::ConverterParams 2 | 3 | Datastructure holding parameters controlling how invalid numbers (including empty strings) should be handled. 4 | 5 | --- 6 | 7 | ```c++ 8 | ConverterParams (const bool pHasDefaultConverter = false, const long double pDefaultFloat = std::numeric_limits::signaling_NaN(), const long long pDefaultInteger = 0) 9 | ``` 10 | Constructor. 11 | 12 | **Parameters** 13 | - `pHasDefaultConverter` specifies if conversion of non-numerical strings shall be converted to a default numerical value, instead of causing an exception to be thrown (default). 14 | - `pDefaultFloat` floating-point default value to represent invalid numbers. 15 | - `pDefaultInteger` integer default value to represent invalid numbers. 16 | 17 | --- 18 | 19 | ###### API documentation generated using [Doxygenmd](https://github.com/d99kris/doxygenmd) 20 | 21 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/doc/rapidcsv_LabelParams.md: -------------------------------------------------------------------------------- 1 | ## class rapidcsv::LabelParams 2 | 3 | Datastructure holding parameters controlling which row and column should be treated as labels. 4 | 5 | --- 6 | 7 | ```c++ 8 | LabelParams (const int pColumnNameIdx = 0, const int pRowNameIdx = \-1) 9 | ``` 10 | Constructor. 11 | 12 | **Parameters** 13 | - `pColumnNameIdx` specifies the zero-based row index of the column labels, setting it to -1 prevents column lookup by label name, and gives access to all rows as document data. Default: 0 14 | - `pRowNameIdx` specifies the zero-based column index of the row labels, setting it to -1 prevents row lookup by label name, and gives access to all columns as document data. Default: -1 15 | 16 | --- 17 | 18 | ###### API documentation generated using [Doxygenmd](https://github.com/d99kris/doxygenmd) 19 | 20 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/doc/rapidcsv_LineReaderParams.md: -------------------------------------------------------------------------------- 1 | ## class rapidcsv::LineReaderParams 2 | 3 | Datastructure holding parameters controlling how special line formats should be treated. 4 | 5 | --- 6 | 7 | ```c++ 8 | LineReaderParams (const bool pSkipCommentLines = false, const char pCommentPrefix = '#', const bool pSkipEmptyLines = false) 9 | ``` 10 | Constructor. 11 | 12 | **Parameters** 13 | - `pSkipCommentLines` specifies whether to skip lines prefixed with mCommentPrefix. Default: false 14 | - `pCommentPrefix` specifies which prefix character to indicate a comment line. Default: # 15 | - `pSkipEmptyLines` specifies whether to skip empty lines. Default: false 16 | 17 | --- 18 | 19 | ###### API documentation generated using [Doxygenmd](https://github.com/d99kris/doxygenmd) 20 | 21 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/doc/rapidcsv_SeparatorParams.md: -------------------------------------------------------------------------------- 1 | ## class rapidcsv::SeparatorParams 2 | 3 | Datastructure holding parameters controlling how the CSV data fields are separated. 4 | 5 | --- 6 | 7 | ```c++ 8 | SeparatorParams (const char pSeparator = ',', const bool pTrim = false, const bool pHasCR = sPlatformHasCR, const bool pQuotedLinebreaks = false, const bool pAutoQuote = true) 9 | ``` 10 | Constructor. 11 | 12 | **Parameters** 13 | - `pSeparator` specifies the column separator (default ','). 14 | - `pTrim` specifies whether to trim leading and trailing spaces from cells read (default false). 15 | - `pHasCR` specifies whether a new document (i.e. not an existing document read) should use CR/LF instead of only LF (default is to use standard behavior of underlying platforms - CR/LF for Win, and LF for others). 16 | - `pQuotedLinebreaks` specifies whether to allow line breaks in quoted text (default false) 17 | - `pAutoQuote` specifies whether to automatically dequote data during read, and add quotes during write (default true). 18 | 19 | --- 20 | 21 | ###### API documentation generated using [Doxygenmd](https://github.com/d99kris/doxygenmd) 22 | 23 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/doc/rapidcsv_no_converter.md: -------------------------------------------------------------------------------- 1 | ## class rapidcsv::no_converter 2 | 3 | Exception thrown when attempting to access Document data in a datatype which is not supported by the Converter class. 4 | 5 | --- 6 | 7 | ###### API documentation generated using [Doxygenmd](https://github.com/d99kris/doxygenmd) 8 | 9 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/cmake-add-subdirectory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.11 FATAL_ERROR) 2 | project(cmake-addsubdirectory) 3 | set(CMAKE_CXX_STANDARD 11) 4 | 5 | add_subdirectory(rapidcsv) 6 | 7 | add_executable(exprog2 src/exprog2.cpp) 8 | target_link_libraries(exprog2 PUBLIC rapidcsv) 9 | install(TARGETS exprog2 DESTINATION bin) 10 | 11 | add_custom_target(uninstall 12 | COMMAND "${CMAKE_COMMAND}" -E remove "${CMAKE_INSTALL_PREFIX}/bin/exprog2" 13 | ) 14 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/cmake-add-subdirectory/README.md: -------------------------------------------------------------------------------- 1 | CMake Add Subdirectory Example Project 2 | ====================================== 3 | 4 | Build Steps 5 | ----------- 6 | Commands to build the example project: 7 | 8 | ln -s ../.. rapidcsv 9 | mkdir -p build && cd build && cmake .. && make 10 | 11 | 12 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/cmake-add-subdirectory/src/exprog2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | rapidcsv::Document doc("../../colhdr.csv"); 8 | 9 | std::vector col = doc.GetColumn("Close"); 10 | std::cout << "Read " << col.size() << " values." << std::endl; 11 | } 12 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/cmake-fetchcontent/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.11 FATAL_ERROR) 2 | project(cmake-fetchcontent) 3 | set(CMAKE_CXX_STANDARD 11) 4 | 5 | include(FetchContent) 6 | FetchContent_Declare( 7 | rapidcsv 8 | GIT_REPOSITORY "https://github.com/d99kris/rapidcsv.git" 9 | GIT_TAG "v8.50" 10 | ) 11 | FetchContent_MakeAvailable(rapidcsv) 12 | 13 | add_executable(exprog src/exprog.cpp) 14 | target_link_libraries(exprog PUBLIC rapidcsv) 15 | install(TARGETS exprog DESTINATION bin) 16 | 17 | add_custom_target(uninstall 18 | COMMAND "${CMAKE_COMMAND}" -E remove "${CMAKE_INSTALL_PREFIX}/bin/exprog" 19 | ) 20 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/cmake-fetchcontent/README.md: -------------------------------------------------------------------------------- 1 | CMake FetchContent Example Project 2 | ================================== 3 | 4 | Build Steps 5 | ----------- 6 | Commands to build the example project: 7 | 8 | mkdir -p build && cd build && cmake .. && make 9 | 10 | 11 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/cmake-fetchcontent/src/exprog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | rapidcsv::Document doc("../../colhdr.csv"); 8 | 9 | std::vector col = doc.GetColumn("Close"); 10 | std::cout << "Read " << col.size() << " values." << std::endl; 11 | } 12 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/colhdr.csv: -------------------------------------------------------------------------------- 1 | Open,High,Low,Close,Volume,Adj Close 2 | 64.529999,64.800003,64.139999,64.620003,21705200,64.620003 3 | 64.419998,64.730003,64.190002,64.620003,20235200,64.620003 4 | 64.330002,64.389999,64.050003,64.360001,19259700,64.360001 5 | 64.610001,64.949997,64.449997,64.489998,19384900,64.489998 6 | 64.470001,64.690002,64.300003,64.620003,21234600,64.620003 7 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/colrowhdr.csv: -------------------------------------------------------------------------------- 1 | Date,Open,High,Low,Close,Volume,Adj Close 2 | 2017-02-24,64.529999,64.800003,64.139999,64.620003,21705200,64.620003 3 | 2017-02-23,64.419998,64.730003,64.190002,64.620003,20235200,64.620003 4 | 2017-02-22,64.330002,64.389999,64.050003,64.360001,19259700,64.360001 5 | 2017-02-21,64.610001,64.949997,64.449997,64.489998,19384900,64.489998 6 | 2017-02-17,64.470001,64.690002,64.300003,64.620003,21234600,64.620003 7 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/ex001.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | TMP=$(mktemp -d) 3 | c++ -std=c++11 -I src -o ${TMP}/a.out ${0} && ${TMP}/a.out ${@:1} ; RV=${?} 4 | rm -rf ${TMP} 5 | exit ${RV} 6 | #endif 7 | 8 | #include 9 | #include 10 | #include "rapidcsv.h" 11 | 12 | int main() 13 | { 14 | rapidcsv::Document doc("examples/colhdr.csv"); 15 | 16 | std::vector col = doc.GetColumn("Close"); 17 | std::cout << "Read " << col.size() << " values." << std::endl; 18 | } 19 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/ex002.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | TMP=$(mktemp -d) 3 | c++ -std=c++11 -I src -o ${TMP}/a.out ${0} && ${TMP}/a.out ${@:1} ; RV=${?} 4 | rm -rf ${TMP} 5 | exit ${RV} 6 | #endif 7 | 8 | #include 9 | #include 10 | #include "rapidcsv.h" 11 | 12 | int main() 13 | { 14 | rapidcsv::Document doc("examples/colrowhdr.csv", rapidcsv::LabelParams(0, 0)); 15 | 16 | std::vector close = doc.GetRow("2017-02-22"); 17 | std::cout << "Read " << close.size() << " values." << std::endl; 18 | 19 | long long volume = doc.GetCell("Volume", "2017-02-22"); 20 | std::cout << "Volume " << volume << " on 2017-02-22." << std::endl; 21 | } 22 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/ex003.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | TMP=$(mktemp -d) 3 | c++ -std=c++11 -I src -o ${TMP}/a.out ${0} && ${TMP}/a.out ${@:1} ; RV=${?} 4 | rm -rf ${TMP} 5 | exit ${RV} 6 | #endif 7 | 8 | #include 9 | #include 10 | #include "rapidcsv.h" 11 | 12 | int main() 13 | { 14 | rapidcsv::Document doc("examples/rowhdr.csv", rapidcsv::LabelParams(-1, 0)); 15 | 16 | std::vector row = doc.GetRow("2017-02-22"); 17 | std::cout << "Read " << row.size() << " values." << std::endl; 18 | } 19 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/ex004.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | TMP=$(mktemp -d) 3 | c++ -std=c++11 -I src -o ${TMP}/a.out ${0} && ${TMP}/a.out ${@:1} ; RV=${?} 4 | rm -rf ${TMP} 5 | exit ${RV} 6 | #endif 7 | 8 | #include 9 | #include 10 | #include "rapidcsv.h" 11 | 12 | int main() 13 | { 14 | rapidcsv::Document doc("examples/nohdr.csv", rapidcsv::LabelParams(-1, -1)); 15 | 16 | std::vector close = doc.GetColumn(5); 17 | std::cout << "Read " << close.size() << " values." << std::endl; 18 | 19 | long long volume = doc.GetCell(4, 2); 20 | std::cout << "Volume " << volume << " on 2017-02-22." << std::endl; 21 | } 22 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/ex005.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | TMP=$(mktemp -d) 3 | c++ -std=c++11 -I src -o ${TMP}/a.out ${0} && ${TMP}/a.out ${@:1} ; RV=${?} 4 | rm -rf ${TMP} 5 | exit ${RV} 6 | #endif 7 | 8 | #include 9 | #include 10 | #include "rapidcsv.h" 11 | 12 | int main() 13 | { 14 | rapidcsv::Document doc("examples/semi.csv", rapidcsv::LabelParams(0, 0), 15 | rapidcsv::SeparatorParams(';')); 16 | 17 | std::vector close = doc.GetColumn("Close"); 18 | std::cout << "Read " << close.size() << " values." << std::endl; 19 | 20 | long long volume = doc.GetCell("Volume", "2017-02-22"); 21 | std::cout << "Volume " << volume << " on 2017-02-22." << std::endl; 22 | } 23 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/ex006.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | TMP=$(mktemp -d) 3 | c++ -std=c++11 -I src -o ${TMP}/a.out ${0} && ${TMP}/a.out ${@:1} ; RV=${?} 4 | rm -rf ${TMP} 5 | exit ${RV} 6 | #endif 7 | 8 | #include 9 | #include 10 | #include "rapidcsv.h" 11 | 12 | int main() 13 | { 14 | rapidcsv::Document doc("examples/colrowhdr.csv", rapidcsv::LabelParams(0, 0)); 15 | 16 | std::cout << doc.GetCell("Volume", "2017-02-22") << std::endl; 17 | std::cout << doc.GetCell("Volume", "2017-02-22") << std::endl; 18 | std::cout << doc.GetCell("Volume", "2017-02-22") << std::endl; 19 | std::cout << doc.GetCell("Volume", "2017-02-22") << std::endl; 20 | std::cout << doc.GetCell("Volume", "2017-02-22") << std::endl; 21 | std::cout << doc.GetCell("Volume", "2017-02-22") << std::endl; 22 | std::cout << doc.GetCell("Volume", "2017-02-22") << std::endl; 23 | std::cout << doc.GetCell("Volume", "2017-02-22") << std::endl; 24 | std::cout << doc.GetCell("Volume", "2017-02-22") << std::endl; 25 | std::cout << doc.GetCell("Volume", "2017-02-22") << std::endl; 26 | std::cout << doc.GetCell("Volume", "2017-02-22") << std::endl; 27 | } 28 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/ex007.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | TMP=$(mktemp -d) 3 | c++ -std=c++11 -I src -o ${TMP}/a.out ${0} && ${TMP}/a.out ${@:1} ; RV=${?} 4 | rm -rf ${TMP} 5 | exit ${RV} 6 | #endif 7 | 8 | #include 9 | #include 10 | #include "rapidcsv.h" 11 | 12 | int main() 13 | { 14 | const std::string& csv = 15 | "Date,Open,High,Low,Close,Volume,Adj Close\n" 16 | "2017-02-24,64.529999,64.800003,64.139999,64.620003,21705200,64.620003\n" 17 | "2017-02-23,64.419998,64.730003,64.190002,64.620003,20235200,64.620003\n" 18 | "2017-02-22,64.330002,64.389999,64.050003,64.360001,19259700,64.360001\n" 19 | "2017-02-21,64.610001,64.949997,64.449997,64.489998,19384900,64.489998\n" 20 | "2017-02-17,64.470001,64.690002,64.300003,64.620003,21234600,64.620003\n" 21 | ; 22 | 23 | std::stringstream sstream(csv); 24 | rapidcsv::Document doc(sstream, rapidcsv::LabelParams(0, 0)); 25 | 26 | std::vector close = doc.GetColumn("Close"); 27 | std::cout << "Read " << close.size() << " values." << std::endl; 28 | 29 | long long volume = doc.GetCell("Volume", "2017-02-22"); 30 | std::cout << "Volume " << volume << " on 2017-02-22." << std::endl; 31 | } 32 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/ex008.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | TMP=$(mktemp -d) 3 | c++ -std=c++11 -I src -o ${TMP}/a.out ${0} && ${TMP}/a.out ${@:1} ; RV=${?} 4 | rm -rf ${TMP} 5 | exit ${RV} 6 | #endif 7 | 8 | #include 9 | #include 10 | #include "rapidcsv.h" 11 | 12 | namespace rapidcsv 13 | { 14 | template<> 15 | void Converter::ToVal(const std::string& pStr, int& pVal) const 16 | { 17 | pVal = static_cast(roundf(100.0f * std::stof(pStr))); 18 | } 19 | } 20 | 21 | int main() 22 | { 23 | rapidcsv::Document doc("examples/colrowhdr.csv", rapidcsv::LabelParams(0, 0)); 24 | 25 | std::vector close = doc.GetColumn("Close"); 26 | std::cout << "close[0] = " << close[0] << std::endl; 27 | std::cout << "close[1] = " << close[1] << std::endl; 28 | } 29 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/ex009.cpp: -------------------------------------------------------------------------------- 1 | #if 0 2 | TMP=$(mktemp -d) 3 | c++ -std=c++11 -I src -o ${TMP}/a.out ${0} && ${TMP}/a.out ${@:1} ; RV=${?} 4 | rm -rf ${TMP} 5 | exit ${RV} 6 | #endif 7 | 8 | #include 9 | #include 10 | #include "rapidcsv.h" 11 | 12 | void ConvFixPoint(const std::string& pStr, int& pVal) 13 | { 14 | pVal = static_cast(roundf(100.0f * std::stof(pStr))); 15 | } 16 | 17 | struct MyStruct 18 | { 19 | int val = 0; 20 | }; 21 | 22 | void ConvMyStruct(const std::string& pStr, MyStruct& pVal) 23 | { 24 | pVal.val = static_cast(roundf(100.0f * std::stof(pStr))); 25 | } 26 | 27 | int main() 28 | { 29 | rapidcsv::Document doc("examples/colrowhdr.csv", rapidcsv::LabelParams(0, 0)); 30 | 31 | std::cout << "regular = " << doc.GetCell("Close", "2017-02-21") << "\n"; 32 | std::cout << "fixpointfunc = " << doc.GetCell("Close", "2017-02-21", ConvFixPoint) << "\n"; 33 | 34 | auto convFixLambda = [](const std::string& pStr, int& pVal) { pVal = static_cast(roundf(100.0f * stof(pStr))); }; 35 | std::cout << "fixpointlambda = " << doc.GetCell("Close", "2017-02-21", convFixLambda) << "\n"; 36 | 37 | std::cout << "mystruct = " << doc.GetCell("Close", "2017-02-21", ConvMyStruct).val << "\n"; 38 | } 39 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/nohdr.csv: -------------------------------------------------------------------------------- 1 | 64.529999,64.800003,64.139999,64.620003,21705200,64.620003 2 | 64.419998,64.730003,64.190002,64.620003,20235200,64.620003 3 | 64.330002,64.389999,64.050003,64.360001,19259700,64.360001 4 | 64.610001,64.949997,64.449997,64.489998,19384900,64.489998 5 | 64.470001,64.690002,64.300003,64.620003,21234600,64.620003 6 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/rowhdr.csv: -------------------------------------------------------------------------------- 1 | 2017-02-24,64.529999,64.800003,64.139999,64.620003,21705200,64.620003 2 | 2017-02-23,64.419998,64.730003,64.190002,64.620003,20235200,64.620003 3 | 2017-02-22,64.330002,64.389999,64.050003,64.360001,19259700,64.360001 4 | 2017-02-21,64.610001,64.949997,64.449997,64.489998,19384900,64.489998 5 | 2017-02-17,64.470001,64.690002,64.300003,64.620003,21234600,64.620003 6 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/examples/semi.csv: -------------------------------------------------------------------------------- 1 | Date;Open;High;Low;Close;Volume;Adj Close 2 | 2017-02-24;64.529999;64.800003;64.139999;64.620003;21705200;64.620003 3 | 2017-02-23;64.419998;64.730003;64.190002;64.620003;20235200;64.620003 4 | 2017-02-22;64.330002;64.389999;64.050003;64.360001;19259700;64.360001 5 | 2017-02-21;64.610001;64.949997;64.449997;64.489998;19384900;64.489998 6 | 2017-02-17;64.470001;64.690002;64.300003;64.620003;21234600;64.620003 7 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/chi-utf16.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdeitel/CPlusPlus20ForProgrammers/7c78398f15b3e25c6cb16ca1afe6746a791a8a26/examples/libraries/rapidcsv/tests/chi-utf16.csv -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/ptest001.cpp: -------------------------------------------------------------------------------- 1 | // ptest001.cpp - file load and get data by column, row and cell 2 | 3 | #include 4 | #include "perftest.h" 5 | #include "unittest.h" 6 | 7 | int main() 8 | { 9 | int rv = 0; 10 | 11 | try 12 | { 13 | perftest::Timer timer; 14 | 15 | for (int i = 0; i < 10; ++i) 16 | { 17 | timer.Start(); 18 | 19 | rapidcsv::Document doc("../tests/msft.csv", rapidcsv::LabelParams(0, 0)); 20 | const std::vector& column = doc.GetColumn("Close"); 21 | const std::vector& row = doc.GetRow("2016-05-23"); 22 | const double cell = doc.GetCell("Close", "2016-05-23"); 23 | 24 | timer.Stop(); 25 | 26 | // dummy usage of variables 27 | (void) column; 28 | (void) row; 29 | (void) cell; 30 | } 31 | 32 | timer.ReportMedian(); 33 | } 34 | catch (const std::exception& ex) 35 | { 36 | std::cout << ex.what() << std::endl; 37 | rv = 1; 38 | } 39 | 40 | return rv; 41 | } 42 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/ptest002.cpp: -------------------------------------------------------------------------------- 1 | // ptest002.cpp - file load 2 | 3 | #include 4 | #include "perftest.h" 5 | #include "unittest.h" 6 | 7 | int main() 8 | { 9 | int rv = 0; 10 | 11 | try 12 | { 13 | perftest::Timer timer; 14 | 15 | for (int i = 0; i < 10; ++i) 16 | { 17 | timer.Start(); 18 | 19 | rapidcsv::Document doc("../tests/msft.csv"); 20 | 21 | timer.Stop(); 22 | } 23 | 24 | timer.ReportMedian(); 25 | } 26 | catch (const std::exception& ex) 27 | { 28 | std::cout << ex.what() << std::endl; 29 | rv = 1; 30 | } 31 | 32 | return rv; 33 | } 34 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test001.cpp: -------------------------------------------------------------------------------- 1 | // test001.cpp - read cell value 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 22 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 3); 23 | unittest::ExpectEqual(int, doc.GetCell(1, 0), 9); 24 | unittest::ExpectEqual(int, doc.GetCell(2, 0), 81); 25 | 26 | unittest::ExpectEqual(std::string, doc.GetCell("A", "2"), "4"); 27 | unittest::ExpectEqual(std::string, doc.GetCell("B", "2"), "16"); 28 | unittest::ExpectEqual(std::string, doc.GetCell("C", "2"), "256"); 29 | } 30 | catch (const std::exception& ex) 31 | { 32 | std::cout << ex.what() << std::endl; 33 | rv = 1; 34 | } 35 | 36 | unittest::DeleteFile(path); 37 | 38 | return rv; 39 | } 40 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test003.cpp: -------------------------------------------------------------------------------- 1 | // test003.cpp - read column values 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 22 | 23 | std::vector ints; 24 | std::vector strs; 25 | 26 | ints = doc.GetColumn(0); 27 | unittest::ExpectEqual(size_t, ints.size(), 2); 28 | unittest::ExpectEqual(int, ints.at(0), 3); 29 | unittest::ExpectEqual(int, ints.at(1), 4); 30 | 31 | ints = doc.GetColumn("B"); 32 | unittest::ExpectEqual(size_t, ints.size(), 2); 33 | unittest::ExpectEqual(int, ints.at(0), 9); 34 | unittest::ExpectEqual(int, ints.at(1), 16); 35 | 36 | strs = doc.GetColumn(2); 37 | unittest::ExpectEqual(size_t, strs.size(), 2); 38 | unittest::ExpectEqual(std::string, strs.at(0), "81"); 39 | unittest::ExpectEqual(std::string, strs.at(1), "256"); 40 | } 41 | catch (const std::exception& ex) 42 | { 43 | std::cout << ex.what() << std::endl; 44 | rv = 1; 45 | } 46 | 47 | unittest::DeleteFile(path); 48 | 49 | return rv; 50 | } 51 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test005.cpp: -------------------------------------------------------------------------------- 1 | // test005.cpp - read row values 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 22 | 23 | std::vector ints; 24 | std::vector strs; 25 | 26 | ints = doc.GetRow(0); 27 | unittest::ExpectEqual(size_t, ints.size(), 3); 28 | unittest::ExpectEqual(int, ints.at(0), 3); 29 | unittest::ExpectEqual(int, ints.at(1), 9); 30 | unittest::ExpectEqual(int, ints.at(2), 81); 31 | 32 | strs = doc.GetRow("2"); 33 | unittest::ExpectEqual(size_t, strs.size(), 3); 34 | unittest::ExpectEqual(std::string, strs.at(0), "4"); 35 | unittest::ExpectEqual(std::string, strs.at(1), "16"); 36 | unittest::ExpectEqual(std::string, strs.at(2), "256"); 37 | } 38 | catch (const std::exception& ex) 39 | { 40 | std::cout << ex.what() << std::endl; 41 | rv = 1; 42 | } 43 | 44 | unittest::DeleteFile(path); 45 | 46 | return rv; 47 | } 48 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test007.cpp: -------------------------------------------------------------------------------- 1 | // test007.cpp - delete columns 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | "-,B,D\n" 12 | "0,4,256\n" 13 | "1,9,6561\n" 14 | "2,16,65536\n" 15 | "3,25,390625\n" 16 | ; 17 | 18 | std::string csv = 19 | "-,A,B,C,D\n" 20 | "0,2,4,16,256\n" 21 | "1,3,9,81,6561\n" 22 | "2,4,16,256,65536\n" 23 | "3,5,25,625,390625\n" 24 | ; 25 | 26 | std::string path = unittest::TempPath(); 27 | unittest::WriteFile(path, csv); 28 | 29 | try 30 | { 31 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 32 | 33 | doc.RemoveColumn("C"); 34 | doc.RemoveColumn(0); 35 | 36 | doc.Save(); 37 | 38 | std::string csvread = unittest::ReadFile(path); 39 | 40 | unittest::ExpectEqual(std::string, csvref, csvread); 41 | } 42 | catch (const std::exception& ex) 43 | { 44 | std::cout << ex.what() << std::endl; 45 | rv = 1; 46 | } 47 | 48 | unittest::DeleteFile(path); 49 | 50 | return rv; 51 | } 52 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test008.cpp: -------------------------------------------------------------------------------- 1 | // test008.cpp - delete rows 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | "-,A,B,C,D\n" 12 | "1,3,9,81,6561\n" 13 | "2,4,16,256,65536\n" 14 | ; 15 | 16 | std::string csv = 17 | "-,A,B,C,D\n" 18 | "0,2,4,16,256\n" 19 | "1,3,9,81,6561\n" 20 | "2,4,16,256,65536\n" 21 | "3,5,25,625,390625\n" 22 | ; 23 | 24 | std::string path = unittest::TempPath(); 25 | unittest::WriteFile(path, csv); 26 | 27 | try 28 | { 29 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 30 | 31 | doc.RemoveRow("3"); 32 | doc.RemoveRow(0); 33 | 34 | doc.Save(); 35 | 36 | std::string csvread = unittest::ReadFile(path); 37 | 38 | unittest::ExpectEqual(std::string, csvref, csvread); 39 | } 40 | catch (const std::exception& ex) 41 | { 42 | std::cout << ex.what() << std::endl; 43 | rv = 1; 44 | } 45 | 46 | unittest::DeleteFile(path); 47 | 48 | return rv; 49 | } 50 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test011.cpp: -------------------------------------------------------------------------------- 1 | // test011.cpp - generate new document by cell 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | ",A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | 18 | try 19 | { 20 | rapidcsv::Document doc("", rapidcsv::LabelParams(0, 0), rapidcsv::SeparatorParams(',', false, false)); 21 | 22 | doc.SetCell(0, 0, 3); 23 | doc.SetCell(1, 0, 9); 24 | doc.SetCell(2, 0, 81); 25 | 26 | doc.SetCell(0, 1, 4); 27 | doc.SetCell(1, 1, 16); 28 | doc.SetCell(2, 1, 256); 29 | 30 | doc.SetColumnName(0, "A"); 31 | doc.SetColumnName(1, "B"); 32 | doc.SetColumnName(2, "C"); 33 | 34 | doc.SetRowName(0, "1"); 35 | doc.SetRowName(1, "2"); 36 | 37 | doc.Save(path); 38 | 39 | std::string csvread = unittest::ReadFile(path); 40 | 41 | unittest::ExpectEqual(std::string, csvref, csvread); 42 | } 43 | catch (const std::exception& ex) 44 | { 45 | std::cout << ex.what() << std::endl; 46 | rv = 1; 47 | } 48 | 49 | unittest::DeleteFile(path); 50 | 51 | return rv; 52 | } 53 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test012.cpp: -------------------------------------------------------------------------------- 1 | // test012.cpp - read cell value, no row labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "A,B,C\n" 12 | "3,9,81\n" 13 | "4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path); 22 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 3); 23 | unittest::ExpectEqual(int, doc.GetCell(1, 0), 9); 24 | unittest::ExpectEqual(int, doc.GetCell(2, 0), 81); 25 | 26 | unittest::ExpectEqual(std::string, doc.GetCell(0, 1), "4"); 27 | unittest::ExpectEqual(std::string, doc.GetCell(1, 1), "16"); 28 | unittest::ExpectEqual(std::string, doc.GetCell(2, 1), "256"); 29 | } 30 | catch (const std::exception& ex) 31 | { 32 | std::cout << ex.what() << std::endl; 33 | rv = 1; 34 | } 35 | 36 | unittest::DeleteFile(path); 37 | 38 | return rv; 39 | } 40 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test014.cpp: -------------------------------------------------------------------------------- 1 | // test014.cpp - read column values, no row labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "A,B,C\n" 12 | "3,9,81\n" 13 | "4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path); 22 | 23 | std::vector ints; 24 | std::vector strs; 25 | 26 | ints = doc.GetColumn(0); 27 | unittest::ExpectEqual(size_t, ints.size(), 2); 28 | unittest::ExpectEqual(int, ints.at(0), 3); 29 | unittest::ExpectEqual(int, ints.at(1), 4); 30 | 31 | ints = doc.GetColumn("B"); 32 | unittest::ExpectEqual(size_t, ints.size(), 2); 33 | unittest::ExpectEqual(int, ints.at(0), 9); 34 | unittest::ExpectEqual(int, ints.at(1), 16); 35 | 36 | strs = doc.GetColumn(2); 37 | unittest::ExpectEqual(size_t, strs.size(), 2); 38 | unittest::ExpectEqual(std::string, strs.at(0), "81"); 39 | unittest::ExpectEqual(std::string, strs.at(1), "256"); 40 | } 41 | catch (const std::exception& ex) 42 | { 43 | std::cout << ex.what() << std::endl; 44 | rv = 1; 45 | } 46 | 47 | unittest::DeleteFile(path); 48 | 49 | return rv; 50 | } 51 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test016.cpp: -------------------------------------------------------------------------------- 1 | // test016.cpp - read row values, no row labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "A,B,C\n" 12 | "3,9,81\n" 13 | "4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path); 22 | 23 | std::vector ints; 24 | std::vector strs; 25 | 26 | ints = doc.GetRow(0); 27 | unittest::ExpectEqual(size_t, ints.size(), 3); 28 | unittest::ExpectEqual(int, ints.at(0), 3); 29 | unittest::ExpectEqual(int, ints.at(1), 9); 30 | unittest::ExpectEqual(int, ints.at(2), 81); 31 | 32 | strs = doc.GetRow(1); 33 | unittest::ExpectEqual(size_t, strs.size(), 3); 34 | unittest::ExpectEqual(std::string, strs.at(0), "4"); 35 | unittest::ExpectEqual(std::string, strs.at(1), "16"); 36 | unittest::ExpectEqual(std::string, strs.at(2), "256"); 37 | } 38 | catch (const std::exception& ex) 39 | { 40 | std::cout << ex.what() << std::endl; 41 | rv = 1; 42 | } 43 | 44 | unittest::DeleteFile(path); 45 | 46 | return rv; 47 | } 48 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test018.cpp: -------------------------------------------------------------------------------- 1 | // test018.cpp - delete columns, no row labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | "B,D\n" 12 | "4,256\n" 13 | "9,6561\n" 14 | "16,65536\n" 15 | "25,390625\n" 16 | ; 17 | 18 | std::string csv = 19 | "A,B,C,D\n" 20 | "2,4,16,256\n" 21 | "3,9,81,6561\n" 22 | "4,16,256,65536\n" 23 | "5,25,625,390625\n" 24 | ; 25 | 26 | std::string path = unittest::TempPath(); 27 | unittest::WriteFile(path, csv); 28 | 29 | try 30 | { 31 | rapidcsv::Document doc(path); 32 | 33 | doc.RemoveColumn("C"); 34 | doc.RemoveColumn(0); 35 | 36 | doc.Save(); 37 | 38 | std::string csvread = unittest::ReadFile(path); 39 | 40 | unittest::ExpectEqual(std::string, csvref, csvread); 41 | } 42 | catch (const std::exception& ex) 43 | { 44 | std::cout << ex.what() << std::endl; 45 | rv = 1; 46 | } 47 | 48 | unittest::DeleteFile(path); 49 | 50 | return rv; 51 | } 52 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test019.cpp: -------------------------------------------------------------------------------- 1 | // test019.cpp - delete rows, no row labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | "A,B,C,D\n" 12 | "3,9,81,6561\n" 13 | "4,16,256,65536\n" 14 | ; 15 | 16 | std::string csv = 17 | "A,B,C,D\n" 18 | "2,4,16,256\n" 19 | "3,9,81,6561\n" 20 | "4,16,256,65536\n" 21 | "5,25,625,390625\n" 22 | ; 23 | 24 | std::string path = unittest::TempPath(); 25 | unittest::WriteFile(path, csv); 26 | 27 | try 28 | { 29 | rapidcsv::Document doc(path); 30 | 31 | doc.RemoveRow(3); 32 | doc.RemoveRow(0); 33 | 34 | doc.Save(); 35 | 36 | std::string csvread = unittest::ReadFile(path); 37 | 38 | unittest::ExpectEqual(std::string, csvref, csvread); 39 | } 40 | catch (const std::exception& ex) 41 | { 42 | std::cout << ex.what() << std::endl; 43 | rv = 1; 44 | } 45 | 46 | unittest::DeleteFile(path); 47 | 48 | return rv; 49 | } 50 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test022.cpp: -------------------------------------------------------------------------------- 1 | // test022.cpp - generate new document by cell, no row labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | "A,B,C\n" 12 | "3,9,81\n" 13 | "4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | 18 | try 19 | { 20 | rapidcsv::Document doc("", rapidcsv::LabelParams(), rapidcsv::SeparatorParams(',', false, false)); 21 | 22 | doc.SetCell(0, 0, 3); 23 | doc.SetCell(1, 0, 9); 24 | doc.SetCell(2, 0, 81); 25 | 26 | doc.SetCell(0, 1, 4); 27 | doc.SetCell(1, 1, 16); 28 | doc.SetCell(2, 1, 256); 29 | 30 | doc.SetColumnName(0, "A"); 31 | doc.SetColumnName(1, "B"); 32 | doc.SetColumnName(2, "C"); 33 | 34 | doc.Save(path); 35 | 36 | std::string csvread = unittest::ReadFile(path); 37 | 38 | unittest::ExpectEqual(std::string, csvref, csvread); 39 | } 40 | catch (const std::exception& ex) 41 | { 42 | std::cout << ex.what() << std::endl; 43 | rv = 1; 44 | } 45 | 46 | unittest::DeleteFile(path); 47 | 48 | return rv; 49 | } 50 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test023.cpp: -------------------------------------------------------------------------------- 1 | // test023.cpp - read cell value, no row/column labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "3,9,81\n" 12 | "4,16,256\n" 13 | ; 14 | 15 | std::string path = unittest::TempPath(); 16 | unittest::WriteFile(path, csv); 17 | 18 | try 19 | { 20 | rapidcsv::Document doc(path, rapidcsv::LabelParams(-1, -1)); 21 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 3); 22 | unittest::ExpectEqual(int, doc.GetCell(1, 0), 9); 23 | unittest::ExpectEqual(int, doc.GetCell(2, 0), 81); 24 | 25 | unittest::ExpectEqual(std::string, doc.GetCell(0, 1), "4"); 26 | unittest::ExpectEqual(std::string, doc.GetCell(1, 1), "16"); 27 | unittest::ExpectEqual(std::string, doc.GetCell(2, 1), "256"); 28 | } 29 | catch (const std::exception& ex) 30 | { 31 | std::cout << ex.what() << std::endl; 32 | rv = 1; 33 | } 34 | 35 | unittest::DeleteFile(path); 36 | 37 | return rv; 38 | } 39 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test025.cpp: -------------------------------------------------------------------------------- 1 | // test025.cpp - read column values, no row/column labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "3,9,81\n" 12 | "4,16,256\n" 13 | ; 14 | 15 | std::string path = unittest::TempPath(); 16 | unittest::WriteFile(path, csv); 17 | 18 | try 19 | { 20 | rapidcsv::Document doc(path, rapidcsv::LabelParams(-1, -1)); 21 | 22 | std::vector ints; 23 | std::vector strs; 24 | 25 | ints = doc.GetColumn(0); 26 | unittest::ExpectEqual(size_t, ints.size(), 2); 27 | unittest::ExpectEqual(int, ints.at(0), 3); 28 | unittest::ExpectEqual(int, ints.at(1), 4); 29 | 30 | ints = doc.GetColumn(1); 31 | unittest::ExpectEqual(size_t, ints.size(), 2); 32 | unittest::ExpectEqual(int, ints.at(0), 9); 33 | unittest::ExpectEqual(int, ints.at(1), 16); 34 | 35 | strs = doc.GetColumn(2); 36 | unittest::ExpectEqual(size_t, strs.size(), 2); 37 | unittest::ExpectEqual(std::string, strs.at(0), "81"); 38 | unittest::ExpectEqual(std::string, strs.at(1), "256"); 39 | } 40 | catch (const std::exception& ex) 41 | { 42 | std::cout << ex.what() << std::endl; 43 | rv = 1; 44 | } 45 | 46 | unittest::DeleteFile(path); 47 | 48 | return rv; 49 | } 50 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test027.cpp: -------------------------------------------------------------------------------- 1 | // test027.cpp - read row values, no row/column labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "3,9,81\n" 12 | "4,16,256\n" 13 | ; 14 | 15 | std::string path = unittest::TempPath(); 16 | unittest::WriteFile(path, csv); 17 | 18 | try 19 | { 20 | rapidcsv::Document doc(path, rapidcsv::LabelParams(-1, -1)); 21 | 22 | std::vector ints; 23 | std::vector strs; 24 | 25 | ints = doc.GetRow(0); 26 | unittest::ExpectEqual(size_t, ints.size(), 3); 27 | unittest::ExpectEqual(int, ints.at(0), 3); 28 | unittest::ExpectEqual(int, ints.at(1), 9); 29 | unittest::ExpectEqual(int, ints.at(2), 81); 30 | 31 | strs = doc.GetRow(1); 32 | unittest::ExpectEqual(size_t, strs.size(), 3); 33 | unittest::ExpectEqual(std::string, strs.at(0), "4"); 34 | unittest::ExpectEqual(std::string, strs.at(1), "16"); 35 | unittest::ExpectEqual(std::string, strs.at(2), "256"); 36 | } 37 | catch (const std::exception& ex) 38 | { 39 | std::cout << ex.what() << std::endl; 40 | rv = 1; 41 | } 42 | 43 | unittest::DeleteFile(path); 44 | 45 | return rv; 46 | } 47 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test029.cpp: -------------------------------------------------------------------------------- 1 | // test029.cpp - delete columns, no row/column labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | "4,256\n" 12 | "9,6561\n" 13 | "16,65536\n" 14 | "25,390625\n" 15 | ; 16 | 17 | std::string csv = 18 | "2,4,16,256\n" 19 | "3,9,81,6561\n" 20 | "4,16,256,65536\n" 21 | "5,25,625,390625\n" 22 | ; 23 | 24 | std::string path = unittest::TempPath(); 25 | unittest::WriteFile(path, csv); 26 | 27 | try 28 | { 29 | rapidcsv::Document doc(path, rapidcsv::LabelParams(-1, -1)); 30 | 31 | doc.RemoveColumn(2); 32 | doc.RemoveColumn(0); 33 | 34 | doc.Save(); 35 | 36 | std::string csvread = unittest::ReadFile(path); 37 | 38 | unittest::ExpectEqual(std::string, csvref, csvread); 39 | } 40 | catch (const std::exception& ex) 41 | { 42 | std::cout << ex.what() << std::endl; 43 | rv = 1; 44 | } 45 | 46 | unittest::DeleteFile(path); 47 | 48 | return rv; 49 | } 50 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test030.cpp: -------------------------------------------------------------------------------- 1 | // test030.cpp - delete rows, no row/column labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | "3,9,81,6561\n" 12 | "4,16,256,65536\n" 13 | ; 14 | 15 | std::string csv = 16 | "2,4,16,256\n" 17 | "3,9,81,6561\n" 18 | "4,16,256,65536\n" 19 | "5,25,625,390625\n" 20 | ; 21 | 22 | std::string path = unittest::TempPath(); 23 | unittest::WriteFile(path, csv); 24 | 25 | try 26 | { 27 | rapidcsv::Document doc(path, rapidcsv::LabelParams(-1, -1)); 28 | 29 | doc.RemoveRow(3); 30 | doc.RemoveRow(0); 31 | 32 | doc.Save(); 33 | 34 | std::string csvread = unittest::ReadFile(path); 35 | 36 | unittest::ExpectEqual(std::string, csvref, csvread); 37 | } 38 | catch (const std::exception& ex) 39 | { 40 | std::cout << ex.what() << std::endl; 41 | rv = 1; 42 | } 43 | 44 | unittest::DeleteFile(path); 45 | 46 | return rv; 47 | } 48 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test031.cpp: -------------------------------------------------------------------------------- 1 | // test031.cpp - generate new document by row, no row/column labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | "2,4,16,256\n" 12 | "3,9,81,6561\n" 13 | "4,16,256,65536\n" 14 | "5,25,625,390625\n" 15 | ; 16 | 17 | std::string path = unittest::TempPath(); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc("", rapidcsv::LabelParams(-1, -1), rapidcsv::SeparatorParams(',', false, false)); 22 | 23 | doc.SetRow(0, std::vector({ 2, 4 })); 24 | doc.SetRow(1, std::vector({ 3, 9, 81, 6561 })); 25 | doc.SetRow(2, std::vector({ 4, 16, 256, 65536 })); 26 | doc.SetRow(3, std::vector({ 5, 25, 625, 390625 })); 27 | 28 | doc.SetCell(2, 0, 16); 29 | doc.SetCell(3, 0, 256); 30 | 31 | doc.Save(path); 32 | 33 | std::string csvread = unittest::ReadFile(path); 34 | 35 | unittest::ExpectEqual(std::string, csvref, csvread); 36 | } 37 | catch (const std::exception& ex) 38 | { 39 | std::cout << ex.what() << std::endl; 40 | rv = 1; 41 | } 42 | 43 | unittest::DeleteFile(path); 44 | 45 | return rv; 46 | } 47 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test032.cpp: -------------------------------------------------------------------------------- 1 | // test032.cpp - generate new document by column, no row/column labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | "2,4,16,256\n" 12 | "3,9,81,6561\n" 13 | "4,16,256,65536\n" 14 | "5,25,625,390625\n" 15 | ; 16 | 17 | std::string path = unittest::TempPath(); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc("", rapidcsv::LabelParams(-1, -1), rapidcsv::SeparatorParams(',', false, false)); 22 | 23 | doc.SetColumn(0, std::vector({ 2, 3 })); 24 | doc.SetColumn(1, std::vector({ 4, 9, 16, 25 })); 25 | doc.SetColumn(2, std::vector({ 16, 81, 256, 625 })); 26 | doc.SetColumn(3, std::vector({ 256, 6561, 65536, 390625 })); 27 | 28 | doc.SetCell(0, 2, 4); 29 | doc.SetCell(0, 3, 5); 30 | 31 | doc.Save(path); 32 | 33 | std::string csvread = unittest::ReadFile(path); 34 | 35 | unittest::ExpectEqual(std::string, csvref, csvread); 36 | } 37 | catch (const std::exception& ex) 38 | { 39 | std::cout << ex.what() << std::endl; 40 | rv = 1; 41 | } 42 | 43 | unittest::DeleteFile(path); 44 | 45 | return rv; 46 | } 47 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test033.cpp: -------------------------------------------------------------------------------- 1 | // test033.cpp - generate new document by cell, no row/column labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | "3,9,81\n" 12 | "4,16,256\n" 13 | ; 14 | 15 | std::string path = unittest::TempPath(); 16 | 17 | try 18 | { 19 | rapidcsv::Document doc("", rapidcsv::LabelParams(-1, -1), rapidcsv::SeparatorParams(',', false, false)); 20 | 21 | doc.SetCell(0, 0, 3); 22 | doc.SetCell(1, 0, 9); 23 | doc.SetCell(2, 0, 81); 24 | 25 | doc.SetCell(0, 1, 4); 26 | doc.SetCell(1, 1, 16); 27 | doc.SetCell(2, 1, 256); 28 | 29 | doc.Save(path); 30 | 31 | std::string csvread = unittest::ReadFile(path); 32 | 33 | unittest::ExpectEqual(std::string, csvref, csvread); 34 | } 35 | catch (const std::exception& ex) 36 | { 37 | std::cout << ex.what() << std::endl; 38 | rv = 1; 39 | } 40 | 41 | unittest::DeleteFile(path); 42 | 43 | return rv; 44 | } 45 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test034.cpp: -------------------------------------------------------------------------------- 1 | // test034.cpp - copy document 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | std::string pathcopy = unittest::TempPath(); 20 | 21 | try 22 | { 23 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 24 | 25 | rapidcsv::Document doccopy(doc); 26 | 27 | doccopy.Save(pathcopy); 28 | 29 | std::string csvread = unittest::ReadFile(pathcopy); 30 | 31 | unittest::ExpectEqual(std::string, csv, csvread); 32 | } 33 | catch (const std::exception& ex) 34 | { 35 | std::cout << ex.what() << std::endl; 36 | rv = 1; 37 | } 38 | 39 | unittest::DeleteFile(path); 40 | unittest::DeleteFile(pathcopy); 41 | 42 | return rv; 43 | } 44 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test038.cpp: -------------------------------------------------------------------------------- 1 | // test038.cpp - read windows CR/LF linebreaks 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\r\n" 13 | "2,4,16,256\r\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 22 | 23 | unittest::ExpectEqual(std::string, doc.GetCell(0, 0), "3"); 24 | unittest::ExpectEqual(std::string, doc.GetCell(1, 0), "9"); 25 | unittest::ExpectEqual(std::string, doc.GetCell(2, 0), "81"); 26 | 27 | unittest::ExpectEqual(std::string, doc.GetCell(0, 1), "4"); 28 | unittest::ExpectEqual(std::string, doc.GetCell(1, 1), "16"); 29 | unittest::ExpectEqual(std::string, doc.GetCell(2, 1), "256"); 30 | } 31 | catch (const std::exception& ex) 32 | { 33 | std::cout << ex.what() << std::endl; 34 | rv = 1; 35 | } 36 | 37 | unittest::DeleteFile(path); 38 | 39 | return rv; 40 | } 41 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test039.cpp: -------------------------------------------------------------------------------- 1 | // test039.cpp - write windows CR/LF linebreaks 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\r\n" 12 | "1,3,9,81\r\n" 13 | "2,4,16,256\r\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 22 | 23 | unittest::ExpectEqual(std::string, doc.GetCell(0, 0), "3"); 24 | unittest::ExpectEqual(std::string, doc.GetCell(1, 0), "9"); 25 | unittest::ExpectEqual(std::string, doc.GetCell(2, 0), "81"); 26 | 27 | unittest::ExpectEqual(std::string, doc.GetCell(0, 1), "4"); 28 | unittest::ExpectEqual(std::string, doc.GetCell(1, 1), "16"); 29 | unittest::ExpectEqual(std::string, doc.GetCell(2, 1), "256"); 30 | 31 | doc.Save(); 32 | 33 | std::string csvread = unittest::ReadFile(path); 34 | 35 | unittest::ExpectEqual(std::string, csv, csvread); 36 | } 37 | catch (const std::exception& ex) 38 | { 39 | std::cout << ex.what() << std::endl; 40 | rv = 1; 41 | } 42 | 43 | unittest::DeleteFile(path); 44 | 45 | return rv; 46 | } 47 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test040.cpp: -------------------------------------------------------------------------------- 1 | // test040.cpp - multiple translation units, part 1 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int help_func(); 7 | 8 | int main() 9 | { 10 | int rv = 0; 11 | 12 | std::string csv = 13 | "-,A,B,C\n" 14 | "1,3,9,81\n" 15 | "2,4,16,256\n" 16 | ; 17 | 18 | std::string path = unittest::TempPath(); 19 | unittest::WriteFile(path, csv); 20 | 21 | try 22 | { 23 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 24 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 3); 25 | unittest::ExpectEqual(int, doc.GetCell(1, 0), 9); 26 | unittest::ExpectEqual(int, doc.GetCell(2, 0), 81); 27 | 28 | unittest::ExpectEqual(std::string, doc.GetCell("A", "2"), "4"); 29 | unittest::ExpectEqual(std::string, doc.GetCell("B", "2"), "16"); 30 | unittest::ExpectEqual(std::string, doc.GetCell("C", "2"), "256"); 31 | 32 | rv += help_func(); 33 | } 34 | catch (const std::exception& ex) 35 | { 36 | std::cout << ex.what() << std::endl; 37 | rv = 1; 38 | } 39 | 40 | unittest::DeleteFile(path); 41 | 42 | return rv; 43 | } 44 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test040b.cpp: -------------------------------------------------------------------------------- 1 | // test040b.cpp - multiple translation units, part 2 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int help_func() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 22 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 3); 23 | unittest::ExpectEqual(int, doc.GetCell(1, 0), 9); 24 | unittest::ExpectEqual(int, doc.GetCell(2, 0), 81); 25 | 26 | unittest::ExpectEqual(std::string, doc.GetCell("A", "2"), "4"); 27 | unittest::ExpectEqual(std::string, doc.GetCell("B", "2"), "16"); 28 | unittest::ExpectEqual(std::string, doc.GetCell("C", "2"), "256"); 29 | } 30 | catch (const std::exception& ex) 31 | { 32 | std::cout << ex.what() << std::endl; 33 | rv = 1; 34 | } 35 | 36 | unittest::DeleteFile(path); 37 | 38 | return rv; 39 | } 40 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test041.cpp: -------------------------------------------------------------------------------- 1 | // test041.cpp - handling no linebreak at end of last line 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 22 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 3); 23 | unittest::ExpectEqual(int, doc.GetCell(1, 0), 9); 24 | unittest::ExpectEqual(int, doc.GetCell(2, 0), 81); 25 | 26 | unittest::ExpectEqual(std::string, doc.GetCell("A", "2"), "4"); 27 | unittest::ExpectEqual(std::string, doc.GetCell("B", "2"), "16"); 28 | unittest::ExpectEqual(std::string, doc.GetCell("C", "2"), "256"); 29 | } 30 | catch (const std::exception& ex) 31 | { 32 | std::cout << ex.what() << std::endl; 33 | rv = 1; 34 | } 35 | 36 | unittest::DeleteFile(path); 37 | 38 | return rv; 39 | } 40 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test042.cpp: -------------------------------------------------------------------------------- 1 | // test042.cpp - test GetColumnCount() and GetRowCount() 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc1(path, rapidcsv::LabelParams(0, 0)); 22 | unittest::ExpectEqual(size_t, doc1.GetColumnCount(), 3); 23 | unittest::ExpectEqual(size_t, doc1.GetRowCount(), 2); 24 | 25 | rapidcsv::Document doc2(path, rapidcsv::LabelParams(-1, -1)); 26 | unittest::ExpectEqual(size_t, doc2.GetColumnCount(), 4); 27 | unittest::ExpectEqual(size_t, doc2.GetRowCount(), 3); 28 | } 29 | catch (const std::exception& ex) 30 | { 31 | std::cout << ex.what() << std::endl; 32 | rv = 1; 33 | } 34 | 35 | unittest::DeleteFile(path); 36 | 37 | return rv; 38 | } 39 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test044.cpp: -------------------------------------------------------------------------------- 1 | // test044.cpp - set column values as char 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvref = 11 | "-,A,B,C\n" 12 | "1,a,b,c\n" 13 | "2,x,y,z\n" 14 | ; 15 | 16 | std::string csv = 17 | "-,A,B,C\n" 18 | "1,0,0,0\n" 19 | "2,0,0,0\n" 20 | ; 21 | 22 | std::string path = unittest::TempPath(); 23 | unittest::WriteFile(path, csv); 24 | 25 | try 26 | { 27 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 28 | 29 | doc.SetColumn(0, std::vector({ 'a', 'x' })); 30 | doc.SetColumn(1, std::vector({ 'b', 'y' })); 31 | doc.SetColumn("C", std::vector({ 'c', 'z' })); 32 | 33 | doc.Save(); 34 | 35 | std::string csvread = unittest::ReadFile(path); 36 | 37 | unittest::ExpectEqual(std::string, csvref, csvread); 38 | } 39 | catch (const std::exception& ex) 40 | { 41 | std::cout << ex.what() << std::endl; 42 | rv = 1; 43 | } 44 | 45 | unittest::DeleteFile(path); 46 | 47 | return rv; 48 | } 49 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test045.cpp: -------------------------------------------------------------------------------- 1 | // test045.cpp - read data with custom separator 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-;A;B;C\n" 12 | "1;3;9;81\n" 13 | "2;4;16;256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0), rapidcsv::SeparatorParams(';')); 22 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 3); 23 | unittest::ExpectEqual(int, doc.GetCell(1, 0), 9); 24 | unittest::ExpectEqual(int, doc.GetCell(2, 0), 81); 25 | 26 | unittest::ExpectEqual(std::string, doc.GetCell("A", "2"), "4"); 27 | unittest::ExpectEqual(std::string, doc.GetCell("B", "2"), "16"); 28 | unittest::ExpectEqual(std::string, doc.GetCell("C", "2"), "256"); 29 | } 30 | catch (const std::exception& ex) 31 | { 32 | std::cout << ex.what() << std::endl; 33 | rv = 1; 34 | } 35 | 36 | unittest::DeleteFile(path); 37 | 38 | return rv; 39 | } 40 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test047.cpp: -------------------------------------------------------------------------------- 1 | // test047.cpp - exception on invalid conversion 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,,x,#\n" 13 | "2,,y,$\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 22 | 23 | ExpectException(doc.GetCell(0, 0), std::invalid_argument); 24 | ExpectException(doc.GetCell(1, 0), std::invalid_argument); 25 | ExpectException(doc.GetCell(2, 0), std::invalid_argument); 26 | 27 | ExpectException(doc.GetCell(0, 1), std::invalid_argument); 28 | ExpectException(doc.GetCell(1, 1), std::invalid_argument); 29 | ExpectException(doc.GetCell(2, 1), std::invalid_argument); 30 | } 31 | catch (const std::exception& ex) 32 | { 33 | std::cout << ex.what() << std::endl; 34 | rv = 1; 35 | } 36 | 37 | unittest::DeleteFile(path); 38 | 39 | return rv; 40 | } 41 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test048.cpp: -------------------------------------------------------------------------------- 1 | // test048.cpp - default conversion to default values 2 | 3 | #include 4 | #include 5 | #include "unittest.h" 6 | 7 | int main() 8 | { 9 | int rv = 0; 10 | 11 | std::string csv = 12 | "-,A,B,C\n" 13 | "1,,x,#\n" 14 | "2,,y,$\n" 15 | ; 16 | 17 | std::string path = unittest::TempPath(); 18 | unittest::WriteFile(path, csv); 19 | 20 | try 21 | { 22 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0), rapidcsv::SeparatorParams(), 23 | rapidcsv::ConverterParams(true)); 24 | 25 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 0); 26 | unittest::ExpectEqual(long long, doc.GetCell(1, 0), 0); 27 | unittest::ExpectEqual(unsigned int, doc.GetCell(2, 0), 0); 28 | 29 | unittest::ExpectTrue(std::isnan(doc.GetCell(0, 1))); 30 | unittest::ExpectTrue(std::isnan(doc.GetCell(1, 1))); 31 | unittest::ExpectTrue(std::isnan(doc.GetCell(2, 1))); 32 | } 33 | catch (const std::exception& ex) 34 | { 35 | std::cout << ex.what() << std::endl; 36 | rv = 1; 37 | } 38 | 39 | unittest::DeleteFile(path); 40 | 41 | return rv; 42 | } 43 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test049.cpp: -------------------------------------------------------------------------------- 1 | // test049.cpp - default conversion to custom values 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,,x,#\n" 13 | "2,,y,$\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0), rapidcsv::SeparatorParams(), 22 | rapidcsv::ConverterParams(true, 0.0, 1)); 23 | 24 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 1); 25 | unittest::ExpectEqual(long long, doc.GetCell(1, 0), 1); 26 | unittest::ExpectEqual(unsigned int, doc.GetCell(2, 0), 1); 27 | 28 | unittest::ExpectEqual(double, doc.GetCell(0, 1), 0.0); 29 | unittest::ExpectEqual(long double, doc.GetCell(1, 1), 0.0); 30 | unittest::ExpectEqual(float, doc.GetCell(2, 1), 0.0); 31 | } 32 | catch (const std::exception& ex) 33 | { 34 | std::cout << ex.what() << std::endl; 35 | rv = 1; 36 | } 37 | 38 | unittest::DeleteFile(path); 39 | 40 | return rv; 41 | } 42 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test052.cpp: -------------------------------------------------------------------------------- 1 | // test052.cpp - read numbers with scientific notation 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,1.2e10,2.00E-07,1e100\n" 13 | ; 14 | 15 | std::string path = unittest::TempPath(); 16 | unittest::WriteFile(path, csv); 17 | 18 | try 19 | { 20 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 21 | 22 | double eps1 = 1.0e7; 23 | double exp1 = 1.2e10; 24 | double val1 = doc.GetCell("A", "1"); 25 | unittest::ExpectTrue(fabs(val1 - exp1) < eps1); 26 | 27 | double eps2 = 1.0e-10; 28 | double exp2 = 2.00e-07; 29 | double val2 = doc.GetCell("B", "1"); 30 | unittest::ExpectTrue(fabs(val2 - exp2) < eps2); 31 | 32 | double eps3 = 1e97; 33 | double exp3 = 1e100; 34 | double val3 = doc.GetCell("C", "1"); 35 | unittest::ExpectTrue(fabs(val3 - exp3) < eps3); 36 | } 37 | catch (const std::exception& ex) 38 | { 39 | std::cout << ex.what() << std::endl; 40 | rv = 1; 41 | } 42 | 43 | unittest::DeleteFile(path); 44 | 45 | return rv; 46 | } 47 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test055.cpp: -------------------------------------------------------------------------------- 1 | // test055.cpp - write to stream 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | std::string outpath = unittest::TempPath(); 20 | 21 | try 22 | { 23 | // to file stream 24 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 25 | std::ofstream ostream; 26 | ostream.exceptions(std::ifstream::failbit | std::ifstream::badbit); 27 | ostream.open(outpath, std::ios::binary | std::ios::ate); 28 | doc.Save(ostream); 29 | ostream.close(); 30 | 31 | std::string csvread = unittest::ReadFile(outpath); 32 | unittest::ExpectEqual(std::string, csv, csvread); 33 | 34 | // to string stream 35 | std::ostringstream sstream; 36 | doc.Save(sstream); 37 | unittest::ExpectEqual(std::string, csv, sstream.str()); 38 | } 39 | catch (const std::exception& ex) 40 | { 41 | std::cout << ex.what() << std::endl; 42 | rv = 1; 43 | } 44 | 45 | unittest::DeleteFile(path); 46 | 47 | return rv; 48 | } 49 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test056.cpp: -------------------------------------------------------------------------------- 1 | // test056.cpp - write cells containing separator character 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,\"3,8\",9,81\n" 13 | "2,4,16,\"256,8\"\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | std::string outpath = unittest::TempPath(); 19 | 20 | try 21 | { 22 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 23 | doc.SetCell("C", "2", "256,8"); 24 | doc.Save(outpath); 25 | std::string csvread = unittest::ReadFile(outpath); 26 | unittest::ExpectEqual(std::string, csv, csvread); 27 | } 28 | catch (const std::exception& ex) 29 | { 30 | std::cout << ex.what() << std::endl; 31 | rv = 1; 32 | } 33 | 34 | unittest::DeleteFile(path); 35 | unittest::DeleteFile(outpath); 36 | 37 | return rv; 38 | } 39 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test061.cpp: -------------------------------------------------------------------------------- 1 | // test061.cpp - read trimmed cell values 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-, A,B , C \n" 12 | " 1,3 , 9 , 81\n" 13 | "2 ,4 , 16, 256 \n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0), rapidcsv::SeparatorParams(',', true)); 22 | unittest::ExpectEqual(std::string, doc.GetCell("A", "1"), "3"); 23 | unittest::ExpectEqual(std::string, doc.GetCell("B", "1"), "9"); 24 | unittest::ExpectEqual(std::string, doc.GetCell("C", "1"), "81"); 25 | 26 | unittest::ExpectEqual(std::string, doc.GetCell("A", "2"), "4"); 27 | unittest::ExpectEqual(std::string, doc.GetCell("B", "2"), "16"); 28 | unittest::ExpectEqual(std::string, doc.GetCell("C", "2"), "256"); 29 | } 30 | catch (const std::exception& ex) 31 | { 32 | std::cout << ex.what() << std::endl; 33 | rv = 1; 34 | } 35 | 36 | unittest::DeleteFile(path); 37 | 38 | return rv; 39 | } 40 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test062.cpp: -------------------------------------------------------------------------------- 1 | // test062.cpp - read cell value by mixed name / index 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 22 | unittest::ExpectEqual(int, doc.GetCell("A", 0), 3); 23 | unittest::ExpectEqual(int, doc.GetCell("B", 0), 9); 24 | unittest::ExpectEqual(int, doc.GetCell("C", 0), 81); 25 | 26 | unittest::ExpectEqual(std::string, doc.GetCell(0, "2"), "4"); 27 | unittest::ExpectEqual(std::string, doc.GetCell(1, "2"), "16"); 28 | unittest::ExpectEqual(std::string, doc.GetCell(2, "2"), "256"); 29 | } 30 | catch (const std::exception& ex) 31 | { 32 | std::cout << ex.what() << std::endl; 33 | rv = 1; 34 | } 35 | 36 | unittest::DeleteFile(path); 37 | 38 | return rv; 39 | } 40 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test066.cpp: -------------------------------------------------------------------------------- 1 | // test066.cpp - test UTF-8 Byte order mark skipping 2 | 3 | #include "rapidcsv.h" 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvWithBom = 11 | "\xef\xbb\xbfID\n" 12 | "1\n" 13 | ; 14 | 15 | std::string path = unittest::TempPath(); 16 | unittest::WriteFile(path, csvWithBom); 17 | 18 | try 19 | { 20 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, -1)); 21 | unittest::ExpectEqual(size_t, doc.GetRowCount(), 1); 22 | unittest::ExpectEqual(std::string, doc.GetColumn("ID")[0], "1"); 23 | } 24 | catch (const std::exception& ex) 25 | { 26 | std::cout << ex.what() << std::endl; 27 | rv = 1; 28 | } 29 | 30 | unittest::DeleteFile(path); 31 | 32 | return rv; 33 | } 34 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test069.cpp: -------------------------------------------------------------------------------- 1 | // test069.cpp - get row index, no row labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path); 22 | 23 | unittest::ExpectEqual(ssize_t, doc.GetRowIdx("-"), -1); 24 | unittest::ExpectEqual(ssize_t, doc.GetRowIdx("1"), -1); 25 | unittest::ExpectEqual(ssize_t, doc.GetRowIdx("2"), -1); 26 | unittest::ExpectEqual(ssize_t, doc.GetRowIdx("3"), -1); 27 | } 28 | catch (const std::exception& ex) 29 | { 30 | std::cout << ex.what() << std::endl; 31 | rv = 1; 32 | } 33 | 34 | unittest::DeleteFile(path); 35 | 36 | return rv; 37 | } 38 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test070.cpp: -------------------------------------------------------------------------------- 1 | // test070.cpp - get row index with column labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | // Row Label 22 | // ↓ 23 | // -, A, B, C ← Column Label 24 | // 1, 3, 9, 81 25 | // 2, 4, 16, 256 26 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 27 | 28 | unittest::ExpectEqual(ssize_t, doc.GetRowIdx("-"), -1); 29 | unittest::ExpectEqual(ssize_t, doc.GetRowIdx("1"), 0); 30 | unittest::ExpectEqual(ssize_t, doc.GetRowIdx("2"), 1); 31 | unittest::ExpectEqual(ssize_t, doc.GetRowIdx("3"), -1); 32 | } 33 | catch (const std::exception& ex) 34 | { 35 | std::cout << ex.what() << std::endl; 36 | rv = 1; 37 | } 38 | 39 | unittest::DeleteFile(path); 40 | 41 | return rv; 42 | } 43 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test071.cpp: -------------------------------------------------------------------------------- 1 | // test071.cpp - get row index, no column labels 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | // No Column Label 22 | // Row Label 23 | // ↓ 24 | // -, A, B, C 25 | // 1, 3, 9, 81 26 | // 2, 4, 16, 256 27 | rapidcsv::Document doc2(path, rapidcsv::LabelParams(-1, 0)); 28 | 29 | unittest::ExpectEqual(ssize_t, doc2.GetRowIdx("-"), 0); 30 | unittest::ExpectEqual(ssize_t, doc2.GetRowIdx("1"), 1); 31 | unittest::ExpectEqual(ssize_t, doc2.GetRowIdx("2"), 2); 32 | unittest::ExpectEqual(ssize_t, doc2.GetRowIdx("3"), -1); 33 | } 34 | catch (const std::exception& ex) 35 | { 36 | std::cout << ex.what() << std::endl; 37 | rv = 1; 38 | } 39 | 40 | unittest::DeleteFile(path); 41 | 42 | return rv; 43 | } 44 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test072.cpp: -------------------------------------------------------------------------------- 1 | // test072.cpp - get column index 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path); 22 | 23 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("-"), 0); 24 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("A"), 1); 25 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("B"), 2); 26 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("C"), 3); 27 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("D"), -1); 28 | } 29 | catch (const std::exception& ex) 30 | { 31 | std::cout << ex.what() << std::endl; 32 | rv = 1; 33 | } 34 | 35 | unittest::DeleteFile(path); 36 | 37 | return rv; 38 | } 39 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test073.cpp: -------------------------------------------------------------------------------- 1 | // test073.cpp - get column index, shift column name index 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "-,A,B,C\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path, rapidcsv::LabelParams(1)); 22 | 23 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("-"), -1); 24 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("A"), -1); 25 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("B"), -1); 26 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("C"), -1); 27 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("D"), -1); 28 | 29 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("1"), 0); 30 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("3"), 1); 31 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("9"), 2); 32 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("81"), 3); 33 | unittest::ExpectEqual(ssize_t, doc.GetColumnIdx("91"), -1); 34 | } 35 | catch (const std::exception& ex) 36 | { 37 | std::cout << ex.what() << std::endl; 38 | rv = 1; 39 | } 40 | 41 | unittest::DeleteFile(path); 42 | 43 | return rv; 44 | } 45 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test078.cpp: -------------------------------------------------------------------------------- 1 | // test078.cpp - include Windows.h before rapidcsv.h 2 | 3 | #if defined(_MSC_VER) 4 | #include 5 | #endif 6 | 7 | #include 8 | #include "unittest.h" 9 | 10 | int main() 11 | { 12 | int rv = 0; 13 | 14 | std::string csv = 15 | "-,A,B,C\n" 16 | "1,3,9,81\n" 17 | "2,4,16,256\n" 18 | ; 19 | 20 | std::string path = unittest::TempPath(); 21 | unittest::WriteFile(path, csv); 22 | 23 | try 24 | { 25 | rapidcsv::Document doc(path, rapidcsv::LabelParams(0, 0)); 26 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 3); 27 | unittest::ExpectEqual(int, doc.GetCell(1, 0), 9); 28 | unittest::ExpectEqual(int, doc.GetCell(2, 0), 81); 29 | 30 | unittest::ExpectEqual(std::string, doc.GetCell("A", "2"), "4"); 31 | unittest::ExpectEqual(std::string, doc.GetCell("B", "2"), "16"); 32 | unittest::ExpectEqual(std::string, doc.GetCell("C", "2"), "256"); 33 | } 34 | catch (const std::exception& ex) 35 | { 36 | std::cout << ex.what() << std::endl; 37 | rv = 1; 38 | } 39 | 40 | unittest::DeleteFile(path); 41 | 42 | return rv; 43 | } 44 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test079.cpp: -------------------------------------------------------------------------------- 1 | // test079.cpp - perform multiple Load calls on single Document instance 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv1 = 11 | "A,B,C,D\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string csv2 = 17 | "A,B,C,D\n" 18 | "1,3,9,81\n" 19 | ; 20 | 21 | std::string csv3 = 22 | "A,B,C,D\n" 23 | "1,3,9,81\n" 24 | "2,4,16,256\n" 25 | "4,16,256,67840\n" 26 | ; 27 | 28 | std::string path = unittest::TempPath(); 29 | unittest::WriteFile(path, csv3); 30 | 31 | try 32 | { 33 | std::istringstream sstream1(csv1); 34 | rapidcsv::Document doc(sstream1); 35 | unittest::ExpectEqual(size_t, doc.GetRowCount(), 2); 36 | 37 | std::istringstream sstream2(csv2); 38 | doc.Load(sstream2); 39 | unittest::ExpectEqual(size_t, doc.GetRowCount(), 1); 40 | 41 | doc.Load(path); 42 | unittest::ExpectEqual(size_t, doc.GetRowCount(), 3); 43 | } 44 | catch (const std::exception& ex) 45 | { 46 | std::cout << ex.what() << std::endl; 47 | rv = 1; 48 | } 49 | 50 | unittest::DeleteFile(path); 51 | 52 | return rv; 53 | } 54 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test080.cpp: -------------------------------------------------------------------------------- 1 | // test080.cpp - test Clear 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csv = 11 | "A,B,C,D\n" 12 | "1,3,9,81\n" 13 | "2,4,16,256\n" 14 | ; 15 | 16 | std::string path = unittest::TempPath(); 17 | unittest::WriteFile(path, csv); 18 | 19 | try 20 | { 21 | rapidcsv::Document doc(path); 22 | unittest::ExpectEqual(size_t, doc.GetRowCount(), 2); 23 | 24 | doc.Clear(); 25 | unittest::ExpectEqual(size_t, doc.GetRowCount(), 0); 26 | } 27 | catch (const std::exception& ex) 28 | { 29 | std::cout << ex.what() << std::endl; 30 | rv = 1; 31 | } 32 | 33 | unittest::DeleteFile(path); 34 | 35 | return rv; 36 | } 37 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test083.cpp: -------------------------------------------------------------------------------- 1 | // test083.cpp - empty lines 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvEmptyLines = 11 | "\n" 12 | "-,A,B,C\n" 13 | "\n" 14 | "1,3,9,81\n" 15 | "2,4,16,256\n" 16 | "\n" 17 | ; 18 | 19 | std::string path = unittest::TempPath(); 20 | unittest::WriteFile(path, csvEmptyLines); 21 | try 22 | { 23 | rapidcsv::Document doc(path, rapidcsv::LabelParams(), rapidcsv::SeparatorParams(), 24 | rapidcsv::ConverterParams(), 25 | rapidcsv::LineReaderParams(false, '#', true)); 26 | unittest::ExpectEqual(size_t, doc.GetColumn("A").size(), 2); 27 | unittest::ExpectEqual(size_t, doc.GetColumn("B").size(), 2); 28 | unittest::ExpectEqual(size_t, doc.GetColumn("C").size(), 2); 29 | 30 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 1); 31 | unittest::ExpectEqual(int, doc.GetCell(1, 1), 4); 32 | } 33 | catch (const std::exception& ex) 34 | { 35 | std::cout << ex.what() << std::endl; 36 | rv = 1; 37 | } 38 | 39 | unittest::DeleteFile(path); 40 | 41 | return rv; 42 | } 43 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test084.cpp: -------------------------------------------------------------------------------- 1 | // test084.cpp - comment lines 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | std::string csvCommentLines = 11 | "/ comment line 1\n" 12 | "/ comment line 2\n" 13 | "-,A,B,C\n" 14 | "1,3,9,81\n" 15 | "2,4,16,256\n" 16 | ; 17 | 18 | std::string path = unittest::TempPath(); 19 | unittest::WriteFile(path, csvCommentLines); 20 | try 21 | { 22 | rapidcsv::Document doc(path, rapidcsv::LabelParams(), rapidcsv::SeparatorParams(), 23 | rapidcsv::ConverterParams(), 24 | rapidcsv::LineReaderParams(true, '/')); 25 | unittest::ExpectEqual(size_t, doc.GetColumn("A").size(), 2); 26 | unittest::ExpectEqual(size_t, doc.GetColumn("B").size(), 2); 27 | unittest::ExpectEqual(size_t, doc.GetColumn("C").size(), 2); 28 | 29 | unittest::ExpectEqual(int, doc.GetCell(0, 0), 1); 30 | unittest::ExpectEqual(int, doc.GetCell(1, 1), 4); 31 | } 32 | catch (const std::exception& ex) 33 | { 34 | std::cout << ex.what() << std::endl; 35 | rv = 1; 36 | } 37 | 38 | unittest::DeleteFile(path); 39 | 40 | return rv; 41 | } 42 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/tests/test085.cpp: -------------------------------------------------------------------------------- 1 | // test085.cpp - read UTF-16 LE file 2 | 3 | #include 4 | #include "unittest.h" 5 | 6 | int main() 7 | { 8 | int rv = 0; 9 | 10 | try 11 | { 12 | rapidcsv::Document doc("../tests/chi-utf16.csv", rapidcsv::LabelParams(0, 0), rapidcsv::SeparatorParams(';')); 13 | 14 | unittest::ExpectEqual(std::string, doc.GetCell("description", "0"), "等待同PLC的Profinet通讯"); 15 | unittest::ExpectEqual(std::string, doc.GetCell("description", "1"), "辅助关闭"); 16 | unittest::ExpectEqual(std::string, doc.GetCell("description", "2"), "Z1轴运行中转轮锁定"); 17 | 18 | unittest::ExpectEqual(std::string, doc.GetCell(0, 7), "设备不正常"); 19 | unittest::ExpectEqual(std::string, doc.GetCell(0, 8), "标准件校对:工装翻转补偿值不正确"); 20 | unittest::ExpectEqual(std::string, doc.GetCell(0, 39), "达到扭矩限制"); 21 | } 22 | catch (const std::exception& ex) 23 | { 24 | std::cout << ex.what() << std::endl; 25 | rv = 1; 26 | } 27 | 28 | return rv; 29 | } 30 | -------------------------------------------------------------------------------- /examples/libraries/rapidcsv/winmake.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | mkdir build-debug 4 | cd build-debug || goto :error 5 | cmake -DRAPIDCSV_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug .. || goto :error 6 | msbuild /m /nologo /verbosity:quiet /property:Configuration=Debug rapidcsv.sln || goto :error 7 | ctest -C Debug --output-on-failure || goto :error 8 | cd .. || goto :error 9 | 10 | mkdir build-release 11 | cd build-release || goto :error 12 | cmake -DRAPIDCSV_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release .. || goto :error 13 | msbuild /m /nologo /verbosity:quiet /property:Configuration=Release rapidcsv.sln || goto :error 14 | ctest -C Release --verbose || goto :error 15 | cd .. || goto :error 16 | 17 | goto :EOF 18 | 19 | :error 20 | echo Failed with error #%errorlevel%. 21 | exit /b %errorlevel% 22 | --------------------------------------------------------------------------------