#include <Aipsrc.h>
Inheritance diagram for casa::Aipsrc:


Part of API
A class for getting values from the aipsrc files
The static Aipsrc class can get information from the aipsrc resource files. It has the same functionality as getrc (c program used for aips++ installation scripts).
In addition it acts as a central clearing house between system and software by providing functionality to obtain aips++ system parameters (like AIPSPATH elements), and the possibility of storing system wide information provided by a class for reference by other classes.
The format of a line in a resource file is:
# Line starting with an # in column 1 is a comment (as is an empty line)
keyword: value
keyword: value
printer.ps.page
measures.precession.d_interval
measures.nutation.d_interval
_ as word-parts separator. :. The value is the string from the first non-whitespace character after the separator to the end of the line. Interpretation of the string is in general the program's responsibility, but special find() calls (see below) exist to aid.* to indicate all values with that structure (e.g. *.d_interval would indicate in the example above both the precession and the nutation d_interval. ~/.aipsrc
$AIPSROOT/.aipsrc
$AIPSHOST/aipsrc
$AIPSSITE/aipsrc
$AIPSARCH/aipsrc
Aipsrc related call, be set with the setAipsPath() call.Bool Aipsrc::find(String &result, const String &keyword)
Bool AipsrcValue::find(Type &result, const String &keyword, .\..)
find functions have the ability to set a default if there is no match, while also unit conversion is possible.>> will produce this result.) Caution: The search keyword (unlike the file keyword) has no wildcards. The real name should, of course, be looked for. To aid in other places, the following (static) methods are available to get the requested information (derived from HOME and AIPSPATH, computer system information and/or aipsrc keywords): ~/aips++ Given an AIPSPATH of
/epp/aips++ sun4sol_gnu epping norma
/epp/aips++/sun4sol_gnu/epping
The basic find above reacts with the aipsrc files available. If regular access is necessary (e.g. a lot of routines have to check independently a certain integration time limit), keywords can be registered to enable:
$HOME/.aipsrc keyword/value list with save() $HOME/.aipsrc, the old version is saved in $HOME/.aipsrc.old, before the keyword/value pair is prepended to the file. A limited number of edits of the same keyword is preserved only (default 5, changeable with the user.aipsrc.edit.keep keyword.
String printerPage; // result of keyword find if(!Aipsrc::find(printerPage, "printer.ps.page")) { // look for keyword match printerPage = "notSet"; };
Aipsrc::find(printerPage, "printer.ps.page", "notSet");
static uInt pp = Aipsrc::registerRC("printer.ps.page", "noSet"); String printerPage = Aipsrc::get(pp); // Processing, and maybe somewhere else: Aipsrc::set(pp, "nowSet"); // .\.. printerPage = Aipsrc::get(pp); // and save it to the <tt>$HOME/.aipsrc</tt> list Aipsrc::save(pp);
Programs need a way to interact with the aipsrc files.
Definition at line 212 of file Aipsrc.h.
Static Public Member Functions | |
| static void | setAipsPath (const String &path=String()) |
| Set an AIPSPATH that should be used in stead of a global AIPSPATH. | |
| static void | show (ostream &oStream) |
The following show() function, useful for debugging, outputs all keyword/value pairs found. | |
| static void | show () |
| Prints all info on cout. | |
| static Bool | find (String &value, const String &keyword) |
| static Bool | findNoHome (String &value, const String &keyword) |
| static Bool | find (uInt &value, const String &keyword, Int Nname, const String tname[]) |
| These finds check a (possible) value of the keyword against a list of coded values provided, and return an index into the list (N if not found). | |
| static Bool | find (uInt &value, const String &keyword, const Vector< String > &tname) |
| static Bool | find (String &value, const String &keyword, const String &deflt) |
| This find usually saves you some lines of code, since you can supply the default you want to use when no such keyword is defined. | |
| static Bool | findNoHome (String &value, const String &keyword, const String &deflt) |
| static Bool | find (uInt &value, const String &keyword, Int Nname, const String tname[], const String &deflt) |
| static Bool | find (uInt &value, const String &keyword, const Vector< String > &tname, const String &deflt) |
| static uInt | registerRC (const String &keyword, const String &deflt) |
| Functions to register keywords for later use in get() and set(). | |
| static uInt | registerRC (const String &keyword, Int Nname, const String tname[], const String &deflt) |
| static uInt | registerRC (const String &keyword, const Vector< String > &tname, const String &deflt) |
| static const String & | get (uInt keyword) |
| Gets are like find, but using registered integers rather than names. | |
| static const uInt & | get (uInt &code, uInt keyword) |
| get for code | |
| static void | set (uInt keyword, const String &deflt) |
| Sets allow registered values to be set. | |
| static void | set (uInt keyword, Int Nname, const String tname[], const String &deflt) |
| static void | set (uInt keyword, const Vector< String > &tname, const String &deflt) |
| static void | save (uInt keyword) |
Save a registered keyword value to $HOME/.aipsrc. | |
| static void | save (uInt keyword, const String tname[]) |
| static void | save (uInt keyword, const Vector< String > &tname) |
| static const String & | aipsRoot () |
| Returns the appropriate AIPS++ or system variable values. | |
| static const String & | aipsArch () |
| static const String & | aipsSite () |
| static const String & | aipsHost () |
| static const String & | aipsHome () |
Returns: ~/aips++. | |
| static void | reRead () |
The reRead() function, will reinitialise the static maps and read the aipsrc files again. | |
| static Double | lastRead () |
| static const Block< String > & | values () |
| The following functions return the full lists of available data. | |
| static const Block< String > & | patterns () |
| static uInt | genRestore (Vector< String > &namlst, Vector< String > &vallst, const String &fileList) |
| Read aipsrc type files (without wildcards), and return the unique names and values in the Vector arguments. | |
| static void | genSave (Vector< String > &namlst, Vector< String > &vallst, const String &fnam) |
| Save the names/values in file. | |
| static void | genSet (Vector< String > &namlst, Vector< String > &vallst, const String &nam, const String &val) |
| Set (new or overwrite) keyword/value pair. | |
| static Bool | genUnSet (Vector< String > &namlst, Vector< String > &vallst, const String &nam) |
| Remove a keyword from list (False if not in list). | |
| static Bool | genGet (String &val, Vector< String > &namlst, Vector< String > &vallst, const String &nam) |
| Get the value of a keyword. | |
Static Protected Member Functions | |
| static Bool | find (String &value, const String &keyword, uInt start) |
| Actual find function. | |
| static uInt | registerRC (const String &keyword, Block< String > &nlst) |
| The registration function. | |
| static void | save (const String keyword, const String val) |
| Actual saving. | |
Static Private Member Functions | |
| static uInt | genParse (Block< String > &keywordPattern, Block< String > &keywordValue, uInt &fileEnd, const String &fileList) |
| The following parse function can be used for any list of files. | |
| static Bool | matchKeyword (uInt &where, const String &keyword, uInt start) |
| Locate the right keyword in the static maps. | |
| static const String & | fillAips (const String &nam) |
| Fill in root, arch, site, host and home, and return requested nam. | |
| static uInt | parse () |
| Read in the aipsrc files, returning the number of lines found. | |
| static uInt | parse (String &fileList) |
Static Private Attributes | |
| static Bool | doInit |
| Indicate files read. | |
| static Double | lastParse |
| Last time data was (re)read. | |
| static Block< String > | keywordValue |
| List of values belonging to keywords found. | |
| static Block< String > | keywordPattern |
| List of patterns deducted from names. | |
| static uInt | fileEnd |
| The start of the non-home values. | |
| static String | extAipsPath |
| The possibly set external AIPSPATH. | |
| static String | root |
| AIPSROOT. | |
| static String | arch |
| AIPSARCH. | |
| static String | site |
| AIPSSITE. | |
| static String | host |
| AIPSHOST. | |
| static String | home |
| AIPSHOME. | |
| static String | uhome |
| HOME. | |
| static Bool | filled |
| Indicate above filled. | |
| static Block< String > | strlst |
| String register list. | |
| static Block< String > | nstrlst |
| static Block< uInt > | codlst |
| static Block< String > | ncodlst |
find() functions will, given a keyword, return the value with a matched keyword found in the files. If no match found the function will be False. The findNoHome() emulates the -i switch of getrc by bypassing the ~/.aipsrc file.
| static Bool casa::Aipsrc::find | ( | uInt & | value, | |
| const String & | keyword, | |||
| Int | Nname, | |||
| const String | tname[] | |||
| ) | [static] |
These finds check a (possible) value of the keyword against a list of coded values provided, and return an index into the list (N if not found).
Matching is minimax, case insensitive. Always better to use the one with default. return is False if no keyword or no match.
| static Bool casa::Aipsrc::find | ( | uInt & | value, | |
| const String & | keyword, | |||
| const Vector< String > & | tname | |||
| ) | [static] |
| static Bool casa::Aipsrc::find | ( | String & | value, | |
| const String & | keyword, | |||
| const String & | deflt | |||
| ) | [static] |
This find usually saves you some lines of code, since you can supply the default you want to use when no such keyword is defined.
If the return value is False, the keyword was not found and the default was used.
| static Bool casa::Aipsrc::findNoHome | ( | String & | value, | |
| const String & | keyword, | |||
| const String & | deflt | |||
| ) | [static] |
| static Bool casa::Aipsrc::find | ( | uInt & | value, | |
| const String & | keyword, | |||
| Int | Nname, | |||
| const String | tname[], | |||
| const String & | deflt | |||
| ) | [static] |
| static Bool casa::Aipsrc::find | ( | uInt & | value, | |
| const String & | keyword, | |||
| const Vector< String > & | tname, | |||
| const String & | deflt | |||
| ) | [static] |
| static uInt casa::Aipsrc::registerRC | ( | const String & | keyword, | |
| Int | Nname, | |||
| const String | tname[], | |||
| const String & | deflt | |||
| ) | [static] |
| static uInt casa::Aipsrc::registerRC | ( | const String & | keyword, | |
| const Vector< String > & | tname, | |||
| const String & | deflt | |||
| ) | [static] |
Gets are like find, but using registered integers rather than names.
Sets allow registered values to be set.
| static void casa::Aipsrc::set | ( | uInt | keyword, | |
| Int | Nname, | |||
| const String | tname[], | |||
| const String & | deflt | |||
| ) | [static] |
| static void casa::Aipsrc::set | ( | uInt | keyword, | |
| const Vector< String > & | tname, | |||
| const String & | deflt | |||
| ) | [static] |
| static void casa::Aipsrc::save | ( | uInt | keyword | ) | [static] |
Save a registered keyword value to $HOME/.aipsrc.
Set an AIPSPATH that should be used in stead of a global AIPSPATH.
This call should be made before any Aipsrc related call. The AIPSPATH will have up to 4 fields (which can all be empty) giving the root, host, site and arch directory that will be searched for possible [.]aipsrc files.
| static const String& casa::Aipsrc::aipsRoot | ( | ) | [static] |
Returns the appropriate AIPS++ or system variable values.
| static const String& casa::Aipsrc::aipsArch | ( | ) | [static] |
| static const String& casa::Aipsrc::aipsSite | ( | ) | [static] |
| static const String& casa::Aipsrc::aipsHost | ( | ) | [static] |
| static const String& casa::Aipsrc::aipsHome | ( | ) | [static] |
Returns: ~/aips++.
| static void casa::Aipsrc::reRead | ( | ) | [static] |
The reRead() function, will reinitialise the static maps and read the aipsrc files again.
It could be useful in some interactive or multi-processor circumstances. lastRead() returns the time last reRead.
| static Double casa::Aipsrc::lastRead | ( | ) | [static] |
The following functions return the full lists of available data.
They could be useful for debugging purposes.
| static void casa::Aipsrc::show | ( | ostream & | oStream | ) | [static] |
The following show() function, useful for debugging, outputs all keyword/value pairs found.
| static void casa::Aipsrc::show | ( | ) | [static] |
Prints all info on cout.
| static uInt casa::Aipsrc::genRestore | ( | Vector< String > & | namlst, | |
| Vector< String > & | vallst, | |||
| const String & | fileList | |||
| ) | [static] |
Read aipsrc type files (without wildcards), and return the unique names and values in the Vector arguments.
The return value is number of names.
| static void casa::Aipsrc::genSave | ( | Vector< String > & | namlst, | |
| Vector< String > & | vallst, | |||
| const String & | fnam | |||
| ) | [static] |
Save the names/values in file.
| static void casa::Aipsrc::genSet | ( | Vector< String > & | namlst, | |
| Vector< String > & | vallst, | |||
| const String & | nam, | |||
| const String & | val | |||
| ) | [static] |
Set (new or overwrite) keyword/value pair.
| static Bool casa::Aipsrc::genUnSet | ( | Vector< String > & | namlst, | |
| Vector< String > & | vallst, | |||
| const String & | nam | |||
| ) | [static] |
Remove a keyword from list (False if not in list).
| static Bool casa::Aipsrc::genGet | ( | String & | val, | |
| Vector< String > & | namlst, | |||
| Vector< String > & | vallst, | |||
| const String & | nam | |||
| ) | [static] |
Get the value of a keyword.
| static Bool casa::Aipsrc::find | ( | String & | value, | |
| const String & | keyword, | |||
| uInt | start | |||
| ) | [static, protected] |
Actual find function.
| static uInt casa::Aipsrc::registerRC | ( | const String & | keyword, | |
| Block< String > & | nlst | |||
| ) | [static, protected] |
The registration function.
Actual saving.
| static uInt casa::Aipsrc::parse | ( | ) | [static, private] |
Read in the aipsrc files, returning the number of lines found.
| static uInt casa::Aipsrc::genParse | ( | Block< String > & | keywordPattern, | |
| Block< String > & | keywordValue, | |||
| uInt & | fileEnd, | |||
| const String & | fileList | |||
| ) | [static, private] |
The following parse function can be used for any list of files.
It will return the list of Patterns and values found, and the last keyword number of first file in list.
| static Bool casa::Aipsrc::matchKeyword | ( | uInt & | where, | |
| const String & | keyword, | |||
| uInt | start | |||
| ) | [static, private] |
Locate the right keyword in the static maps.
Fill in root, arch, site, host and home, and return requested nam.
Bool casa::Aipsrc::doInit [static, private] |
Double casa::Aipsrc::lastParse [static, private] |
Block<String> casa::Aipsrc::keywordValue [static, private] |
Block<String> casa::Aipsrc::keywordPattern [static, private] |
uInt casa::Aipsrc::fileEnd [static, private] |
String casa::Aipsrc::extAipsPath [static, private] |
String casa::Aipsrc::root [static, private] |
String casa::Aipsrc::arch [static, private] |
String casa::Aipsrc::site [static, private] |
String casa::Aipsrc::host [static, private] |
String casa::Aipsrc::home [static, private] |
String casa::Aipsrc::uhome [static, private] |
Bool casa::Aipsrc::filled [static, private] |
Block<String> casa::Aipsrc::strlst [static, private] |
Block<String> casa::Aipsrc::nstrlst [static, private] |
Block<uInt> casa::Aipsrc::codlst [static, private] |
Block<String> casa::Aipsrc::ncodlst [static, private] |
1.5.1