AFLOW
 
Loading...
Searching...
No Matches
aurostd_xoption.h
Go to the documentation of this file.
1// ***************************************************************************
2// * *
3// * Aflow STEFANO CURTAROLO - Duke University 2003-2024 *
4// * *
5// ***************************************************************************
6// Written by Stefano Curtarolo 2013-2014
7// added template<class utype> bool xoption::args2addattachedscheme SC 2017
8
9#ifndef _AUROSTD_XOPTION_H_
10#define _AUROSTD_XOPTION_H_
11
12#include <ostream>
13#include <string>
14#include <vector>
15
16#include <sys/types.h>
17
18// --------------------------------------------------------------------------
19// general flag for xoption to take/manipulate options
20#define aurostd_xoptionONOFF int(-1)
21#define aurostd_xoptionMULTI int(-2)
22
23namespace aurostd {
24 // namespace aurostd
25 class xoption {
26 public:
27 // trivial constructurs/destuctors/operators
28 xoption(); // default, just allocate
29 ~xoption(); // kill everything
30 xoption(const xoption& b); // constructor copy
31 const xoption& operator=(const xoption& b); // copy
32 friend std::ostream& operator<<(std::ostream&, const xoption&); // ostream
33 void clear(); // clear
34 // CONTENT
35 std::string keyword; // the keyword found (we can provide a bunch with |) //CO20180404
36 bool isentry; // is the entry available
37 std::string content_string; // the content
38 double content_double; // the content
39 int content_int; // the content
40 uint content_uint; // the content
41 bool option; // the output
42 bool option_default; // the default
43 std::string xscheme; // the content
44 std::vector<std::string> vxscheme; // tokenized "," content
45 std::vector<std::string> vxsghost; // tokenized "," content
46 bool preserved; // the output
47 // LOAD BOOLS FUNCTIONS
48 void options2entry(const std::string&, const std::string&, int = aurostd_xoptionONOFF, const std::string& xscheme_DEFAULT = ""); // CO20210805 - const&
49 void scheme2scheme(char, const std::string&); // CO20210805 - const&
50 void scheme2scheme(const std::string&, const std::string&); // CO20210805 - const&
51 [[nodiscard]] bool isscheme(const std::string&) const; // check if available //CO20180101 //SC20191227 //CO20210805 - const&
52 uint opscheme(const std::string&, bool); // add/remove scheme then returns vscheme.size() //CO20210805 - const&
53 uint push(const std::string&); // add scheme then returns vscheme.size() //CO20210805 - const&
54 uint pop(const std::string&); // remove scheme then returns vscheme.size() //CO20210805 - const&
55 // for plain flags
56 bool flag(const std::string&, bool); // if bool=true/false => add/remove "string" //CO20210805 - const&
57 [[nodiscard]] bool flag(const std::string&) const; // interrogate=true/false, same as ischeme //CO20180101 //SC20191227 //CO20210805 - const&
58 [[nodiscard]] bool flag() const; // return if there is any scheme inside //CO20180101 //SC20191227
59 // attached stuff..
60 [[nodiscard]] bool isdefined(const std::string&) const; // SC20200114 //CO20210805 - const&
61 uint opattachedscheme(const std::string&, const std::string&, bool); // add/remove attached_scheme if flag=true, then returns vghost.size() //CO20210805 - const&
62 uint addattachedscheme(const std::string& scheme, const std::string& attached, bool flag); // add attached_scheme if flag=true, then returns vghost.size() //CO20210805 - const&
63 uint push_attached(const std::string& scheme, const std::string& attached); // add attached_scheme, then returns vghost.size() - like addattachedscheme with flag=true //CO20210805 - const&
64 uint pop_attached(const std::string& check); // remove attached_scheme, then returns vghost.size() //CO20210805 - const&
65 [[nodiscard]] std::string getattachedscheme(const std::string& scheme) const; // CO20180101
66 template <class utype> [[nodiscard]] utype getattachedutype(const std::string& scheme) const; // CO20200731
67 bool args2addattachedscheme(std::vector<std::string>& argv, const std::string scheme, const std::string& _s_search, std::string string_default);
68 bool args2addattachedscheme(std::vector<std::string>& argv, std::vector<std::string>& cmds, const std::string scheme, const std::string& _s_search, std::string string_default);
69 bool args2addattachedscheme(std::vector<std::string>& argv, const std::string scheme, const std::string& _s_search, const char* string_default);
70 bool args2addattachedscheme(std::vector<std::string>& argv, std::vector<std::string>& cmds, const std::string scheme, const std::string& _s_search, const char* string_default);
71 template <class utype> bool args2addattachedscheme(std::vector<std::string>& argv, const std::string scheme, const std::string& _s_search, utype utype_default);
72 template <class utype> bool args2addattachedscheme(std::vector<std::string>& argv, std::vector<std::string>& cmds, const std::string scheme, const std::string& _s_search, utype utype_default);
73 bool refresh();
74
75 private: //
76 void free(); // free space
77 void copy(const xoption& b); //
78 };
79} // namespace aurostd
80
81// ----------------------------------------------------------------------------
82// ----------------------------------------------------------------------------
83
84#endif // _AUROSTD_XOPTION_H_
85
86// ***************************************************************************
87// * *
88// * Aflow STEFANO CURTAROLO - Duke University 2003-2024 *
89// * *
90// ***************************************************************************
unsigned uint
Definition aurostd.h:39
#define aurostd_xoptionONOFF
void scheme2scheme(const std::string &, const std::string &)
bool flag(const std::string &) const
void options2entry(const std::string &, const std::string &, int=aurostd_xoptionONOFF, const std::string &xscheme_DEFAULT="")
std::string keyword
uint opscheme(const std::string &, bool)
std::vector< std::string > vxscheme
std::string xscheme
uint push_attached(const std::string &scheme, const std::string &attached)
void copy(const xoption &b)
bool flag(const std::string &, bool)
const xoption & operator=(const xoption &b)
bool args2addattachedscheme(std::vector< std::string > &argv, const std::string scheme, const std::string &_s_search, utype utype_default)
bool args2addattachedscheme(std::vector< std::string > &argv, std::vector< std::string > &cmds, const std::string scheme, const std::string &_s_search, const char *string_default)
void scheme2scheme(char, const std::string &)
uint push(const std::string &)
bool args2addattachedscheme(std::vector< std::string > &argv, std::vector< std::string > &cmds, const std::string scheme, const std::string &_s_search, std::string string_default)
std::string content_string
bool args2addattachedscheme(std::vector< std::string > &argv, const std::string scheme, const std::string &_s_search, std::string string_default)
bool isdefined(const std::string &) const
bool isscheme(const std::string &) const
uint pop_attached(const std::string &check)
utype getattachedutype(const std::string &scheme) const
bool args2addattachedscheme(std::vector< std::string > &argv, const std::string scheme, const std::string &_s_search, const char *string_default)
uint opattachedscheme(const std::string &, const std::string &, bool)
uint addattachedscheme(const std::string &scheme, const std::string &attached, bool flag)
friend std::ostream & operator<<(std::ostream &, const xoption &)
uint pop(const std::string &)
bool args2addattachedscheme(std::vector< std::string > &argv, std::vector< std::string > &cmds, const std::string scheme, const std::string &_s_search, utype utype_default)
std::string getattachedscheme(const std::string &scheme) const
std::vector< std::string > vxsghost