85 out <<
object.getInt() <<
" " <<
object.getString();
91 std::string theString;
94 object.setInt(theInt);
95 object.setString(theString);
107 int main(
int argc,
char* argv[])
110 using Teuchos::tuple;
115 bool success =
false;
123 myPL.set<
int>(
"my int", 1);
124 myPL.set<
unsigned int>(
"my unsigned int", 1);
125 myPL.set<
short int>(
"my short int", 1);
126 myPL.set<
short>(
"my short", 1);
127 myPL.set<
unsigned short int>(
"my unsigned short int", 1);
128 myPL.set<
unsigned short>(
"my unsigned short", 1);
129 myPL.set<
long int>(
"my long int", 1);
130 myPL.set<
long>(
"my long", 1);
131 myPL.set<
unsigned long int>(
"my unsigned long int", 1);
132 myPL.set<
unsigned long>(
"my unsigned long", 1);
133 myPL.set<
long long int>(
"my long long int", 1);
134 myPL.set<
long long>(
"my long long", 1);
135 myPL.set<
unsigned long long int>(
"my unsigned long long int", 1);
136 myPL.set<
unsigned long long>(
"my unsigned long long", 1);
137 myPL.set<
float>(
"my float", 4.3);
138 myPL.set<
double>(
"my double", 4.3);
139 myPL.set(
"my string",
"hello");
140 myPL.set(
"my char",
'c');
141 myPL.set(
"my bool",
true);
144 myPL.set<Array<int> >(
"my array int", tuple<int>(1, 2));
145 myPL.set<Array<unsigned int> >(
"my array unsigned int",
146 tuple<unsigned int>(1));
147 myPL.set<Array<short int> > (
"my array short int",
148 tuple<short int>(1, 2));
149 myPL.set<Array<unsigned short int> > (
"my array unsigned short int",
150 tuple<unsigned short int>(1, 2));
151 myPL.set<Array<long int> >(
"my array long int",
152 tuple<long int>(1, 2));
153 myPL.set<Array<unsigned long int> >(
"my array unsigned long int",
154 tuple<unsigned long int>(1, 2));
155 myPL.set<Array<long long int> >(
"my array long long int",
156 tuple<long long int>(1, 2));
157 myPL.set<Array<unsigned long long int> >(
"my array unsigned long long int",
158 tuple<unsigned long long>(1, 2));
159 myPL.set<Array<float> >(
"my array float", tuple<float>(1,1, 2.2));
160 myPL.set<Array<double> >(
"my array double", tuple<double>(1,1, 2.2));
161 myPL.set<Array<std::string> >(
"my array string",
162 tuple<std::string>(
"hello",
"world"));
167 myPL.set(
"my custom data", sampleCustom);
179 Teuchos::writeParameterListToXmlFile(myPL,
"xml_data_types_test_list.xml");
182 Teuchos::writeParameterListToXmlOStream(
186 const RCP<ParameterList> readPL =
187 Teuchos::getParametersFromXmlFile(
"xml_data_types_test_list.xml");
189 std::cout << *readPL;
193 std::cout <<
"Huzzah!\n";
198 const int myInt = readPL->get<
int>(
"my int");
199 std::cout <<
"myInt = " << myInt <<
"\n";
200 const unsigned int myUnsignedInt = readPL->get<
unsigned int>(
"my unsigned int");
201 std::cout <<
"myUnsignedInt = " << myUnsignedInt <<
"\n";
202 const short int myShortInt = readPL->get<
short int>(
"my short int");
203 std::cout <<
"myShortInt = " << myShortInt <<
"\n";
204 const short int myShort = readPL->get<
short>(
"my short");
205 std::cout <<
"myShort = " << myShort <<
"\n";
206 const unsigned short int myUnsignedShortInt = readPL->get<
unsigned short int>(
"my unsigned short int");
207 std::cout <<
"myUnsignedShortInt = " << myUnsignedShortInt <<
"\n";
208 const unsigned short int myUnsignedShort = readPL->get<
unsigned short>(
"my unsigned short");
209 std::cout <<
"myUnsignedShort = " << myUnsignedShort <<
"\n";
210 const long int myLongInt = readPL->get<
long int>(
"my long int");
211 std::cout <<
"myLongInt = " << myLongInt <<
"\n";
212 const long int myLong = readPL->get<
long>(
"my long");
213 std::cout <<
"myLong = " << myLong <<
"\n";
214 const unsigned long int myUnsignedLongInt = readPL->get<
unsigned long int>(
"my unsigned long int");
215 std::cout <<
"myUnsignedLongInt = " << myUnsignedLongInt <<
"\n";
216 const unsigned long myUnsignedLong = readPL->get<
unsigned long>(
"my unsigned long");
217 std::cout <<
"myUnsignedLong = " << myUnsignedLong <<
"\n";
218 const long long int myLongLongInt = readPL->get<
long long int>(
"my long long int");
219 std::cout <<
"myLongLongInt = " << myLongLongInt <<
"\n";
220 const long long int myLongLong = readPL->get<
long long>(
"my long long");
221 std::cout <<
"myLongLong = " << myLongLong <<
"\n";
222 const unsigned long long int myUnsignedLongLongInt = readPL->get<
unsigned long long int>(
"my unsigned long long int");
223 std::cout <<
"myUnsignedLongLongInt = " << myUnsignedLongLongInt <<
"\n";
224 const unsigned long long myUnsignedLongLong = readPL->get<
unsigned long long>(
"my unsigned long long");
225 std::cout <<
"myUnsignedLongLong = " << myUnsignedLongLong <<
"\n";
226 const float myFloat = readPL->get<
float>(
"my float");
227 std::cout <<
"myFloat = " << myFloat <<
"\n";
228 const double myDouble = readPL->get<
double>(
"my double");
229 std::cout <<
"myDouble = " << myDouble <<
"\n";
230 const std::string myString = readPL->get<std::string>(
"my string");
231 std::cout <<
"myString = " << myString <<
"\n";
232 const char myChar = readPL->get<
char>(
"my char");
233 std::cout <<
"myChar = " << myChar <<
"\n";
234 const bool myBool = readPL->get<
bool>(
"my bool");
235 std::cout <<
"myBool = " << myBool <<
"\n";
236 const Array<int> myIntArray = readPL->get<Array<int> >(
"my array int");
237 std::cout <<
"myIntArray = " << myIntArray <<
"\n";
238 const Array<float> myFloatArray = readPL->get<Array<float> >(
"my array float");
239 std::cout <<
"myFloatArray = " << myFloatArray <<
"\n";
240 const Array<double> myDoubleArray = readPL->get<Array<double> >(
"my array double");
241 std::cout <<
"myDoubleArray = " << myDoubleArray <<
"\n";
242 const Array<std::string> myStringArray = readPL->get<Array<std::string> >(
"my array string");
243 std::cout <<
"myStringArray = " << myStringArray <<
"\n";
254 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...