casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CasacSupport.h
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <casa/Arrays/Vector.h>
4 #include <casa/BasicSL/String.h>
5 #include <casa/Quanta/Quantum.h>
11 #include <stdcasa/Quantity.h>
12 #include <stdcasa/record.h>
13 
14 // Conversions utilities
15 
16 namespace casacore{
17 
18 class Record;
19 class ValueHolder;
20 }
21 
22 namespace casa {
23 
24 
25 casacore::Vector<casacore::String> toVectorString(const std::vector<std::string> &);
26 std::vector<std::string> fromVectorString(const casacore::Vector<casacore::String> &);
28 
30 
31 // Constructs and returns a casacore::Quantity from its input. It will throw an
32 // exception if given a malformed string or string vector, but otherwise will
33 // generate a default casacore::Quantity (0.0) for unhandled variants.
35 
37 
39 
40 // See note in implementation about possible memory leak.
42 // makes a casacore::Vector of casacore::Quantity out of strings or vector of such or later records
43  casacore::Bool toCasaVectorQuantity(const ::casac::variant& theval,
45 
48 
52 bool casaMDirection(const ::casac::variant& theVar,
53  casacore::MDirection& theMeas);
54 bool ang_as_formatted_str(string& out, const casacore::Quantity& qang,
55  const std::string& format, const casacore::Int precision);
56 bool MDirection2str(const casacore::MDirection& in, std::string& out);
57 bool casaMFrequency(const ::casac::variant& theVar,
58  casacore::MFrequency& theMeas);
59 bool casaMPosition(const ::casac::variant& theVar,
60  casacore::MPosition& theMeas);
61 bool casaMRadialVelocity(const ::casac::variant& theVar,
62  casacore::MRadialVelocity& theMeas);
63 bool casaMEpoch(const ::casac::variant& theVar,
64  casacore::MEpoch& theMeas);
65  //utility to split a single string to multiple if they are , or empty space
66  //seperated. if commaOnly = true, only seperate on commas, not empty space
68  const std::string& str);
69 
71  const std::string& str);
72 
73  // allow variant types DOUBLE, DOUBLEVEC, INT, INVEC. An empty string or a BOOLVEC
74  // will return a 0 element vector. Any other type will cause an exception to be thrown.
75  std::vector<double> toVectorDouble(const ::casac::variant& v, const casacore::String& varName);
76 
77 // Allow variant types STRING or STRINGVEC. BOOLVEC will return a 0 element vector.
78  // all other types will cause an excpetion to be thrown.
79  std::vector<string> toVectorString(const ::casac::variant& v, const casacore::String& varName);
80 
81  // Allow variant types INT or INTVEC. An empty string or a BOOLVEC
82  // will return a 0 element vector. Any other type will cause an exception to be thrown.
83  std::vector<int> toVectorInt(const ::casac::variant& v, const casacore::String& varName);
84 
85  // Allow variant types BOOL or BOOLVEC. An empty string
86  // will return a 0 element vector. Any other type will cause an exception to be thrown.
87  std::vector<bool> toVectorBool(const ::casac::variant& v, const casacore::String& varName);
88 
89  casacore::Vector<casacore::String> toCasaVectorString(const std::vector<string>& vs);
90 
91 }
A Measure: astronomical direction.
Definition: MDirection.h:174
casacore::ValueHolder * toValueHolder(const casac::variant &)
bool casaMFrequency(const ::casac::variant &theVar, casacore::MFrequency &theMeas)
A Measure: position on Earth.
Definition: MPosition.h:79
int Int
Definition: aipstype.h:50
std::vector< int > toVectorInt(const ::casac::variant &v, const casacore::String &varName)
Allow variant types INT or INTVEC.
::casac::variant * fromValueHolder(const casacore::ValueHolder &)
bool ang_as_formatted_str(string &out, const casacore::Quantity &qang, const std::string &format, const casacore::Int precision)
casacore::Vector< casacore::String > toCasaVectorString(const std::vector< string > &vs)
bool casaMPosition(const ::casac::variant &theVar, casacore::MPosition &theMeas)
todo: o create python to/from record functions o implement compare() o implement record_to_string() o...
Definition: record.h:19
casacore::String toCasaString(const casac::variant &)
A Measure: radial velocity.
A Measure: instant in time.
Definition: MEpoch.h:104
std::vector< bool > toVectorBool(const ::casac::variant &v, const casacore::String &varName)
Allow variant types BOOL or BOOLVEC.
A Measure: wave characteristics.
Definition: MFrequency.h:161
casacore::Quantity casaQuantity(const casac::Quantity &)
casacore::Int sepCommaEmptyToVectorStrings(casacore::Vector< casacore::String > &retStr, const std::string &str)
utility to split a single string to multiple if they are, or empty space seperated.
A holder for a value of any basic Casacore data type.
Definition: ValueHolder.h:67
bool casaMDirection(const ::casac::variant &theVar, casacore::MDirection &theMeas)
casacore::Int sepCommaToVectorStrings(casacore::Vector< casacore::String > &retStr, const std::string &str)
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Record * toRecord(const casac::record &)
::casac::record * fromRecord(const casacore::Record &)
See note in implementation about possible memory leak.
bool casaMEpoch(const ::casac::variant &theVar, casacore::MEpoch &theMeas)
std::vector< double > toVectorDouble(const ::casac::variant &v, const casacore::String &varName)
allow variant types DOUBLE, DOUBLEVEC, INT, INVEC.
std::vector< std::string > fromVectorString(const casacore::Vector< casacore::String > &)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
::casac::Quantity casacQuantity(const casacore::Quantity &)
casacore::Vector< casacore::String > toVectorString(const std::vector< std::string > &)
bool casaMRadialVelocity(const ::casac::variant &theVar, casacore::MRadialVelocity &theMeas)
casacore::Bool toCasaVectorQuantity(const ::casac::variant &theval, casacore::Vector< casacore::Quantity > &theQuants)
makes a casacore::Vector of casacore::Quantity out of strings or vector of such or later records ...
bool MDirection2str(const casacore::MDirection &in, std::string &out)
casacore::Quantum< casacore::Vector< casacore::Double > > casaQuantumVector(const casac::variant &)
::casac::record * recordFromQuantity(const casacore::Quantity q)
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42