casa  $Rev:20696$
CasacSupport.h
Go to the documentation of this file.
00001 #include <string>
00002 #include <vector>
00003 #include <casa/Arrays/Vector.h>
00004 #include <casa/BasicSL/String.h>
00005 #include <casa/Quanta/Quantum.h>
00006 #include <measures/Measures/MDirection.h>
00007 #include <measures/Measures/MPosition.h>
00008 #include <measures/Measures/MFrequency.h>
00009 #include <measures/Measures/MRadialVelocity.h>
00010 #include <measures/Measures/MEpoch.h>
00011 #include <casac/Quantity.h>
00012 #include <xmlcasa/record.h>
00013 
00014 // Conversions utilities
00015 
00016 namespace casa {
00017 
00018 class Record;
00019 class ValueHolder;
00020 
00021 Vector<String>    toVectorString(const std::vector<std::string> &);
00022 std::vector<std::string> fromVectorString(const Vector<String> &);
00023  String toCasaString(const casac::variant &);
00024 
00025 Quantity          casaQuantity(const casac::Quantity &);
00026 
00027 // Constructs and returns a Quantity from its input.  It will throw an
00028 // exception if given a malformed string or string vector, but otherwise will
00029 // generate a default Quantity (0.0) for unhandled variants.
00030 Quantity          casaQuantity(const casac::variant &);
00031 
00032  Quantum<Vector<Double> > casaQuantumVector(const casac::variant &);
00033 
00034 ::casac::Quantity casacQuantity(const Quantity &);
00035 
00036 // See note in implementation about possible memory leak.
00037 ::casac::record  *fromRecord(const Record &);
00038 // makes a Vector of Quantity out of strings or vector of such or later records
00039  Bool toCasaVectorQuantity(const ::casac::variant& theval, 
00040                            casa::Vector<casa::Quantity>& theQuants);
00041 
00042 ::casac::record* recordFromQuantity(const Quantity q);
00043 ::casac::record* recordFromQuantity(const Quantum<Vector<Double> >& q);
00044 
00045 Record           *toRecord(const casac::record &);
00046 ValueHolder      *toValueHolder(const casac::variant&);
00047 ::casac::variant *fromValueHolder(const ValueHolder &);
00048 Bool             casaMDirection(const ::casac::variant& theVar, 
00049                                             MDirection& theMeas);
00050 Bool             ang_as_formatted_str(string& out, const casa::Quantity& qang,
00051                                       const std::string& format, const Int precision);
00052 Bool             MDirection2str(const MDirection& in, std::string& out);
00053 Bool             casaMFrequency(const ::casac::variant& theVar, 
00054                                 MFrequency& theMeas);
00055 Bool             casaMPosition(const ::casac::variant& theVar, 
00056                                MPosition& theMeas);
00057 Bool             casaMRadialVelocity(const ::casac::variant& theVar, 
00058                                             MRadialVelocity& theMeas);
00059 Bool             casaMEpoch(const ::casac::variant& theVar, 
00060                             MEpoch& theMeas);
00061  //utility to split a single string to multiple if they are , or empty space 
00062  //seperated. if commaOnly = True, only seperate on commas, not empty space
00063  Int sepCommaEmptyToVectorStrings(Vector<String>& retStr, 
00064                                   const std::string& str);
00065 
00066  Int sepCommaToVectorStrings(Vector<String>& retStr,
00067                                   const std::string& str);
00068 
00069  // allow variant types DOUBLE, DOUBLEVEC, INT, INVEC. An empty string or a BOOLVEC
00070  // will return a 0 element vector. Any other type will cause an exception to be thrown.
00071  vector<double> toVectorDouble(const ::casac::variant& v, const String& varName);
00072 
00073 // Allow variant types STRING or STRINGVEC. BOOLVEC will return a 0 element vector.
00074  // all other types will cause an excpetion to be thrown.
00075  vector<string> toVectorString(const ::casac::variant& v, const String& varName);
00076 
00077  // Allow variant types INT or INTVEC. An empty string or a BOOLVEC
00078  // will return a 0 element vector. Any other type will cause an exception to be thrown.
00079  vector<int> toVectorInt(const ::casac::variant& v, const String& varName);
00080 
00081 
00082 
00083 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines