paramxx  1.0.7
StringPar.h
1 #ifndef STRINGPAR_H
2 #define STRINGPAR_H
3 
4 // --8<--8<--8<--8<--
5 //
6 // Copyright (C) 2006 Smithsonian Astrophysical Observatory
7 //
8 // This file is part of paramxx
9 //
10 // paramxx is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU General Public License
12 // as published by the Free Software Foundation; either version 2
13 // of the License, or (at your option) any later version.
14 //
15 // paramxx is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the
22 // Free Software Foundation, Inc.
23 // 51 Franklin Street, Fifth Floor
24 // Boston, MA 02110-1301, USA
25 //
26 // -->8-->8-->8-->8--
27 
28 #include "Par.h"
29 
35 class StringPar : public Par {
36 
37 public:
38 
39  ~StringPar( ) { }
40 
41  StringPar( ) : Par( ) { }
42 
46  StringPar( const StringPar& par ) : Par( par ) { }
47 
48  // constructor
49  StringPar( ParTxt& par ) throw ( ParFileException );
50 
51  void pgetstr( char result[], size_t size ) const throw ( ParFileException ) {
52  strncpy( result, parameter[ PARVALUE ].c_str( ), size );
53  result[ size ] = '\0';
54  }
55 
56  string pgetstring( ) const throw ( ParFileException ) {
57  return parameter[ PARVALUE ];
58  }
59 
63  void print( ostream& os ) const;
64 
65  void set_val( const string& str ) throw ( ParFileException, Exception );
66 
67 private:
68 
69  void between_limits( const string& t ) const
70  throw ( ParFileException, Exception );
71 
72  void validate( const string& ) const throw ( ParFileException ) {
73  return;
74  }
75 
76 };
77 
78 #endif
Definition: Par.h:41
Definition: ParFileException.h:33
StringPar(const StringPar &par)
Definition: StringPar.h:46
Par(void)
Definition: Par.h:94
string pgetstring() const
only defined in StringPar
Definition: StringPar.h:56
Definition: Par.h:72
A class to handle the Param library specific string manipulation.
Definition: ParTxt.h:31
void print(ostream &os) const
Definition: StringPar.cc:94
Definition: StringPar.h:35
void pgetstr(char result[], size_t size) const
only defined in LongPar
Definition: StringPar.h:51