10#ifndef _AUROSTD_XOPTION_CPP_
11#define _AUROSTD_XOPTION_CPP_
29#define VERBOSE_XOPTION false
72 for (
size_t i = 0; i < b.
vxscheme.size(); i++) {
76 for (
size_t i = 0; i < b.
vxsghost.size(); i++) {
99 for (
size_t i = 0; i < a.
vxscheme.size(); i++) {
113 void xoption::options2entry(
const string& options_FILE_IN,
const string& input_keyword_IN,
int option_DEFAULT_IN,
const string& xscheme_DEFAULT_IN) {
123 const string options_FILE = options_FILE_IN;
124 const string input_keyword = input_keyword_IN;
125 const int _option_DEFAULT = option_DEFAULT_IN;
126 const string xscheme_DEFAULT = xscheme_DEFAULT_IN;
130 bool option_DEFAULT =
false;
131 if (_option_DEFAULT == 0) {
132 option_DEFAULT =
false;
134 if (_option_DEFAULT == 1) {
135 option_DEFAULT =
true;
144 cerr <<
"DEBUG - " <<
__AFLOW_FUNC__ <<
" input_keyword=\"" << input_keyword <<
"\"" << endl;
145 cerr <<
"DEBUG - " <<
__AFLOW_FUNC__ <<
" option_DEFAULT=" << (option_DEFAULT ?
"true" :
"false") << endl;
146 cerr <<
"DEBUG - " <<
__AFLOW_FUNC__ <<
" xscheme_DEFAULT=\"" << xscheme_DEFAULT <<
"\"" << endl;
150 vector<string> vkeyword;
154 for (
size_t i = 0; i < vkeyword.size(); i++) {
155 cerr <<
"\"" << vkeyword[i] <<
"\"" << endl;
159 if (!vkeyword.empty()) {
162 for (
size_t i = 0; i < vkeyword.size(); i++) {
184 if (_option_DEFAULT == 0 || _option_DEFAULT == 1) {
186 cerr <<
"DEBUG - " <<
__AFLOW_FUNC__ <<
" LOOK FOR ON/OFF MODE WITH strings/schemes" << endl;
190 if (
isentry && xscheme_DEFAULT.empty()) {
198 cerr <<
"DEBUG - " <<
__AFLOW_FUNC__ <<
" found saus=" << saus << endl;
200 vector<string> tokens;
202 for (
size_t i = 0; i < tokens.size(); i++) {
203 if (tokens[i] ==
"ON" || tokens[i][0] ==
'T' || tokens[i][0] ==
't' || tokens[i][0] ==
'1' || tokens[i][0] ==
'Y' || tokens[i][0] ==
'y') {
207 if (tokens[i] ==
"OFF" || tokens[i][0] ==
'F' || tokens[i][0] ==
'f' || tokens[i][0] ==
'0' || tokens[i][0] ==
'N' || tokens[i][0] ==
'n') {
213 if (tokens[i] ==
"REMOVE_RELAX_1") {
216 if (tokens[i] ==
"REMOVE_RELAX_2") {
223 cerr <<
"DEBUG - " <<
__AFLOW_FUNC__ <<
" xscheme_DEFAULT=\"" << xscheme_DEFAULT <<
"\"" << endl;
226 cerr <<
"DEBUG - " <<
__AFLOW_FUNC__ <<
" xscheme_DEFAULT.empty()=" << xscheme_DEFAULT.empty() << endl;
228 if (
isentry && !xscheme_DEFAULT.empty()) {
239 if ((content ==
"OFF") || (content ==
"false") || (content ==
"NO")) {
247 cerr <<
"DEBUG - " <<
__AFLOW_FUNC__ <<
" SCHEME MODE EMPTY DEFAULT STILL EMPTY CONTENT" << endl;
255 if (!
isentry && option_DEFAULT) {
262 vector<string> voptions_FILE;
263 vector<string> vcontent;
267 for (
size_t i = 0; i < voptions_FILE.size(); i++) {
269 vector<string> vstrcheck;
273 for (
size_t j = 0; j < vstrcheck.size(); j++) {
275 cerr <<
"DEBUG - " <<
__AFLOW_FUNC__ <<
" BEFORE keyword=" <<
keyword <<
" " <<
"vstrcheck[j]=" << vstrcheck[j] << endl;
278 if (vstrcheck[j] ==
"A") {
279 vstrcheck[j] =
"AUTO";
281 if (vstrcheck[j] ==
"G") {
282 vstrcheck[j] =
"GAMMA";
284 if (vstrcheck[j] ==
"M") {
285 vstrcheck[j] =
"MONKHORST_PACK";
292 if (vstrcheck[j] ==
"SPRIM") {
293 vstrcheck[j] =
"STANDARD_PRIMITIVE";
295 if (vstrcheck[j] ==
"STD_PRIM") {
296 vstrcheck[j] =
"STANDARD_PRIMITIVE";
298 if (vstrcheck[j] ==
"STANDARD_PRIMITIVE") {
299 vstrcheck[j] =
"STANDARD_PRIMITIVE";
301 if (vstrcheck[j] ==
"SCONV") {
302 vstrcheck[j] =
"STANDARD_CONVENTIONAL";
304 if (vstrcheck[j] ==
"STD_CONV") {
305 vstrcheck[j] =
"STANDARD_CONVENTIONAL";
307 if (vstrcheck[j] ==
"STANDARD_CONVENTIONAL") {
308 vstrcheck[j] =
"STANDARD_CONVENTIONAL";
310 if (vstrcheck[j] ==
"NIGGLI") {
311 vstrcheck[j] =
"NIGGLI";
313 if (vstrcheck[j] ==
"MINK") {
314 vstrcheck[j] =
"MINKOWSKI";
316 if (vstrcheck[j] ==
"MINKOWSKI") {
317 vstrcheck[j] =
"MINKOWSKI";
319 if (vstrcheck[j] ==
"INCELL") {
320 vstrcheck[j] =
"INCELL";
322 if (vstrcheck[j] ==
"COMPACT") {
323 vstrcheck[j] =
"COMPACT";
325 if (vstrcheck[j] ==
"INCOMPACT") {
326 vstrcheck[j] =
"COMPACT";
328 if (vstrcheck[j] ==
"INWIGNERSEITZ") {
329 vstrcheck[j] =
"WIGNERSEITZ";
331 if (vstrcheck[j] ==
"WS") {
332 vstrcheck[j] =
"WIGNERSEITZ";
334 if (vstrcheck[j] ==
"WIGNERSEITZ") {
335 vstrcheck[j] =
"WIGNERSEITZ";
337 if (vstrcheck[j] ==
"C") {
338 vstrcheck[j] =
"CARTESIAN";
340 if (vstrcheck[j] ==
"CART") {
341 vstrcheck[j] =
"CARTESIAN";
343 if (vstrcheck[j] ==
"CARTESIAN") {
344 vstrcheck[j] =
"CARTESIAN";
346 if (vstrcheck[j] ==
"F") {
347 vstrcheck[j] =
"FRACTIONAL";
349 if (vstrcheck[j] ==
"FRAC") {
350 vstrcheck[j] =
"FRACTIONAL";
352 if (vstrcheck[j] ==
"FRACTIONAL") {
353 vstrcheck[j] =
"FRACTIONAL";
355 if (vstrcheck[j] ==
"D") {
356 vstrcheck[j] =
"DIRECT";
358 if (vstrcheck[j] ==
"DIR") {
359 vstrcheck[j] =
"DIRECT";
361 if (vstrcheck[j] ==
"DIRECT") {
362 vstrcheck[j] =
"DIRECT";
364 if (vstrcheck[j] ==
"PRE") {
365 vstrcheck[j] =
"PRESERVE";
367 if (vstrcheck[j] ==
"PRES") {
368 vstrcheck[j] =
"PRESERVE";
370 if (vstrcheck[j] ==
"PRESERVE") {
371 vstrcheck[j] =
"PRESERVE";
375 cerr <<
"DEBUG - " <<
__AFLOW_FUNC__ <<
" AFTER keyword=" <<
keyword <<
" " <<
"vstrcheck[j]=" << vstrcheck[j] << endl;
377 vcontent.push_back(vstrcheck[j]);
381 for (
size_t i = 0; i < vcontent.size(); i++) {
382 content_string += vcontent[i] + (i < vcontent.size() - 1 ?
"," :
"");
386 if (!vcontent.empty()) {
398 for (
size_t i = 0; i <
vxscheme.size(); i++) {
433 stringstream message;
445 for (
size_t i = 0; i <
vxscheme.size(); i++) {
453 for (
size_t i = 0; i <
vxscheme.size(); i++) {
468 for (
size_t i = 0; i <
vxscheme.size(); i++) {
502 for (
size_t i = 0; i <
vxscheme.size(); i++) {
523 if (operation ==
true) {
525 cerr <<
"DEBUG - aurostd::xoption::opscheme: ADD=" <<
aurostd::toupper(_xscheme) << endl;
528 for (
size_t i = 0; i <
vxscheme.size(); i++) {
529 cerr <<
"DEBUG - aurostd::xoption::opscheme: ADD_BEFORE vxscheme.at(" << i <<
")=" <<
vxscheme.at(i) << endl;
533 for (
size_t i = 0; i <
vxscheme.size(); i++) {
541 for (
size_t i = 0; i <
vxscheme.size(); i++) {
542 cerr <<
"DEBUG - aurostd::xoption::opscheme: ADD_BEFORE vxscheme.at(" << i <<
")=" <<
vxscheme.at(i) << endl;
547 cerr <<
"DEBUG - aurostd::xoption::opscheme: PURGE=" <<
aurostd::toupper(_xscheme) << endl;
550 for (
size_t i = 0; i <
vxscheme.size(); i++) {
551 cerr <<
"DEBUG - aurostd::xoption::opscheme: PURGE_BEFORE vxscheme.at(" << i <<
")=" <<
vxscheme.at(i) << endl;
556 for (
size_t i = 0; i < _vxscheme.size(); i++) {
562 for (
size_t i = 0; i <
vxscheme.size(); i++) {
563 cerr <<
"DEBUG - aurostd::xoption::opscheme: PURGE_AFTER vxscheme.at(" << i <<
")=" <<
vxscheme.at(i) << endl;
602 for (
size_t i = 0; i <
vxsghost.size(); i += 2) {
618 for (
size_t i = 0; i <
vxsghost.size() - 1; i += 2) {
631#define AST_TEMPLATE(utype) template utype xoption::getattachedutype(const string&) const;
638 if (operation ==
true) {
640 cerr <<
"DEBUG - aurostd::xoption::opattachedscheme: ADD=" <<
aurostd::toupper(_xscheme) << endl;
643 cerr <<
"DEBUG - aurostd::xoption::opattachedscheme: GHOST=" << attached << endl;
646 for (
size_t i = 0; i <
vxsghost.size(); i += 2) {
656 cerr <<
"DEBUG - aurostd::xoption::opattachedscheme: PURGE=" <<
aurostd::toupper(_xscheme) << endl;
660 for (
size_t i = 0; i < _vxsghost.size(); i += 2) {
663 vxsghost.push_back(_vxsghost.at(i + 1));
667 for (
size_t i = 0; i <
vxsghost.size(); i++) {
668 cerr <<
"PURGEATTACHED_AFTER vxsghost.at(" << i <<
")=" <<
vxsghost.at(i) << endl;
696 bool xoption::args2addattachedscheme(vector<string>& argv, vector<string>& cmds,
const string xscheme,
const string& _s_search,
string string_default) {
698 string s_search(_s_search);
703 cerr <<
"DEBUG - aurostd::xoption::args2addscheme: xscheme=" <<
xscheme <<
" s_search=" << s_search <<
" attached=" <<
aurostd::args2attachedstring(argv, s_search, string_default) << endl;
713 cerr <<
"DEBUG - aurostd::xoption::args2addscheme: xscheme=" <<
xscheme <<
" s_search=" << s_search <<
" taking=" <<
aurostd::args2string(argv, s_search, string_default) << endl;
724 bool xoption::args2addattachedscheme(vector<string>& argv, vector<string>& cmds,
const string xscheme,
const string& _s_search,
const char* string_default) {
This file contains the preprocessor macros to ensure a proper instantiation of all aurostd functions.
#define AST_GEN_1(type_selection)
autogenerate 1D code based on AST_TEMPLATE
#define aurostd_xoptionONOFF
#define aurostd_xoptionMULTI
void options2entry(const std::string &, const std::string &, int=aurostd_xoptionONOFF, const std::string &xscheme_DEFAULT="")
uint opscheme(const std::string &, bool)
std::vector< std::string > vxscheme
uint push_attached(const std::string &scheme, const std::string &attached)
void copy(const xoption &b)
const xoption & operator=(const xoption &b)
void scheme2scheme(char, const std::string &)
uint push(const std::string &)
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
uint opattachedscheme(const std::string &, const std::string &, bool)
uint addattachedscheme(const std::string &scheme, const std::string &attached, bool flag)
uint pop(const std::string &)
std::string getattachedscheme(const std::string &scheme) const
std::vector< std::string > vxsghost
void StringSubstInPlace(string &work_string, const string &old_string, const string &new_string)
substitute parts of a strings in place
uint string2tokens(const string &str, vector< string > &tokens, const string &delimiters=" ", bool consecutive=false) __xprototype
utype string2utype(const string &from, const uint base=10)
bool args2flag(const vector< string > &argv, const string &s0)
string utype2string(const utype &from, int precision=AUROSTD_DEFAULT_PRECISION, char FORMAT=DEFAULT_STREAM) __xprototype
size_t string2vectorstring(const string &stringIN, vector< string > &vstringout, bool consecutive=false, bool trim_edges=false)
string args2string(const vector< string > &argv, const string &s0, const string &s_def)
string substring2string(ifstream &input, const string &strsub1, const int instance=1, bool RemoveWS=false, bool RemoveComments=true)
string tolower(const string &in) __xprototype
bool args2attachedflag(const vector< string > &argv, const string &s0)
string toupper(const string &in) __xprototype
string args2attachedstring(const vector< string > &argv, const string &s0, string s_def)
b64_encoder_proxy operator<<(std::ostream &os, b64_encoder_creator)
string RemoveWhiteSpaces(const string &s) __xprototype
bool substring2bool(const string &strstream, const string &strsub1, bool RemoveWS=false, bool RemoveComments=true)