51 out <<
object.getInt() <<
" " <<
object.getString();
57 std::string theString;
60 object.setInt(theInt);
61 object.setString(theString);
73 int main(
int argc,
char* argv[])
89 myPL.set<
int>(
"my int", 1);
90 myPL.set<
unsigned int>(
"my unsigned int", 1);
91 myPL.set<
short int>(
"my short int", 1);
92 myPL.set<
short>(
"my short", 1);
93 myPL.set<
unsigned short int>(
"my unsigned short int", 1);
94 myPL.set<
unsigned short>(
"my unsigned short", 1);
95 myPL.set<
long int>(
"my long int", 1);
96 myPL.set<
long>(
"my long", 1);
97 myPL.set<
unsigned long int>(
"my unsigned long int", 1);
98 myPL.set<
unsigned long>(
"my unsigned long", 1);
99 myPL.set<
long long int>(
"my long long int", 1);
100 myPL.set<
long long>(
"my long long", 1);
101 myPL.set<
unsigned long long int>(
"my unsigned long long int", 1);
102 myPL.set<
unsigned long long>(
"my unsigned long long", 1);
103 myPL.set<
float>(
"my float", 4.3);
104 myPL.set<
double>(
"my double", 4.3);
105 myPL.set(
"my string",
"hello");
106 myPL.set(
"my char",
'c');
107 myPL.set(
"my bool",
true);
110 myPL.set<Array<int> >(
"my array int", tuple<int>(1, 2));
111 myPL.set<Array<unsigned int> >(
"my array unsigned int",
112 tuple<unsigned int>(1));
113 myPL.set<Array<short int> > (
"my array short int",
114 tuple<short int>(1, 2));
115 myPL.set<Array<unsigned short int> > (
"my array unsigned short int",
116 tuple<unsigned short int>(1, 2));
117 myPL.set<Array<long int> >(
"my array long int",
118 tuple<long int>(1, 2));
119 myPL.set<Array<unsigned long int> >(
"my array unsigned long int",
120 tuple<unsigned long int>(1, 2));
121 myPL.set<Array<long long int> >(
"my array long long int",
122 tuple<long long int>(1, 2));
123 myPL.set<Array<unsigned long long int> >(
"my array unsigned long long int",
124 tuple<unsigned long long>(1, 2));
125 myPL.set<Array<float> >(
"my array float", tuple<float>(1,1, 2.2));
126 myPL.set<Array<double> >(
"my array double", tuple<double>(1,1, 2.2));
127 myPL.set<Array<std::string> >(
"my array string",
128 tuple<std::string>(
"hello",
"world"));
133 myPL.set(
"my custom data", sampleCustom);
145 Teuchos::writeParameterListToXmlFile(myPL,
"xml_data_types_test_list.xml");
148 Teuchos::writeParameterListToXmlOStream(
152 const RCP<ParameterList> readPL =
153 Teuchos::getParametersFromXmlFile(
"xml_data_types_test_list.xml");
155 std::cout << *readPL;
159 std::cout <<
"Huzzah!\n";
164 const int myInt = readPL->get<
int>(
"my int");
165 std::cout <<
"myInt = " << myInt <<
"\n";
166 const unsigned int myUnsignedInt = readPL->get<
unsigned int>(
"my unsigned int");
167 std::cout <<
"myUnsignedInt = " << myUnsignedInt <<
"\n";
168 const short int myShortInt = readPL->get<
short int>(
"my short int");
169 std::cout <<
"myShortInt = " << myShortInt <<
"\n";
170 const short int myShort = readPL->get<
short>(
"my short");
171 std::cout <<
"myShort = " << myShort <<
"\n";
172 const unsigned short int myUnsignedShortInt = readPL->get<
unsigned short int>(
"my unsigned short int");
173 std::cout <<
"myUnsignedShortInt = " << myUnsignedShortInt <<
"\n";
174 const unsigned short int myUnsignedShort = readPL->get<
unsigned short>(
"my unsigned short");
175 std::cout <<
"myUnsignedShort = " << myUnsignedShort <<
"\n";
176 const long int myLongInt = readPL->get<
long int>(
"my long int");
177 std::cout <<
"myLongInt = " << myLongInt <<
"\n";
178 const long int myLong = readPL->get<
long>(
"my long");
179 std::cout <<
"myLong = " << myLong <<
"\n";
180 const unsigned long int myUnsignedLongInt = readPL->get<
unsigned long int>(
"my unsigned long int");
181 std::cout <<
"myUnsignedLongInt = " << myUnsignedLongInt <<
"\n";
182 const unsigned long myUnsignedLong = readPL->get<
unsigned long>(
"my unsigned long");
183 std::cout <<
"myUnsignedLong = " << myUnsignedLong <<
"\n";
184 const long long int myLongLongInt = readPL->get<
long long int>(
"my long long int");
185 std::cout <<
"myLongLongInt = " << myLongLongInt <<
"\n";
186 const long long int myLongLong = readPL->get<
long long>(
"my long long");
187 std::cout <<
"myLongLong = " << myLongLong <<
"\n";
188 const unsigned long long int myUnsignedLongLongInt = readPL->get<
unsigned long long int>(
"my unsigned long long int");
189 std::cout <<
"myUnsignedLongLongInt = " << myUnsignedLongLongInt <<
"\n";
190 const unsigned long long myUnsignedLongLong = readPL->get<
unsigned long long>(
"my unsigned long long");
191 std::cout <<
"myUnsignedLongLong = " << myUnsignedLongLong <<
"\n";
192 const float myFloat = readPL->get<
float>(
"my float");
193 std::cout <<
"myFloat = " << myFloat <<
"\n";
194 const double myDouble = readPL->get<
double>(
"my double");
195 std::cout <<
"myDouble = " << myDouble <<
"\n";
196 const std::string myString = readPL->get<std::string>(
"my string");
197 std::cout <<
"myString = " << myString <<
"\n";
198 const char myChar = readPL->get<
char>(
"my char");
199 std::cout <<
"myChar = " << myChar <<
"\n";
200 const bool myBool = readPL->get<
bool>(
"my bool");
201 std::cout <<
"myBool = " << myBool <<
"\n";
202 const Array<int> myIntArray = readPL->get<Array<int> >(
"my array int");
203 std::cout <<
"myIntArray = " << myIntArray <<
"\n";
204 const Array<float> myFloatArray = readPL->get<Array<float> >(
"my array float");
205 std::cout <<
"myFloatArray = " << myFloatArray <<
"\n";
206 const Array<double> myDoubleArray = readPL->get<Array<double> >(
"my array double");
207 std::cout <<
"myDoubleArray = " << myDoubleArray <<
"\n";
208 const Array<std::string> myStringArray = readPL->get<Array<std::string> >(
"my array string");
209 std::cout <<
"myStringArray = " << myStringArray <<
"\n";
220 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
CustomDataType(int theInt, std::string theString)
std::istringstream & operator>>(std::istringstream &in, Array< T > &array)
A wrapper around the fromStringToArray function which allows the operator>> to be used on Arrays...
Simple helper functions that make it easy to read and write XML to and from a parameterlist.
Templated Parameter List class.
std::string getString() const
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
bool operator==(const CustomDataType &other) const
std::string Teuchos_Version()
A list of parameters of arbitrary type.
int main(int argc, char *argv[])
#define TEUCHOS_ADD_TYPE_CONVERTER(T)
void setString(std::string theString)
Templated array class derived from the STL std::vector.
Smart reference counting pointer class for automatic garbage collection.
Definition of Teuchos::as, for conversions between types.
std::ostream & operator<<(std::ostream &os, const any &rhs)
Writes "any" input rhs to the output stream os.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes...