cgv
Loading...
Searching...
No Matches
options.cxx
1#include "options.h"
2#include "scan.h"
3#include "advanced_scan.h"
4
5namespace cgv {
6 namespace utils {
7
8 bool has_option(const std::string& option)
9 {
10 std::vector<std::string> options;
11 enumerate_options(options);
12 for (auto o : options)
13 if (to_upper(o) == to_upper(option))
14 return true;
15 return false;
16
17 }
18 void enumerate_options(std::vector<std::string>& options)
19 {
20 char* cgv_options = getenv("CGV_OPTIONS");
21 if (cgv_options) {
22 std::vector<cgv::utils::token> toks;
23 std::string option_str(cgv_options);
24 split_to_tokens(option_str, toks, ";", true, "", "", "");
25 for (auto tok : toks)
26 options.push_back(to_string(tok));
27 }
28 }
29 }
30}
More advanced text processing for splitting text into lines or tokens.
void split_to_tokens(const char *begin, const char *end, std::vector< token > &tokens, const std::string &separators, bool merge_separators, const std::string &open_parenthesis, const std::string &close_parenthesis, const std::string &whitespaces, unsigned int max_nr_tokens)
this function splits a text range into tokens.
std::string to_string(const std::string &v, unsigned int w, unsigned int p, bool)
specialization of conversion from string to strings
char to_upper(char c)
convert char to upper case
Definition scan.cxx:106
bool has_option(const std::string &option)
check whether the system variable CGV_OPTIONS contains the given option (the comparison is case insen...
Definition options.cxx:8
void enumerate_options(std::vector< std::string > &options)
push back all options provided in the CGV_OPTIONS system variable
Definition options.cxx:18
the cgv namespace
Definition print.h:11
Helper functions to access cgv options provided in the CGV_OPTIONS environment variable.
Helper functions to process strings.