/usr/include/odinpara/jdxtypes.h is in libodin-dev 1.8.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 | /***************************************************************************
jdxtypes.h - description
-------------------
begin : Sun Jun 6 2004
copyright : (C) 2000-2014 by Thies H. Jochimsen
email : thies@jochimsen.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef JDXTYPES_H
#define JDXTYPES_H
#include <odinpara/jdxbase.h>
/**
* @addtogroup jcampdx
* @{
*/
//////////////////////////////////////////////////////////////////
/**
*
* JCAMP-DX class for representing strings
*/
class JDXstring : public STD_string, public virtual JcampDxClass {
public:
/**
* Default constructor
*/
JDXstring () : STD_string() {}
/**
* Constructor with the following arguments:
* - ss: Initial value for the string
* - name: The label of the JCAMP-DX parameter
* - userParameter: Whether this is a user defined JCAMP-DX parameter
* - mode: Mode for ASCII representation of strings or arrays of strings
* - parameter_mode: Mode for GUI accesibility of the parameter
* - parx_equivalent: Equivalent parameter in PARX to which this parameter will be assigned
*/
JDXstring (const STD_string& ss,const STD_string& name="",bool userParameter=true,
compatMode mode=notBroken,parameterMode parameter_mode=edit,
const STD_string& parx_equivalent="");
/**
* Constructs a string of length i with c as their initial content
*/
JDXstring (int i,const char c=' ') : STD_string(i,c) {}
/**
* Copy constructor from a C-string
*/
JDXstring (const char *charptr) : STD_string(charptr) {}
/**
* Copy constructor
*/
JDXstring (const JDXstring& str) {JDXstring::operator = (str);}
/**
* Assigns the string ss to the parameter
*/
JDXstring& operator = (const STD_string& ss) {STD_string::operator = (ss); return *this;}
/**
* Assigns the C-string charptr to the parameter
*/
JDXstring& operator = (const char *charptr) {STD_string::operator = (charptr); return *this;}
/**
* Copy assignment
*/
JDXstring& operator = (const JDXstring& ss);
/**
* Final overrider for stream output
*/
friend STD_ostream& operator << (STD_ostream& s,const JDXstring& t) {return s << STD_string(t);}
// overwriting virtual functions from JcampDxClass
bool parsevalstring (const STD_string& parstring);
STD_string printvalstring() const;
STD_string get_parx_code(parxCodeType type, const ParxEquiv& equiv) const;
ParxEquiv get_parx_equiv() const {parx_equiv.type="char"; return parx_equiv;}
const char* get_typeInfo() const {return "string";}
JcampDxClass* create_copy() const {return new JDXstring(*this);}
STD_string* cast(STD_string*) {return this;}
private:
mutable ParxEquiv parx_equiv;
};
//////////////////////////////////////////////////////////////////
/**
*
* JCAMP-DX class for representing Boolean values
*/
class JDXbool : public virtual JcampDxClass {
public:
/**
* Default constructor
*/
JDXbool () : val(false) {}
/**
* Constructor with the following arguments:
* - flag: Initial value for the Boolean value
* - name: The label of the JCAMP-DX parameter
* - userParameter: Whether this is a user defined JCAMP-DX parameter
* - mode: Mode for ASCII representation of strings or arrays of strings
* - parameter_mode: Mode for GUI accesibility of the parameter
* - parx_equivalent: Equivalent parameter in PARX to which this parameter will be assigned
*/
JDXbool(bool flag, const STD_string& name="",
bool userParameter=true, compatMode mode=notBroken,
parameterMode parameter_mode=edit,
const STD_string& parx_equivalent="");
/**
* Copy constructor
*/
JDXbool(const JDXbool& jb) {JDXbool::operator = (jb);}
/**
* Assigns the value of flag to the parameter
*/
JDXbool& operator = (bool flag) {val=flag; return *this;}
/**
* Assigns the value of s to the parameter, s may contain "yes" or "true"
* (upper- or lowercase) to indicate a value of true, otherwise false
*/
JDXbool& operator = (const STD_string& s) {parsevalstring(s); return *this;}
/**
* Copy assignment
*/
JDXbool& operator = (const JDXbool& jb);
/**
* type conversion operator of the current value of the parameter
*/
operator bool () const {return val;}
// overwriting virtual functions from JcampDxClass
bool parsevalstring (const STD_string& parstring);
STD_string printvalstring() const;
STD_string get_parx_code(parxCodeType type, const ParxEquiv& equiv) const;
ParxEquiv get_parx_equiv() const {parx_equiv.type="YesNo"; return parx_equiv;}
const char* get_typeInfo() const {return "bool";}
JcampDxClass* create_copy() const {return new JDXbool(*this);}
bool* cast(bool*) {return &val;}
private:
bool val;
mutable ParxEquiv parx_equiv;
};
//////////////////////////////////////////////////////////////////
/**
*
* JCAMP-DX class to represent enumerations
*/
class JDXenum : public virtual JcampDxClass {
public:
/**
* Default constructor
*/
JDXenum() {actual=entries.end();}
/**
* Constructor with the following arguments:
* - first_entry: Initial value for the first entry of the enumeration
* - name: The label of the JCAMP-DX parameter
* - userParameter: Whether this is a user defined JCAMP-DX parameter
* - mode: Mode for ASCII representation of strings or arrays of strings
* - parameter_mode: Mode for GUI accesibility of the parameter
* - parx_equivalent: Equivalent parameter in PARX to which this parameter will be assigned
*/
JDXenum(const STD_string& first_entry, const STD_string& name="",
bool userParameter=true, compatMode mode=notBroken,
parameterMode parameter_mode=edit, const STD_string& parx_equivalent="");
/**
* Copy constructor
*/
JDXenum(const JDXenum& je) {JDXenum::operator = (je);}
/**
* Sets the current value of the enumeration to the given item
*/
JDXenum& operator = (const char* item) {set_actual(STD_string(item)); return *this;}
/**
* Sets the current value of the enumeration to the given item
*/
JDXenum& operator = (const STD_string& item) {set_actual(item); return *this;}
/**
* Sets the current value of the enumeration to the given item
*/
JDXenum& operator = (int item) {set_actual(item); return *this;}
/**
* Assignment operator
*/
JDXenum& operator = (const JDXenum& je);
/**
* Appends an item to the the list of items in the enumeration.
* If index is non-negative, the item will be inserted at the
* position indicated by index.
*/
JDXenum& add_item(const STD_string& item, int index=-1);
/**
* Sets the current value of the enumeration to the given item
*/
JDXenum& set_actual(const STD_string& item);
/**
* Sets the current value of the enumeration to the given item
*/
JDXenum& set_actual(int index);
/**
* Clears the list of items in the enumeration
*/
JDXenum& clear();
/**
* type conversion operator of the current value of the enumeration
*/
operator int () const;
/**
* type conversion operator of the current value of the enumeration
*/
operator STD_string () const;
/**
* Compares the current value with s for equality
*/
bool operator == (const STD_string& s) const {return (operator STD_string ())==s;}
/**
* Compares the current value with s for equality
*/
bool operator == (const char* s) const {return (operator STD_string ())==STD_string(s);}
/**
* Compares the current index with i for equality
*/
bool operator == (int i) const {return (operator int ())==i;}
/**
* Compares the current value with s for inequality
*/
bool operator != (const STD_string& s) const {return (operator STD_string ())!=s;}
/**
* Compares the current value with s for inequality
*/
bool operator != (const char* s) const {return (operator STD_string ())!=STD_string(s);}
/**
* Compares the current index with i for inequality
*/
bool operator != (int i) const {return (operator int ())!=i;}
/**
* Returns the number of items in the enumeration
*/
unsigned int n_items() const {return entries.size();}
/**
* Returns the item at the position 'index' in the label-index map
*/
const STD_string& get_item(unsigned int index) const;
/**
* Returns the current position in the label-index map
*/
unsigned int get_item_index() const;
/**
* Sets the current position 'index' in the label-index map
*/
JDXenum& set_item_index(unsigned int index);
// overwriting virtual functions from JcampDxClass
bool parsevalstring (const STD_string& parstring);
STD_string printvalstring() const;
svector get_alternatives() const;
STD_string get_parx_code(parxCodeType type, const ParxEquiv& equiv) const;
ParxEquiv get_parx_equiv() const;
const char* get_typeInfo() const {return "enum";}
JcampDxClass* create_copy() const {return new JDXenum(*this);}
JDXenum* cast(JDXenum*) {return this;}
private:
STD_map<int,STD_string> entries;
STD_map<int,STD_string>::const_iterator actual;
mutable ParxEquiv parx_equiv;
STD_string parxtype_cache;
};
//////////////////////////////////////////////////////////////////
/**
*
* JCAMP-DX class to trigger actions from the GUI
*/
class JDXaction : public virtual JcampDxClass {
public:
/**
* Default constructor
*/
JDXaction() : state(false) {set_filemode(exclude);}
/**
* Constructor with the following arguments:
* - init_state: Initial value for the action
* - name: The label of the JCAMP-DX parameter
* - userParameter: Whether this is a user defined JCAMP-DX parameter
* - mode: Mode for ASCII representation of strings or arrays of strings
* - parameter_mode: Mode for GUI accesibility of the parameter
*/
JDXaction(bool init_state, const STD_string& name="",
bool userParameter=true, compatMode mode=notBroken,
parameterMode parameter_mode=edit);
/**
* Copy constructor
*/
JDXaction(const JDXaction& ja) {JDXaction::operator = (ja);}
/**
* Copy assignment
*/
JDXaction& operator = (const JDXaction& ja);
/**
* Returns whether an action should be triggered and resets the action flag
*/
operator bool () const;
/**
* After calling this function, the next type conversion to bool will return true
*/
JDXaction& trigger_action() {state=true; return *this;}
// overwriting virtual functions from JcampDxClass
bool parsevalstring (const STD_string& parstring);
STD_string printvalstring() const;
const char* get_typeInfo() const {return "action";}
JcampDxClass* create_copy() const {return new JDXaction(*this);}
JDXaction* cast(JDXaction*) {return this;}
private:
mutable bool state;
};
//////////////////////////////////////////////////////////////////
/**
*
* JCAMP-DX class for representing file names. Besides using JDXfileName
* as a convenient way within the UI to display/retrieve/browse file names,
* it can be used to analyze file paths, for example in the following way:
* \verbatim
STD_string myfile="/somedir/anotherdir/file.txt";
STD_string myfile_base=JDXfileName(myfile).get_basename();
STD_cout << "myfile_base=" << myfile_base << STD_endl;
STD_string myfile_base_nosuffix=JDXfileName(myfile).get_basename_nosuffix();
STD_cout << "myfile_base_nosuffix=" << myfile_base_nosuffix << STD_endl;
STD_string myfile_dir= JDXfileName(myfile).get_dirname();
STD_cout << "myfile_dir=" << myfile_dir << STD_endl;
\endverbatim
*
*/
class JDXfileName : public JDXstring {
public:
/**
* Default constructor
*/
JDXfileName () {common_init();}
/**
* Constructor with the following arguments:
* - filename: Initial value for the file name
* - name: The label of the JCAMP-DX parameter
* - userParameter: Whether this is a user defined JCAMP-DX parameter
* - mode: Mode for ASCII representation of strings or arrays of strings
* - parameter_mode: Mode for GUI accesibility of the parameter
*/
JDXfileName (const STD_string& filename, const STD_string& name="",
bool userParameter=true, compatMode mode=notBroken,
parameterMode parameter_mode=edit);
/**
* Copy constructor
*/
JDXfileName(const JDXfileName& jf);
/**
* Assignment from a string
*/
JDXfileName& operator = (const STD_string& filename);
/**
* Assignment operator
*/
JDXfileName& operator = (const JDXfileName& jf);
/**
* Returns 'true' only if the file/directory exists
*/
bool exists() const;
/**
* Returns the filename without preceeding directories
*/
STD_string get_basename() const {return basename_cache;}
/**
* Returns the filename without preceeding directories and without
* a previously specified suffix (file extension)
*/
STD_string get_basename_nosuffix() const;
/**
* Returns the directory of the filename
*/
STD_string get_dirname() const {return dirname_cache;}
/**
* Returns the suffix (file extension) of the filename
*/
STD_string get_suffix() const {return suffix_cache;}
/**
* Sets/overwrites the suffix (file extension) of the filename
*/
JDXfileName& set_suffix(const STD_string& suff) {suffix_cache=suff; return *this;}
/**
* Returns the default location of the filename
*/
STD_string get_defaultdir() const {return defaultdir;}
/**
* Sets the default location of the filename
*/
JDXfileName& set_defaultdir(const STD_string& defdir);
/**
* Returns whether used exclusively for directory names
*/
bool is_dir() const {return dir;}
/**
* Specifies whether used exclusively for directory names
*/
JDXfileName& set_dir(bool flag) {dir=flag; return *this;}
// overwriting virtual functions from JcampDxClass
bool parsevalstring (const STD_string& parstring);
const char* get_typeInfo() const {return "fileName";}
JcampDxClass* create_copy() const {return new JDXfileName(*this);}
JDXfileName* cast(JDXfileName*) {return this;}
private:
static void normalize(const STD_string& fname, bool dir, STD_string& result, STD_string& result_dirname, STD_string& result_basename, STD_string& result_suffix);
void common_init() {dir=false;}
STD_string defaultdir;
STD_string dirname_cache;
STD_string basename_cache;
STD_string suffix_cache;
bool dir;
};
//////////////////////////////////////////////////////////////////
/**
*
* JCAMP-DX class for representing mathematic formulas
*/
class JDXformula : public JDXstring {
public:
/**
* Default constructor
*/
JDXformula () : JDXstring() {}
/**
* Constructor with the following arguments:
* - formula: Initial value for the formula
* - name: The label of the JCAMP-DX parameter
* - userParameter: Whether this is a user defined JCAMP-DX parameter
* - mode: Mode for ASCII representation of strings or arrays of strings
* - parameter_mode: Mode for GUI accesibility of the parameter
*/
JDXformula (const STD_string& formula, const STD_string& name="",
bool userParameter=true, compatMode mode=notBroken,
parameterMode parameter_mode=edit);
/**
* Copy constructor
*/
JDXformula (const JDXformula& jf) {JDXformula::operator = (jf);}
/**
* Assignment from a formula string
*/
JDXformula& operator = (const STD_string& formula) {JDXstring::operator = (formula); return *this;}
/**
* Copy assignment
*/
JDXformula& operator = (const JDXformula& jf);
/**
* Sets a string describing the formulas syntax
*/
JDXformula& set_syntax(const STD_string& syn) {syntax=syn; return *this;}
/**
* Returns a string describing the formulas syntax
*/
STD_string get_syntax() const {return syntax;}
// overwriting virtual functions from JcampDxClass
const char* get_typeInfo() const {return "formula";}
JcampDxClass* create_copy() const {return new JDXformula(*this);}
JDXformula* cast(JDXformula*) {return this;}
private:
STD_string syntax;
};
/** @}
*/
#endif
|