84 out <<
object.getInt() <<
" " <<
object.getString();
90 std::string theString;
93 object.setInt(theInt);
94 object.setString(theString);
106 int main(
int argc,
char* argv[])
109 using Teuchos::tuple;
119 myPL.set<
int>(
"my int", 1);
120 myPL.set<
unsigned int>(
"my unsigned int", 1);
121 myPL.set<
short int>(
"my short int", 1);
122 myPL.set<
short>(
"my short", 1);
123 myPL.set<
unsigned short int>(
"my unsigned short int", 1);
124 myPL.set<
unsigned short>(
"my unsigned short", 1);
125 myPL.set<
long int>(
"my long int", 1);
126 myPL.set<
long>(
"my long", 1);
127 myPL.set<
unsigned long int>(
"my unsigned long int", 1);
128 myPL.set<
unsigned long>(
"my unsigned long", 1);
129 #ifdef HAVE_TEUCHOS_LONG_LONG_INT
130 myPL.set<
long long int>(
"my long long int", 1);
131 myPL.set<
long long>(
"my long long", 1);
132 myPL.set<
unsigned long long int>(
"my unsigned long long int", 1);
133 myPL.set<
unsigned long long>(
"my unsigned long long", 1);
134 #endif // HAVE_TEUCHOS_LONG_LONG_INT
135 myPL.set<
float>(
"my float", 4.3);
136 myPL.set<
double>(
"my double", 4.3);
137 myPL.set(
"my string",
"hello");
138 myPL.set(
"my char",
'c');
139 myPL.set(
"my bool",
true);
142 myPL.set<Array<int> >(
"my array int", tuple<int>(1, 2));
143 myPL.set<Array<unsigned int> >(
"my array unsigned int",
144 tuple<unsigned int>(1));
145 myPL.set<Array<short int> > (
"my array short int",
146 tuple<short int>(1, 2));
147 myPL.set<Array<unsigned short int> > (
"my array unsigned short int",
148 tuple<unsigned short int>(1, 2));
149 myPL.set<Array<long int> >(
"my array long int",
150 tuple<long int>(1, 2));
151 myPL.set<Array<unsigned long int> >(
"my array unsigned long int",
152 tuple<unsigned long int>(1, 2));
153 #ifdef HAVE_TEUCHOS_LONG_LONG_INT
154 myPL.set<Array<long long int> >(
"my array long long int",
155 tuple<long long int>(1, 2));
156 myPL.set<Array<unsigned long long int> >(
"my array unsigned long long int",
157 tuple<unsigned long long>(1, 2));
158 #endif // HAVE_TEUCHOS_LONG_LONG_INT
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";
196 std::cerr <<
"Uh oh...";
201 const int myInt = readPL->get<
int>(
"my int");
202 std::cout <<
"myInt = " << myInt <<
"\n";
203 const unsigned int myUnsignedInt = readPL->get<
unsigned int>(
"my unsigned int");
204 std::cout <<
"myUnsignedInt = " << myUnsignedInt <<
"\n";
205 const short int myShortInt = readPL->get<
short int>(
"my short int");
206 std::cout <<
"myShortInt = " << myShortInt <<
"\n";
207 const short int myShort = readPL->get<
short>(
"my short");
208 std::cout <<
"myShort = " << myShort <<
"\n";
209 const unsigned short int myUnsignedShortInt = readPL->get<
unsigned short int>(
"my unsigned short int");
210 std::cout <<
"myUnsignedShortInt = " << myUnsignedShortInt <<
"\n";
211 const unsigned short int myUnsignedShort = readPL->get<
unsigned short>(
"my unsigned short");
212 std::cout <<
"myUnsignedShort = " << myUnsignedShort <<
"\n";
213 const long int myLongInt = readPL->get<
long int>(
"my long int");
214 std::cout <<
"myLongInt = " << myLongInt <<
"\n";
215 const long int myLong = readPL->get<
long>(
"my long");
216 std::cout <<
"myLong = " << myLong <<
"\n";
217 const unsigned long int myUnsignedLongInt = readPL->get<
unsigned long int>(
"my unsigned long int");
218 std::cout <<
"myUnsignedLongInt = " << myUnsignedLongInt <<
"\n";
219 const unsigned long myUnsignedLong = readPL->get<
unsigned long>(
"my unsigned long");
220 std::cout <<
"myUnsignedLong = " << myUnsignedLong <<
"\n";
221 #ifdef HAVE_TEUCHOS_LONG_LONG_INT
222 const long long int myLongLongInt = readPL->get<
long long int>(
"my long long int");
223 std::cout <<
"myLongLongInt = " << myLongLongInt <<
"\n";
224 const long long int myLongLong = readPL->get<
long long>(
"my long long");
225 std::cout <<
"myLongLong = " << myLongLong <<
"\n";
226 const unsigned long long int myUnsignedLongLongInt = readPL->get<
unsigned long long int>(
"my unsigned long long int");
227 std::cout <<
"myUnsignedLongLongInt = " << myUnsignedLongLongInt <<
"\n";
228 const unsigned long long myUnsignedLongLong = readPL->get<
unsigned long long>(
"my unsigned long long");
229 std::cout <<
"myUnsignedLongLong = " << myUnsignedLongLong <<
"\n";
230 #endif // HAVE_TEUCHOS_LONG_LONG_INT
231 const float myFloat = readPL->get<
float>(
"my float");
232 std::cout <<
"myFloat = " << myFloat <<
"\n";
233 const double myDouble = readPL->get<
double>(
"my double");
234 std::cout <<
"myDouble = " << myDouble <<
"\n";
235 const std::string myString = readPL->get<std::string>(
"my string");
236 std::cout <<
"myString = " << myString <<
"\n";
237 const char myChar = readPL->get<
char>(
"my char");
238 std::cout <<
"myChar = " << myChar <<
"\n";
239 const bool myBool = readPL->get<
bool>(
"my bool");
240 std::cout <<
"myBool = " << myBool <<
"\n";
241 const Array<int> myIntArray = readPL->get<Array<int> >(
"my array int");
242 std::cout <<
"myIntArray = " << myIntArray <<
"\n";
243 const Array<float> myFloatArray = readPL->get<Array<float> >(
"my array float");
244 std::cout <<
"myFloatArray = " << myFloatArray <<
"\n";
245 const Array<double> myDoubleArray = readPL->get<Array<double> >(
"my array double");
246 std::cout <<
"myDoubleArray = " << myDoubleArray <<
"\n";
247 const Array<std::string> myStringArray = readPL->get<Array<std::string> >(
"my array string");
248 std::cout <<
"myStringArray = " << myStringArray <<
"\n";
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
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.
Memory-safe templated array class that encapsulates std::vector.