File indexing completed on 2026-04-09 07:49:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #pragma once
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #include <cstddef>
0034 #include <string>
0035 #include <vector>
0036 #include <array>
0037 #include <glm/fwd.hpp>
0038 #include "plog/Severity.h"
0039
0040
0041 #include "SYSRAP_API_EXPORT.hh"
0042
0043 class SYSRAP_API SStr {
0044
0045 typedef unsigned long long ULL ;
0046
0047 public:
0048 static const plog::Severity LEVEL ;
0049 static void Save(const char* path, const std::vector<std::string>& a, char delim='\n' );
0050 static void Save(const char* path_, const char* txt );
0051 static const char* Load(const char* path_ );
0052 static void LoadList(const char* path, std::vector<std::string>& lines, char delim='\n' ) ;
0053 static std::vector<std::string>* LoadList( const char* arg, char delim='\n' );
0054 public:
0055 static void FillFromULL( char* dest, unsigned long long value, char unprintable='.') ;
0056 static const char* FromULL(unsigned long long value, char unprintable='.');
0057 static unsigned long long ToULL(const char* s8 );
0058
0059
0060 template <size_t SIZE>
0061 static const char* Format1( const char* fmt, const char* value );
0062
0063 template <size_t SIZE>
0064 static const char* Format2( const char* fmt, const char* value1, const char* value2 );
0065
0066 template <size_t SIZE>
0067 static const char* Format3( const char* fmt, const char* value1, const char* value2, const char* value3 );
0068
0069
0070 template <size_t SIZE>
0071 static const char* FormatInt( const char* fmt, int value );
0072
0073
0074 static const char* FormatIndex( int idx, bool prefix=false, int wid=3 );
0075
0076
0077 template<typename T>
0078 static const char* FormatReal(const T value, int w, int p, char fill='0' ) ;
0079
0080 static bool Blank(const char* s );
0081 static bool All(const char* s, char q );
0082 static unsigned Count(const char* s, char q );
0083
0084 static bool Contains(const char* s, const char* q );
0085 static bool EndsWith( const char* s, const char* q);
0086 static bool StartsWith( const char* s, const char* q);
0087
0088 static const char* AZaz ;
0089 static bool StartsWithLetterAZaz(const char* q );
0090
0091 static bool SimpleMatch(const char* s, const char* q );
0092 static bool Match(const char* s, const char* q);
0093
0094 static const char* StripPrefix_(const char* s, const char* pfx0 );
0095 static const char* StripPrefix(const char* s, const char* pfx0, const char* pfx1=nullptr, const char* pfx2=nullptr );
0096 static const char* MaterialBaseName(const char* s ) ;
0097
0098
0099 static bool HasPointerSuffix( const char* name, unsigned hexdigits ) ;
0100 static bool HasPointerSuffix( const char* name, unsigned min_hexdigits, unsigned max_hexdigits ) ;
0101 static int GetPointerSuffixDigits( const char* name );
0102 static const char* TrimPointerSuffix( const char* name );
0103
0104 static const char* TrimLeading(const char* s);
0105 static const char* TrimTrailing(const char* s);
0106 static const char* Trim(const char* s);
0107
0108 static const char* HeadFirst(const char* s, char c);
0109 static const char* HeadLast( const char* s, char c);
0110
0111 static const char* Concat( const char* a, const char* b, const char* c=NULL );
0112 static const char* Concat( const char* a, unsigned b , const char* c=NULL );
0113 static const char* Concat( const char* a, unsigned b, const char* c, unsigned d, const char* e ) ;
0114
0115 template <typename T>
0116 static const char* Concat_( const char* a, T b , const char* c );
0117
0118
0119
0120
0121 static const char* Replace( const char* s, char a, char b );
0122 static const char* ReplaceEnd( const char* s, const char* q, const char* r );
0123
0124 static void Split( const char* str, char delim, std::vector<std::string>& elem ) ;
0125 static int ISplit( const char* line, std::vector<int>& ivec, char delim ) ;
0126 static std::vector<int>* ISplit( const char* line, char delim );
0127
0128
0129 static void ParseGridSpec( std::array<int,9>& grid, const char* spec);
0130 static void DumpGrid( const std::array<int,9>& grid ) ;
0131
0132
0133 static void GetEVec(glm::vec3& v, const char* key, const char* fallback );
0134 static void GetEVec(glm::vec4& v, const char* key, const char* fallback );
0135
0136 template <typename T>
0137 static void GetEVector(std::vector<T>& vec, const char* key, const char* fallback );
0138
0139 template <typename T>
0140 static std::string Present(std::vector<T>& vec);
0141
0142
0143
0144
0145 static void GridMinMax( const std::array<int,9>& grid, int& mn, int& mx ) ;
0146 static void GridMinMax( const std::array<int,9>& grid, glm::ivec3& mn, glm::ivec3& mx) ;
0147
0148 static unsigned Encode4(const char* s);
0149
0150 template <typename T>
0151 static T ato_( const char* a );
0152
0153 template <typename T>
0154 static T GetEValue(const char* key, T fallback);
0155
0156
0157 static int AsInt(const char* arg, int fallback=-1 ) ;
0158 static int ExtractInt(const char* arg, int start, unsigned num, int fallback=-1) ;
0159
0160
0161 static const char* ReplaceChars(const char* str, const char* repl="(),[]", char to=' ') ;
0162
0163 static long ExtractLong( const char* s, long fallback );
0164 static void Extract( std::vector<long>& vals, const char* s );
0165 static void Extract_( std::vector<long>& vals, const char* s );
0166 static void Extract_( std::vector<float>& vals, const char* s );
0167
0168 static int ekv_split( std::vector<std::pair<std::string, std::string> > & ekv, const char* line_, char edelim, char kvdelim);
0169
0170 template<typename ... Args>
0171 static std::string Format_( const char* fmt, Args ... args );
0172
0173 template<typename ... Args>
0174 static const char* Format( const char* fmt, Args ... args );
0175
0176
0177
0178
0179
0180 static const char* ParseStringIntInt( const char* triplet, int& y, int& z, char delim=':' );
0181 };
0182
0183
0184