#pragma once #ifndef _NB_STRING_UTILS #define _NB_STRING_UTILS #include #include #include #include "TypeTraits.hpp" namespace nb { #ifdef _NB_TARGET_WINDOWS const std::string NEWLINE = "\n"; const std::wstring WNEWLINE = L"\n"; #endif // _NB_TARGET_WINDOWS #ifdef _NB_TARGET_LINUX const std::string NEWLINE = "\n"; const std::wstring WNEWLINE = L"\n"; #endif // _NB_TARGET_LINUX const std::string TABOVER = " "; // std::wstring str_to_wstr(std::string in); // std::string wstr_to_str(std::wstring in); template void stream(const Stream& s, Args&&... args); template void stream(const Stream& s, Args&&... args) { (s << ... << args); } template void term(Args&&... args) { stream(std::cout, args..., nb::NEWLINE); } template void wterm(Args&&... args) { stream(std::wcout, args..., nb::WNEWLINE); } template std::basic_string find_and_replace( ExplicitType_t> original, ExplicitType_t> find, ExplicitType_t> replace ) { using StringType = std::basic_string; StringType ret(original); std::size_t find_len = find.length(); std::size_t replace_len = replace.length(); std::size_t currpos = 0; while(true) { currpos = ret.find(find, currpos); if (currpos == StringType::npos) { break; } ret = ret.erase(currpos, find_len); ret = ret.insert(currpos, replace); currpos += replace_len; } return ret; } std::string indent_strblock( std::string block, std::string prepend, std::string topIndent ); std::string indent_strblock( std::string block, std::string prepend ); } // namespace nb #endif // _NB_STRING_UTILS