osuplusplus/include/string_util.hpp
jacekpoz b978fb2288
fix pretty much everything, read description
this is a big (or dare I say, huge) commit that pretty much fixes every
problem I've had so far with the basic parsing

I still need to do a custom operator>> for some types but at this point
the parser goes through the entire file and prints out everything which
is a large milestone I'd say

changes in this commit:
- add SECTION_LIST for a section containing a single list of values
  examples: TimingPoints, HitObjects
- improve operator>> for enums making it accept int values and fail
  properly when the value is incorrect (there's a warning I need to get
  rid of but it's ok for now)
- skip over blank lines: adding this single line (src/osuparser.cpp:52)
  made the parser go from shitting itself to actually going through the
  whole file and printing everything (with some errors but still)
- new string util: isBlank() used for the above
- new __VA_ARGS__ util: ARG_COUNT() and rename foreach.hpp to
  va_args_util.hpp as that name no longer fits
2024-04-26 19:05:35 +02:00

24 lines
624 B
C++

#pragma once
#ifndef PP_DEBUG
#include <algorithm>
#include <string>
#endif
inline void toLower(std::string &str) {
std::transform(str.begin(), str.end(), str.begin(),
[](unsigned char c){ return std::tolower(c); });
}
inline void toUpper(std::string &str) {
std::transform(str.begin(), str.end(), str.begin(),
[](unsigned char c){ return std::toupper(c); });
}
inline bool isInt(const std::string &str) {
return str.find_first_not_of("1234567890") == std::string::npos;
}
inline bool isBlank(const std::string &str) {
return str.find_first_not_of(" \n\t\v\r\f") == std::string::npos;
}