16 const char *
nWord(
const char *chKey,
99 uniqueLen = s2.length();
101 uniqueLen = p->second;
106 void setline(
const string& card);
111 const char *
nWord(
const char *chKey)
const;
115 long int GetElem(
void )
const;
142 for (
const char *q=p; *q; ++q)
147 const char *c =
m_card.c_str();
176 bool GetRange(
const char *chKey,
double *val1,
double *val2)
192 bool found = (i != 0);
195 const long len = strlen(p);
197 for (
long j=0; j<len; ++j)
215 bool isVar(
void)
const;
218 void echo(
void)
const;
219 bool last(
void)
const;
236 void help(FILE *fp)
const;
242 void getPairs(vector<double>& a, vector<double> & b);
243 void readList(vector<string>& list,
const char *chName);
332 return (
p_line[0] ==
'#' );
342 for(
size_t i=0; i <
p_line.length(); ++i )
344 if( i > 0 &&
p_line[i] ==
'#' )
346 else if( !isspace(
p_line[i]) )
354 long p =
p_ls.tellg();
364 if( p >=
p_line.length() )
365 p_ls.setstate(ios_base::eofbit);
372 char c =
p_ls.peek();
380 return ( c ==
'=' || c ==
',' );
385 bool lgModified =
false;
386 for(
size_t i=0; i <
p_line.length(); ++i )
427 void checkMagic(
long i0,
long i1,
long i2,
long i3);
443 else if( !isspace(
p_ls.peek()) && !
p_ls.eof() )
444 errorAbort(
"found trailing junk after token");
455 "Reading C-style strings is not supported, use C++ strings instead." );
456 for(
size_t i=0; i < n; ++i )
477 "Reading C-style strings is not supported, use C++ strings instead." );
478 for(
size_t i=0; i < n; ++i )
487 else if( !isspace(
p_ls.peek()) && !
p_ls.eof() )
488 errorAbort(
"found trailing junk after token");
517 errorAbort(
"skipping to requested position failed");
524 auto p =
p_line.substr(cp).find(s);
525 if( p != string::npos )
526 skipTo(cp + p + s.length());
530 oss <<
"skipAfter could not find string =" << s <<
"=";
546 errorAbort(
"found trailing junk at the end of this line");
556 errorAbort(
"found surplus input at the end of this file");
580 template <
typename V>
588 const char *
key(
void)
const
599 template <
typename V>
620 template <
typename T,
typename V>
623 bool lgFound =
false;
624 for (
unsigned long option=0; option < nlist; ++option)
626 if( p.
nWord( list[option].key() ) )
628 list[option]( value );
665 ostringstream& chHeader,
672 ostringstream& chHeader);
676 ostringstream& chHeader);
924 vector< pair<string, shared_ptr<Option> > >
p;
bool lgEOF() const
Definition: parser.h:549
void checkEOD()
Definition: parser.h:553
void Parse_Save_Line_RT(Parser &p)
Definition: save_line.cpp:207
void setEOL(bool val)
Definition: parser.h:129
bool nMatch(const char *chKey) const
Definition: parser.h:163
void parse_save_average(Parser &p, long int ipPun, ostringstream &chHeader)
Definition: save_average.cpp:11
const realnum m_unit
Definition: parser.h:608
void(* OptionParser)(Parser &)
Definition: parser.h:23
void getTokenOptionalImpl(istringstream &iss, const string &, T &var)
Definition: parser.h:249
STATIC long int ipPun
Definition: save_do.cpp:368
void echo(void) const
Definition: parser.cpp:194
void ParseCosmology(Parser &p)
Definition: parse_cosmology.cpp:9
bool peekNextCommand(const string &s2)
Definition: parser.cpp:847
double FFmtRead(void)
Definition: parser.cpp:487
#define NORETURN
Definition: cpu.h:461
void ParseIonParX(Parser &p)
Definition: parse_ionpar.cpp:15
NORETURN void TotalInsanity(void)
Definition: service.cpp:1174
void setline(const string &card)
Definition: parser.cpp:287
void getToken(T &var)
Definition: parser.h:465
Option(double val)
Definition: parser.h:905
double getNumberCheckLogLinNegImplLog(const char *chDesc)
Definition: parser.cpp:425
Parser(void)
Definition: parser.h:56
bool m_lgEOL
Definition: parser.h:48
bool Command(const char *name, OptionParser doOpts)
Definition: parser.h:206
long int m_nqh
Definition: parser.h:53
void ParseDatabaseH2(Parser &p)
Definition: parse_atom_h2.cpp:10
void operator()(realnum *t) const
Definition: parser.h:612
void readList(vector< string > &list, const char *chName)
Definition: parser.cpp:1112
Properties()
Definition: parser.h:925
eod_style p_es
stream for reading data file
Definition: parser.h:316
void ParseRangeOption(Parser &p)
Definition: parse_rangeoption.cpp:8
bool lgReachedEnd()
Definition: parser.cpp:114
size_t getTokenOptional(T var[], size_t n)
Definition: parser.h:450
string p_filename
Definition: parser.h:314
long nMatch(const char *chKey, const char *chCard)
Definition: service.cpp:728
void ParseLineList(Parser &p, vector< LineID > &lines)
Definition: prt_linesum.cpp:14
void skip_whitespace()
Definition: parser.cpp:45
int GetQuote(string &chLabel)
Definition: parser.cpp:218
access_scheme
Definition: cpu.h:257
void getQuote(string &str)
Definition: parser.h:493
bool getTokenOptional(T &var)
Definition: parser.h:438
bool at_end() const
Definition: parser.cpp:37
Symbol(enum tokens t, const string &v)
Definition: parser.h:37
void newlineProcess()
Definition: parser.cpp:50
double getNumberDefaultAlwaysLog(const char *chDesc, double fdef)
Definition: parser.cpp:461
bool nMatchErase(const char *chKey)
Definition: parser.h:186
void ParseHDEN(Parser &p)
Definition: parse_hden.cpp:10
void insertToken(trieNode *root, const string &token)
Definition: thirdparty.cpp:5129
void setline(const string &line)
Definition: parser.h:431
LineID getLineID(bool lgAtStart=true)
Definition: parser.cpp:599
long int m_off
Definition: parser.h:47
void ParseElement(Parser &p)
Definition: parse_element.cpp:17
void ParseTest(Parser &p)
Definition: parse_test.cpp:20
eod_style
Definition: parser.h:311
bool parserProcess(Parser &p, T *list, unsigned long nlist, V *value)
Definition: parser.h:621
FILE * ioQQQ
Definition: cddefines.cpp:7
void parse_save_line(Parser &p, bool lgLog3, ostringstream &chHeader, long int ipPun)
double getWave()
Definition: parser.cpp:394
string s
Definition: parser.h:894
size_t p_pos()
Definition: parser.h:352
void FPRead(istringstream &iss, const string &s, double &value)
Definition: service.cpp:548
const char * name
Definition: parser.h:26
bool lgEODMarker() const
Definition: parser.cpp:1447
Symbol getSymbol()
Definition: parser.cpp:987
void ParseRadius(Parser &p)
Definition: parse_radius.cpp:13
int getElement()
Definition: parser.cpp:899
size_t p_nr
the current line being read
Definition: parser.h:318
bool isBoundaryChar(char c)
Definition: parser.cpp:135
NORETURN void StringError() const
Definition: parser.cpp:208
double getNumberPlain(const char *chDesc)
Definition: parser.cpp:403
bool m_lgDone
Definition: parser.h:922
bool isDone() const
Definition: parser.h:930
void lines(void)
Definition: prt_lines.cpp:56
void ParseCaseB(Parser &p)
Definition: parse_caseb.cpp:9
void ParseGrain(Parser &p)
Definition: parse_grain.cpp:12
void rewind()
Definition: parser.h:563
string ClosestMatch(const string &token) const
Definition: parser.cpp:862
void p_skipWS()
Definition: parser.h:368
void ParseExtinguish(Parser &p)
Definition: parse_extinguish.cpp:9
void setpos(long pos)
Definition: parser.h:561
OptionParser action
Definition: parser.h:27
void getToken(T var[], size_t n)
Definition: parser.h:472
istringstream p_ls
number of the line we are parsing
Definition: parser.h:319
void p_showLocation(size_t p, FILE *io)
Definition: parser.cpp:1240
void IntRead(istringstream &iss, const string &s, long long &value)
Definition: service.cpp:649
string StandardFluxUnit(void) const
Definition: parser.cpp:305
Option(long val)
Definition: parser.h:900
size_t findUniqueLen(trieNode *root, const string &token)
Definition: thirdparty.cpp:5153
void ParseSave(Parser &p)
Definition: parse_save.cpp:85
bool lgEOL()
Definition: parser.h:535
string getRawTail()
Definition: parser.h:232
Quoted
Definition: parser.h:888
size_t m_getUniqueLen(const string &s2) const
Definition: parser.h:94
const char * nWord(const char *chKey, const char *chCard)
Definition: parser.cpp:67
void ParseTable(Parser &p)
Definition: parse_table.cpp:94
bool m_lgDSet
Definition: parser.h:54
void set_point(long int ipnt)
Definition: parser.h:107
void getLineID(LineID &line)
Definition: parser.cpp:1359
Opts
Definition: parser.h:887
void ParseAgn(Parser &p)
Definition: parse_agn.cpp:10
void init()
Definition: parser.h:65
void warning(const string &msg, FILE *io=ioQQQ)
Definition: parser.cpp:1475
void ParseDatabaseISO(long ipISO, Parser &p)
Definition: parse_atom_iso.cpp:16
void operator()(realnum *v) const
Definition: parser.h:592
Option(bool val)
Definition: parser.h:895
NORETURN void errorAbort(const string &msg, FILE *io=ioQQQ)
Definition: parser.cpp:1461
void showLocation(FILE *io=ioQQQ) const
Definition: parser.cpp:120
void ParsePowerlawContinuum(Parser &p)
Definition: parse_powerlawcontinuum.cpp:10
float realnum
Definition: cddefines.h:127
const char * StandardEnergyUnit(void) const
Definition: parser.cpp:301
long getpos()
Definition: parser.h:559
float sys_float
Definition: cddefines.h:130
bool last(void) const
Definition: parser.cpp:201
void ParseIonPar(Parser &p, char chType)
Definition: parse_ionpar.cpp:20
void parse_save_colden(Parser &p, ostringstream &chHeader)
void p_replaceSep()
Definition: parser.h:383
void p_pos(size_t p)
Definition: parser.h:361
DataParser(const string &name, eod_style es, access_scheme as=AS_DEFAULT)
Definition: parser.h:406
void ParseCMB(double z, long int *nqh)
Definition: parse_CMB.cpp:10
void p_close()
Definition: parser.cpp:1214
long i
Definition: parser.h:891
bool hasCommand(const string &s2)
Definition: parser.cpp:831
void ParseAbundances(Parser &p)
Definition: parse_abundances.cpp:18
void checkEOL()
Definition: parser.h:543
void skipTo(size_t p)
Definition: parser.h:514
void p_open(const string &name, eod_style es, access_scheme as)
have we passed beyond the EOF?
Definition: parser.cpp:1204
NORETURN void NoNumb(const char *chDesc) const
Definition: parser.cpp:360
long min(int a, long b)
Definition: cddefines.h:766
void ParseMap(Parser &p)
Definition: parse_map.cpp:9
string m_card
Definition: parser.h:43
long int GetElem(void) const
Definition: parser.cpp:336
tokens
Definition: parser.h:34
#define NULL
Definition: cddefines.h:115
const char * nWord(const char *chKey) const
Definition: parser.cpp:32
int nMatch1(const char *chKey) const
Definition: parser.h:135
string getFirstChunk(long i)
Definition: parser.cpp:569
void ParseCosmicRays(Parser &p)
Definition: parse_cosmic_rays.cpp:12
void getKeyword(string &str)
Definition: parser.h:506
bool isVar(void) const
Definition: parser.cpp:149
long int m_len
Definition: parser.h:46
void ParseAbundancesNonSolar(Parser &p)
void ParseIlluminate(Parser &p)
Definition: parse_illuminate.cpp:11
void ParsePrtLineSum(Parser &p)
Definition: prt_linesum.cpp:42
void setDone()
Definition: parser.h:926
void ParseRatio(Parser &p)
Definition: parse_ratio.cpp:10
vector< pair< string, shared_ptr< Option > > > p
Definition: parser.h:924
double getNumberCheckAlwaysLogLim(const char *chDesc, double flim)
Definition: parser.cpp:448
void ParseCompile(Parser &p)
Definition: parse_compile.cpp:14
void ParseConstant(Parser &p)
Definition: parse_constant.cpp:14
Definition: thirdparty.h:516
void help(FILE *fp) const
Definition: parser.cpp:309
void ParseInit(Parser &p)
Definition: parse_init.cpp:10
void close()
Definition: parser.h:417
bool l
Definition: parser.h:890
#define ASSERT(exp)
Definition: cddefines.h:637
void skipAfter(const string &s)
Definition: parser.h:521
KeyAction< V > MakeKeyAction(const char *keyword, const V &action)
Definition: parser.h:600
void ParsePrint(Parser &p)
Definition: parse_print.cpp:134
bool getline()
Definition: parser.cpp:275
string getFirstChunkRaw(long i)
Definition: parser.cpp:584
void ParseNorm(Parser &p)
Definition: parse_norm.cpp:10
void ParseAbsMag(Parser &p)
Definition: parse_absmag.cpp:9
void ParseOptimize(Parser &p)
Definition: parse_optimize.cpp:30
KeyAction(const char *keyword, const V &action)
Definition: parser.h:585
void ParseAge(Parser &p)
Definition: parse_age.cpp:38
NORETURN void Error(const char *msg) const
Definition: parser.cpp:248
bool GetParam(const char *chKey, double *val)
Definition: parser.h:167
void ParseIonParI(Parser &p)
Definition: parse_ionpar.cpp:11
string m_getCommandToken() const
Definition: parser.cpp:892
bool getQuoteOptional(string &str)
Definition: parser.h:482
double getNumberCheckAlwaysLog(const char *chDesc)
Definition: parser.cpp:442
Option(const string &val, enum Quoted q)
Definition: parser.h:910
void checkMagic(long i0)
Definition: parser.cpp:1286
Parser(const CloudyCommand *commands)
Definition: parser.h:60
const CloudyCommand *const m_Commands
Definition: parser.h:49
void ParseInitFile(const string &chName)
Definition: parse_init.cpp:47
double getNumberDefault(const char *chDesc, double fdef)
Definition: parser.cpp:416
char current(void) const
Definition: parser.h:87
void ParseGrid(Parser &p)
Definition: parse_grid.cpp:10
bool p_lgEOF
stream for reading current line
Definition: parser.h:320
bool lgEOL(void) const
Definition: parser.h:125
string value
Definition: parser.h:36
bool getKeywordOptional(string &str)
Definition: parser.h:499
int fprintf(const Output &stream, const char *format,...)
Definition: service.cpp:1325
DataParser()
Definition: parser.h:401
Definition: depth_table.h:7
NORETURN void CommandError(void) const
Definition: parser.cpp:259
bool p_isComment() const
Definition: parser.h:327
void getPairs(vector< double > &a, vector< double > &b)
Definition: parser.cpp:931
void ParseGlobule(Parser &p)
Definition: parse_globule.cpp:11
enum tokens toktype
Definition: parser.h:35
void ParseSet(Parser &p)
Definition: parse_set.cpp:38
void ParseMetal(Parser &p)
Definition: parse_metal.cpp:239
const char *const m_keyword
Definition: parser.h:582
void ParseDont(Parser &p)
Definition: parse_dont.cpp:28
char current_raw() const
Definition: parser.cpp:41
int PrintLine(FILE *fp) const
Definition: parser.h:220
bool isOpen() const
Definition: parser.h:422
void p_getQuoteOptional(string &str)
Definition: parser.cpp:1257
void ParseBlackbody(Parser &p)
Definition: parse_blackbody.cpp:11
string p_line
what are the allowed EOD markers?
Definition: parser.h:317
void open(const string &name, eod_style es, access_scheme as=AS_DEFAULT)
Definition: parser.h:411
std::string getVarName(void)
Definition: parser.cpp:153
void caps(char *chCard)
Definition: service.cpp:299
enum Option::Opts opttype
bool getline()
Definition: parser.cpp:1342
void ParseBackgrd(Parser &p)
Definition: parse_backgrd.cpp:10
bool m_lgEOF
Definition: parser.h:54
void ParseF_nu(Parser &p, const char *chType, bool lgNU2)
Definition: parse_f_nu.cpp:9
fstream p_io
the name of the data file
Definition: parser.h:315
void readLaw(DepthTable &table)
Definition: parser.cpp:1139
bool GetRange(const char *chKey, double *val1, double *val2)
Definition: parser.h:176
UnitConverter(double unit)
Definition: parser.h:610
string m_card_raw
Definition: parser.h:44
void ParseCrashDo(Parser &p)
Definition: parse_crashdo.cpp:51
void ParseFluc(Parser &p)
Definition: parse_fluc.cpp:9
void doSetVar(void)
Definition: parser.cpp:166
double getNumberDefaultNegImplLog(const char *chDesc, double fdef)
Definition: parser.cpp:470
double getWaveOpt()
Definition: parser.cpp:371
std::map< string, double > m_symtab
Definition: parser.h:50
void ParseSphere(Parser &p)
Definition: parse_sphere.cpp:9
const char * key(void) const
Definition: parser.h:588
std::map< string, size_t > m_uniqueLen
Definition: parser.h:51
V m_action
Definition: parser.h:583
void ParseDLaw(Parser &p)
Definition: parse_dlaw.cpp:10
bool p_isSeparator(char c)
Definition: parser.h:378
void ParseTLaw(Parser &p)
Definition: parse_tlaw.cpp:13
void ParseTrace(Parser &p)
Definition: parse_trace.cpp:11
string m_card_comment
Definition: parser.h:45
bool isComment(void) const
Definition: parser.cpp:145
bool p_blankLine() const
Definition: parser.h:340
void p_newlineProcess()
Definition: parser.cpp:1229
double r
Definition: parser.h:892
void ParseCoronal(Parser &p)
Definition: parse_coronal.cpp:14
void ParseInterp(Parser &p)
Definition: parse_interp.cpp:11
double getNumberCheck(const char *chDesc)
Definition: parser.cpp:407
void ParseStop(Parser &p)
Definition: parse_stop.cpp:17