C++ I wrote a simple and fast formatting library for strings

C++ FString

A quick C++ formatting library

I was working on a logging library, and needed some way to format strings quickly, simple and clean, so I wrote this library.

This library is not the best in general, but for my project needs it i…


This content originally appeared on DEV Community and was authored by Maysara

C++ FString

A quick C++ formatting library

I was working on a logging library, and needed some way to format strings quickly, simple and clean, so I wrote this library.

This library is not the best in general, but for my project needs it is the fastest and the best

Features

  • Easy include and just call fstring()
  • Fast Just a simple code to extract and modify the string
  • Light No lots of code, just one class with only one function to call
  • CrossPlatform It doesn't use any third party libraries, so it should work anywhere

Syntax

// parameters
fstring("{}, {}", "Hello","World"); // "Hello, World"

// padding
fstring("%5Hello%5World%5"); // "     Hello     World     "

// smart padding, divide string to sections, final padding = padding - length of section
fstring("%.10Hello.%%.10World.%"); // "Hello     World     "

// result
fstring(..).get(); // return to &string

Target

  • Providing an easy, fast and clean way to format strings

  • Providing the best performance for millions of times use

Test Info

  • OS: Ubuntu 22.04 LTS / 64-bit
  • Processor: Intel® Core™ i7-6500U CPU @ 2.50GHz × 4
  • Compiler: g++ 12
  • Flags: -O3
  • C++ Version: 23

Questions

  • Is there anything that could be improved?
  • Are there errors?
  • Do you have any tips or comments?

Updates / Edits

i will add edits or updates here

Code (GitHub)

#c #cpp


This content originally appeared on DEV Community and was authored by Maysara


Print Share Comment Cite Upload Translate Updates
APA

Maysara | Sciencx (2022-07-08T18:41:01+00:00) C++ I wrote a simple and fast formatting library for strings. Retrieved from https://www.scien.cx/2022/07/08/c-i-wrote-a-simple-and-fast-formatting-library-for-strings/

MLA
" » C++ I wrote a simple and fast formatting library for strings." Maysara | Sciencx - Friday July 8, 2022, https://www.scien.cx/2022/07/08/c-i-wrote-a-simple-and-fast-formatting-library-for-strings/
HARVARD
Maysara | Sciencx Friday July 8, 2022 » C++ I wrote a simple and fast formatting library for strings., viewed ,<https://www.scien.cx/2022/07/08/c-i-wrote-a-simple-and-fast-formatting-library-for-strings/>
VANCOUVER
Maysara | Sciencx - » C++ I wrote a simple and fast formatting library for strings. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/07/08/c-i-wrote-a-simple-and-fast-formatting-library-for-strings/
CHICAGO
" » C++ I wrote a simple and fast formatting library for strings." Maysara | Sciencx - Accessed . https://www.scien.cx/2022/07/08/c-i-wrote-a-simple-and-fast-formatting-library-for-strings/
IEEE
" » C++ I wrote a simple and fast formatting library for strings." Maysara | Sciencx [Online]. Available: https://www.scien.cx/2022/07/08/c-i-wrote-a-simple-and-fast-formatting-library-for-strings/. [Accessed: ]
rf:citation
» C++ I wrote a simple and fast formatting library for strings | Maysara | Sciencx | https://www.scien.cx/2022/07/08/c-i-wrote-a-simple-and-fast-formatting-library-for-strings/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.