- Notifications
You must be signed in to change notification settings - Fork0
Documentation#225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Documentation#225
Changes fromall commits
Commits
Show all changes
9 commits Select commitHold shift + click to select a range
685553f #204-create PCS documentation
schmouk7a771e2 #204-create PCS documentation
schmouk96c75d6 #204-create PCS documentation
schmouk4fda9ec Update README.md
schmouk2e1ad62 #204
schmoukcac9c07 #224-generate doxygen documentation
schmouk061477d #204-create PCS documentation
schmouk7382f6b #223-cpp-strings VS project clean-up
schmouk7d902d3 #222-simplify .gitignore
schmoukFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
22 changes: 0 additions & 22 deletions.gitignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -7,25 +7,6 @@ | ||
| *.o | ||
| *.obj | ||
| # Executables | ||
| *.exe | ||
| *.out | ||
| @@ -36,6 +17,3 @@ | ||
| x64 | ||
| Debug | ||
| Release | ||
105 changes: 104 additions & 1 deletionREADME.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,105 @@ | ||
| # Library cpp-strings | ||
| [](https://github.com/schmouk/cpprandlib/license) [](https://github.com/schmouk/cpprandlib/releases) []() []() | ||
| github repository: [https://github.com/schmouk/pythonic-cpp-strings](https://github.com/schmouk/pythonic-cpp-strings) | ||
| What if c++ strings where as easy to use as Python strings? | ||
| Let's just use c++ strings as are Python ones, with same API or as similar API as possible. | ||
| Library **cpp-strings** is fully templated. Just download header file `cppstrings.h` and put it anywhere in your project. Notice: all of its stuff is declared and defined in namespace `pcs` - which stands for **P**ythonic **C**++ **S**trings. | ||
| * The templated class `pcs::CppStringT<>` defines all constructors and methods that implement the equivalent of Python strings API. | ||
| * Class `pcs::CppString` specializes the templated class with `char` characters. | ||
| * Class `pcs::CppWString` specializes the templated class with `wchar_t` characters. | ||
| **cpp-strings** is implemented with the currently most recent c++ standard available with gcc, clang and msvc c++ compilers, i.e. standard **c++20**. | ||
| * directory `cpp-strings` contains the header file `cppstring.h`. | ||
| This is the header file to include in your projects. | ||
| * directory `cpp-strings-tests` contains the unit-tests file `cpp-strings-tests.cpp` | ||
| This file tests all the library stuff. It is a valuable code container with so many examples of use of the library, the classes, the methods and the functions it defines. | ||
| The code has been developed using VS2022 IDE. As such, unitary tests have been coded using Microsoft Visual Studio Cpp Unit Test Framework. The related VS project is provided with this library. | ||
| Notice: no clang, gcc or msvc specific declarations or goodies have been use to code library **cpp-strings**. It should then be compilable with any of these compilers. To be able to use it with your project, just ensure that the c++ standard used with you favorite compiler is **c++20**: | ||
| * options `-std=c++20` or `-std=c++latest` for clang and gcc (v. 10 and above), | ||
| or option `-std=c++2a` for clang and gcc (v. 9 and earlier); | ||
| * options `/std=c++20` or `/std=c++latest` for Visual Studio 2019 and later. | ||
| If you want to run the unitary tests, well, use the last version of Visual Studio (i.e. VS 2022, by July 2025). The Community free version will truly be fine. | ||
| The vcproject associated with the unit tests in **cpp-strings** is already configured to use the option flag `/std:c++latest` since the implemented code uses a very few but very useful c++23 goodies. | ||
| --- | ||
| ## License | ||
| Library cpp-strings | ||
| "What if c++ strings where as easy to use as Python strings?" | ||
| Copyright (C) 2023-2025 Philippe Schmouker | ||
| contact - ph (dot) schmouker (at) gmail (dot) com | ||
| This program is free software: you can redistribute it and/or modify | ||
| it under the terms of the GNU General Public License as published by | ||
| the Free Software Foundation, either version 3 of the License, or | ||
| (at your option) any later version. | ||
| This program is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU General Public License for more details. | ||
| You should have received a copy of the GNU General Public License | ||
| along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| --- | ||
| ## Intro | ||
| The creation of this library has been started with the aim at easing the use of strings in c++. Other projects exist, even aiming also to implement a Python-like strings API, but the only ones we have found were either started but not completed, or were not implementing the whole Python API. | ||
| So, we started to work on **Pythonic c++ strings**. Library **cpp-strings** is now ready. It fully implements the Python API (even with a c++ implementation of *slices*) and it is fully tested with *unitary tests*. | ||
| The implementation of library **cpp-strings** is fully templated and is contained into a single header file: `cpp-strings/cppstrings.h`. To take a whole benefit of it, just add this header file to your project and include it in your own files. It very fastly compiles. That's all! | ||
| Header file `cpp-strings/cppstrings.h` defines: | ||
| * templated class `template<typename CharT> class pcs::CppStringT` which implements all the stuff about pythonic c++ strings. It inherits from c++ STL class `std::basic_string<CharT>`, so it gets access to all c++ STL methods, functions and goodies about strings; | ||
| * this class is specialized by: `using pcs::CppString> = pcs::CppStringT<char>` for pythonic c++ strings based on `char` characters; | ||
| * it is also specialized by: `using pcs::CppWString> = pcs::CppStringT<wchar_t>` for pythonic c++ strings based on `wchar_t` characters. | ||
| The unitary tests are provided in directory `cpp-strings-tests/`. File `cpp-strings-tests/cpp-strings-tests.cpp` contains the related code. Tests have been coded using VS2022 IDE and as such, are using the Microsoft Visual Studio Cpp Unit Test Framework. The related VS project can be found in the same directory. It is already configured to create code for Release as well as for Debug configurations, and for 32-bits or 64-bits platforms at your choice. | ||
| This `.cpp` file is a great place to see **cpp-strings** code in action. Each structure, class, method, litteral operator and function being unitary tested in here, you should find there many examples of its use for all **cpp-strings** stuff. | ||
| --- | ||
| ## Latest Release - Release 1.0 (1.0.0.224) 2025/07 | ||
| The coding of this project started by March 2023 and had been put in standby mode for some months - no time to work on it. The very first release is now availble (since July 2025), as **Release 1.0**. | ||
| This release has been fully tested. Code coverage is 100%. | ||
| Release 1.0 implements all Python strings API but one feature (see below). | ||
| Python *slices* are implemented via c++ `operator()` as declared and defined in the templated class `pcs::CppStringT<>`. Python slices have next specific notation: `[start : stop : step]` and allow the running step by step through range [start, stop) (notice: stop is excluded from the range). Operator `(start, stop, step)` acts the same way while running through the content of pythonic c++ strings. A dedicated base class `Slice` is also provided and can be passed as argument to `operator()`. It is derived in many simpler slices classes, since Python slices may not define either `start`, `stop` or `step` which then get default values (resp. 0, *end-of-sequence*, and 1). | ||
| ### Missing parts in Release 1.0 | ||
| Python strings are based on Unicode chars. This is currently not the case for pythonic c++ strings in **cpp-strings**. | ||
| Unicode encoding allows for a specific comparison mode on strings, the **casefold** mode. There, Unicode chars are transformed into their lower equivalent char in a standardized manner which is more "agressive" than the simpler lowering method `lower()`. Comparing strings without taking into account the case of their chars is then performed in a far more accurate manner. | ||
| This feature is currently NOT implemented in library **cpp-strings**. | ||
| So up to now, if you want to compare pythonic c++ strings from **cpp-strings** on whatever the case is for each of their chars, compare them applying method `.lower()` to both strings. This will do the job for chars and for wchar_t also for a majority of languages (but might fail for very few signs of specific languages in this last case). | ||
| Notice: dealing with Unicode chars and implementing method `casefold()` as it is the case in Python is planned for a next release of library **cpp-strings**. | ||
| N.B. "*planned for a next release*" does not imply that a fixed date is planned either. | ||
| --- | ||
| ## Documentation | ||
| The **cpp-strings** HTML documentation is available here: [html/index.html](html/index.html). | ||
| It has then been produced with the great utility **doxygen** developed by Vicente Hernando (the doxygen Github repository can be accessed [here](https://github.com/doxygen/doxygen), and the utility can be downloaded from there: [https://www.doxygen.nl/download.html](https://www.doxygen.nl/download.html)). | ||
| This is a short documentation of the library. For some of its part it is a copy of the Python original documentation on strings. For its other part it documents the c++ implementation of **cpp-strings**. | ||
| And remember: to better understand how to use this pythonic c++ strings library, have a look also at [`cpp-strings-tests/cpp-strings-tests.cpp`](cpp-strings-tests/cpp-strings-tests.cpp) to see **cpp-strings** library code in action! |
96 changes: 96 additions & 0 deletionscpp-strings/cpp-strings.cfg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # Doxyfile 1.14.0 | ||
| # This file describes the settings to be used by the documentation system | ||
| # Doxygen (www.doxygen.org) for a project. | ||
| # | ||
| # All text after a double hash (##) is considered a comment and is placed in | ||
| # front of the TAG it is preceding. | ||
| # | ||
| # All text after a single hash (#) is considered a comment and will be ignored. | ||
| # The format is: | ||
| # TAG = value [value, ...] | ||
| # For lists, items can also be appended using: | ||
| # TAG += value [value, ...] | ||
| # Values that contain spaces should be placed between quotes (\" \"). | ||
| # | ||
| # Note: | ||
| # | ||
| # Use Doxygen to compare the used configuration file with the template | ||
| # configuration file: | ||
| # doxygen -x [configFile] | ||
| # Use Doxygen to compare the used configuration file with the template | ||
| # configuration file without replacing the environment variables or CMake type | ||
| # replacement variables: | ||
| # doxygen -x_noenv [configFile] | ||
| #--------------------------------------------------------------------------- | ||
| # Project related configuration options | ||
| #--------------------------------------------------------------------------- | ||
| PROJECT_NAME = "cpp-strings" | ||
| PROJECT_NUMBER = "1.0.0" | ||
| PROJECT_BRIEF = "Pythonic c++ strings" | ||
| OUTPUT_DIRECTORY = | ||
| ABBREVIATE_BRIEF = "The $name class" \ | ||
| "The $name widget" \ | ||
| "The $name file" \ | ||
| is \ | ||
| provides \ | ||
| specifies \ | ||
| contains \ | ||
| represents \ | ||
| a \ | ||
| an \ | ||
| the | ||
| ALWAYS_DETAILED_SEC = YES | ||
| FULL_PATH_NAMES = NO | ||
| BUILTIN_STL_SUPPORT = YES | ||
| TIMESTAMP = DATE ##YES ##NO ##DATETIME ## | ||
| #--------------------------------------------------------------------------- | ||
| # Build related configuration options | ||
| #--------------------------------------------------------------------------- | ||
| HIDE_UNDOC_NAMESPACES = NO | ||
| SORT_BRIEF_DOCS = YES | ||
| WARN_NO_PARAMDOC = NO | ||
| #--------------------------------------------------------------------------- | ||
| # Configuration options related to the input files | ||
| #--------------------------------------------------------------------------- | ||
| INPUT = ./ ../ | ||
| INPUT_ENCODING = UTF-8 | ||
| USE_MDFILE_AS_MAINPAGE = ../README.md | ||
| #--------------------------------------------------------------------------- | ||
| # Configuration options related to source browsing | ||
| #--------------------------------------------------------------------------- | ||
| REFERENCED_BY_RELATION = YES | ||
| REFERENCES_RELATION = YES | ||
| #--------------------------------------------------------------------------- | ||
| # Configuration options related to the HTML output | ||
| #--------------------------------------------------------------------------- | ||
| GENERATE_HTML = YES | ||
| HTML_OUTPUT = html | ||
| HTML_FILE_EXTENSION = .html | ||
| HTML_COLORSTYLE_HUE = 220 | ||
| HTML_COLORSTYLE_SAT = 100 | ||
| HTML_COLORSTYLE_GAMMA = 80 | ||
| HTML_DYNAMIC_MENUS = YES | ||
| HTML_DYNAMIC_SECTIONS = NO | ||
| HTML_CODE_FOLDING = NO ##YES | ||
| HTML_COPY_CLIPBOARD = YES | ||
| HTML_INDEX_NUM_ENTRIES = 100 | ||
| GENERATE_TREEVIEW = YES | ||
| FULL_SIDEBAR = NO | ||
| TREEVIEW_WIDTH = 250 | ||
| EXT_LINKS_IN_WINDOW = NO | ||
| SEARCHENGINE = YES | ||
| SERVER_BASED_SEARCH = NO | ||
| EXTERNAL_SEARCH = NO | ||
| #--------------------------------------------------------------------------- | ||
| # Configuration options related to the LaTeX output | ||
| #--------------------------------------------------------------------------- | ||
| GENERATE_LATEX = NO |
4 changes: 0 additions & 4 deletionscpp-strings/cpp-strings.vcxproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletionscpp-strings/cpp-strings.vcxproj.filters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletionscpp-strings/cppstrings.cpp
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.