PolyFEM
Loading...
Searching...
No Matches
StringUtils.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <string>
5
6namespace polyfem
7{
8 namespace utils
9 {
10 namespace StringUtils
11 {
12
13 // Split a string into tokens
14 std::vector<std::string> split(const std::string &str, const std::string &delimiters = " ");
15
16 // Skip comments in a stream
17 std::istream &skip(std::istream &in, char x = '#');
18
19 // Tests whether a string starts with a given prefix
20 bool startswith(const std::string &str, const std::string &prefix);
21
22 // Tests whether a string ends with a given suffix
23 bool endswith(const std::string &str, const std::string &suffix);
24
25 // Replace extension after the last "dot"
26 std::string replace_ext(const std::string &filename, const std::string &newext);
27
28 // Trims a string
29 std::string trim(const std::string &string);
30
31 } // namespace StringUtils
32
33 std::string resolve_path(
34 const std::string &path,
35 const std::string &input_file_path,
36 const bool only_if_exists = false);
37 } // namespace utils
38} // namespace polyfem
int x
std::istream & skip(std::istream &in, char x='#')
std::string trim(const std::string &string)
bool startswith(const std::string &str, const std::string &prefix)
std::vector< std::string > split(const std::string &str, const std::string &delimiters=" ")
bool endswith(const std::string &str, const std::string &suffix)
std::string replace_ext(const std::string &filename, const std::string &newext)
std::string resolve_path(const std::string &path, const std::string &input_file_path, const bool only_if_exists=false)