4 #ifndef OPENVDB_UTIL_NAME_HAS_BEEN_INCLUDED 5 #define OPENVDB_UTIL_NAME_HAS_BEEN_INCLUDED 8 #include <openvdb/version.h> 25 is.read(reinterpret_cast<char*>(&size),
sizeof(uint32_t));
26 std::string buffer(size,
' ');
27 if (size>0) is.read(&buffer[0], size);
35 uint32_t size = uint32_t(name.size());
36 os.write(reinterpret_cast<char*>(&size),
sizeof(uint32_t));
37 os.write(&name[0], size);
42 template <
typename ContainerT>
43 inline void split(ContainerT& out,
const std::string& in,
const char delim)
46 if (in.empty())
return;
47 std::string::size_type pos = 0u, old = 0u;
48 while ((pos = in.find(delim, pos)) != std::string::npos) {
49 out.insert(out.end(), in.substr(old, (pos-old)));
53 out.insert(out.end(), in.substr(old, in.length()-old));
56 template <
typename ContainerT>
57 inline void split(ContainerT& out,
const std::string& in,
const std::set<char>& delims)
60 if (in.empty())
return;
61 std::string::size_type pos = 0u, old = 0u;
62 const std::string seq(delims.begin(), delims.end());
63 while ((pos = in.find_first_of(seq, pos)) != std::string::npos) {
64 out.insert(out.end(), in.substr(old, (pos-old)));
68 out.insert(out.end(), in.substr(old, in.length()-old));
71 inline bool starts_with(
const std::string& in,
const std::string& start)
73 if (start.length() > in.length())
return false;
74 return std::equal(start.begin(), start.end(), in.begin());
77 inline bool ends_with(
const std::string& in,
const std::string& end)
79 if (end.length() > in.length())
return false;
80 return std::equal(end.rbegin(), end.rend(), in.rbegin());
83 inline void trim(std::string& s)
86 s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](
int ch) {
87 return !std::isspace(ch);
91 s.erase(std::find_if(s.rbegin(), s.rend(), [](
int ch) {
92 return !std::isspace(ch);
98 std::transform(s.begin(), s.end(), s.begin(),
99 [](
auto c){
return std::tolower(c); });
107 #endif // OPENVDB_UTIL_NAME_HAS_BEEN_INCLUDED Name readString(std::istream &is)
Definition: Name.h:22
void writeString(std::ostream &os, const Name &name)
Definition: Name.h:33
void to_lower(std::string &s)
Definition: Name.h:96
void split(ContainerT &out, const std::string &in, const std::set< char > &delims)
Definition: Name.h:57
bool ends_with(const std::string &in, const std::string &end)
Definition: Name.h:77
Definition: Exceptions.h:13
std::string Name
Definition: Name.h:19
void trim(std::string &s)
Definition: Name.h:83
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
bool starts_with(const std::string &in, const std::string &start)
Definition: Name.h:71
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:212