Giter Club home page Giter Club logo

stringpy's Introduction

StringPy

๐Ÿ“š A C++17 string manipulation library

Release codecov License

Provides a set of string manipulation functions, many of which are similar to Python string methods.

๐ŸŒŸ Features

  • Flexible Comparison Options: Compare strings using either case-sensitive or case-insensitive matching.

  • Flexible String Matching: Find substrings within strings using either case-sensitive or case-insensitive matching.

  • String Splitting and Joining: Split strings into substrings based on specified delimiters or join multiple strings together with a specified delimiter.

  • String Transformation: Transform strings in various ways, such as capitalizing the first letter of each word, centering text within a specified width, expanding tabs to spaces, justifying text to the left or right, replacing substrings with new values, swapping the case of characters or converting them to uppercase or lowercase, etc.

  • String Trimming: Remove leading and trailing whitespace or specific characters from strings.

  • String Formatting: Provides a very simple yet fast string formatting function. It's at least two times faster than typical solutions based on std::snprintf, such as this one (tested with Google Benchmark). Additionally, this function is safe and does not throw exceptions, even if passed a nullptr as an argument.

  • Character and String Classification: Determine the type of character or string, such as whether it is alphanumeric, alphabetic, ASCII, a digit, graphical, printable, punctuation, whitespace, etc.

And more.

๐Ÿ’ช Robust and Reliable

Each function has been thoroughly tested with unit tests to ensure its correctness and reliability. Additionally, the functions in this library do not throw exceptions and do not use RTTI (Run-Time Type Information), making them safe and easy to use in any project.

๐ŸŒŽ Cross-Platform and Dependency-Free

This library is completely self-contained and does not have any external dependencies (except STL). It can be used on any platform that supports C++17 (Windows, Linux, macOS).

๐Ÿ’ป Usage

There are several ways to include StringPy in your project, such as adding it as a submodule, manually copying the files, or compiling and installing the library.

However, one of the easiest approaches is to use CMake FetchContent. To do this, add the following lines to your CMakeLists.txt file:

include(FetchContent)

FetchContent_Declare(
  StringPy
  GIT_REPOSITORY https://github.com/hun1er/stringpy.git
  GIT_TAG        v1.0.2
)

FetchContent_MakeAvailable(StringPy)

Then you can use the targets and functions of StringPy in other CMakeLists.txt files in your project. For example:

target_link_libraries(my_target PRIVATE StringPy::stringpy)

Once you have included StringPy in your project, you can use it by including the header files and calling the desired functions. For example:

#include <stringpy/stringpy.hpp>

int main()
{
    std::string str = "hello, world!";
    std::string result = strpy::title(str);
    std::cout << result << std::endl; // prints "Hello, World!"

    return 0;
}

๐Ÿ“– Documentation and Examples

Comprehensive documentation for each function, including detailed descriptions, parameter explanations, and practical examples.

๐Ÿ’ฌ Contributions

Contributions are highly appreciated! If you have any ideas for new features, bug fixes, or improvements, please feel free to open an issue or submit a pull request.

๐Ÿ“œ License

StringPy is released under the MIT License. You are free to use, modify, and distribute this library in your own projects.

stringpy's People

Contributors

hun1er avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.