NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
string.hpp File Reference

Contains various utility functions for working with strings. More...

#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include <string_view>
#include <vector>
#include "NNL/common/contract.hpp"

Go to the source code of this file.

Namespaces

namespace  nnl
namespace  nnl::utl::string
 Contains various utility functions for working with strings.

Functions

template<typename T>
std::string nnl::utl::string::PrependZero (T num, std::size_t digits=2)
 Converts a number to a string padded with zero's.
bool nnl::utl::string::EndsWith (std::string_view str, std::string_view suffix)
 Checks if a string ends with a specific suffix.
bool nnl::utl::string::StartsWith (std::string_view str, std::string_view prefix)
 Checks if a string starts with a specific prefix.
std::string nnl::utl::string::Join (const std::vector< std::string > &strings, std::string delim=",")
 Joins a container of strings into one string using a delimiter.
std::vector< std::string > nnl::utl::string::Split (std::string_view str, std::string delim=",")
 Splits a string by delimiter.
std::string nnl::utl::string::Truncate (std::string_view str, std::size_t n)
 Truncates a string to specified length.
std::string nnl::utl::string::FloatToString (float value, int n=6)
 Converts a float value to a string with fixed precision.
template<typename T>
std::string nnl::utl::string::IntToHex (T i, bool prefix=false, bool prepend=true)
 Converts an integer to a hexadecimal string.
std::string nnl::utl::string::ToLower (std::string_view str)
 Converts a string to lowercase.
bool nnl::utl::string::CompareNat (std::string_view a, std::string_view b)
 Performs natural string comparison for sorting.

Detailed Description

Contains various utility functions for working with strings.