59 #ifdef HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
60 #include "yaml-cpp/yaml.h"
61 #endif // HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
67 #ifdef HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
82 static T eval(::YAML::Node
const& node) {
84 if (node.Tag() ==
"!") {
85 throw std::runtime_error(
"quoted_as from quoted string to number");
92 struct QuotedAs<std::string> {
94 static std::string eval(::YAML::Node
const& node) {
return node.as<std::string>(); }
98 static T quoted_as(::YAML::Node
const& node) {
return QuotedAs<T>::eval(node); }
104 for(::YAML::const_iterator it = node.begin(); it != node.end(); it++)
111 bool checkYamlTwoDArrayIsRagged(const ::YAML::Node& node)
114 for (::YAML::const_iterator it = node.begin(); it != node.end(); ++it)
116 if (it->size() != node.begin()->size())
131 for (::YAML::const_iterator rit = node.begin(); rit != node.end(); ++rit)
134 for (::YAML::const_iterator cit = rit->begin(); cit != rit->end(); ++cit)
136 arr(i, j) = quoted_as<T>(*cit);
144 int getYamlArrayDim(const ::YAML::Node& node)
147 if (node.Type() == ::YAML::NodeType::Sequence)
150 if (node.begin()->Type() == ::YAML::NodeType::Sequence)
153 if (node.begin()->begin()->Type() == ::YAML::NodeType::Sequence)
162 template <
typename tarray_t,
typename T>
163 tarray_t getYaml2DRaggedArray(::YAML::Node node,
int ndim, std::string key)
168 for (::YAML::const_iterator it1 = node.begin(); it1 != node.end(); ++it1) {
169 for (::YAML::const_iterator it2 = it1->begin(); it2 != it1->end(); ++it2) {
171 } base_arr.push_back(sub_arr);
177 throw YamlSequenceError(std::string(
"MDArray \"" + key +
"\" must have dim 2."));
185 template <
typename tarray_t,
typename T>
186 tarray_t getYaml3DArray(::YAML::Node node,
int ndim, std::string key)
192 for (::YAML::const_iterator it1 = node.begin(); it1 != node.end(); ++it1) {
193 for (::YAML::const_iterator it2 = it1->begin(); it2 != it1->end(); ++it2) {
194 for (::YAML::const_iterator it3 = it2->begin(); it3 != it2->end(); ++it3) {
195 sub_sub_arr.
push_back(quoted_as<T>(*it3));
198 } base_arr.push_back(sub_arr);
204 throw YamlSequenceError(std::string(
"MDArray \"" + key +
"\" must have dim 3."));
209 template <
typename T>
210 void safe_set_entry(ParameterList& list, std::string
const& name_in, T
const& entry_in) {
212 "Parameter \"" << name_in <<
"\" already exists in list \"" << list.name() <<
"\"\n");
213 list.set(name_in, entry_in);
215 #endif // HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
217 std::string remove_trailing_whitespace(std::string
const& in) {
218 std::size_t new_end = 0;
219 for (std::size_t ri = 0; ri < in.size(); ++ri) {
220 std::size_t i = in.size() - 1 - ri;
221 if (in[i] !=
' ' && in[i] !=
'\t') {
226 return in.substr(0, new_end);
229 std::string remove_trailing_whitespace_and_newlines(std::string
const& in) {
230 std::size_t new_end = 0;
231 for (std::size_t ri = 0; ri < in.size(); ++ri) {
232 std::size_t i = in.size() - 1 - ri;
233 if (in[i] !=
' ' && in[i] !=
'\t' && in[i] !=
'\n' && in[i] !=
'\r') {
238 return in.substr(0, new_end);
241 template <
typename T>
242 bool is_parseable_as(std::string
const& text) {
243 std::istringstream ss(text);
245 ss >> std::noskipws >> val;
246 return ss.eof() && !ss.fail();
250 bool is_parseable_as<int>(std::string
const& text) {
251 std::istringstream ss(text);
252 using LL =
long long;
254 ss >> std::noskipws >> val;
255 return ss.eof() && !ss.fail() &&
256 (val >= LL(std::numeric_limits<int>::min())) &&
257 (val <= LL(std::numeric_limits<int>::max()));
260 template <
typename T>
261 T parse_as(std::string
const& text) {
262 std::istringstream ss(text);
269 static char my_tolower(
char ch)
271 return std::tolower(static_cast<unsigned char>(ch));
275 static bool my_isdigit(
char ch)
277 return std::isdigit(static_cast<unsigned char>(ch));
281 bool is_parseable_as<bool>(std::string
const& text) {
283 for (std::size_t i = 0; i < text.size(); ++i) {
284 lower.push_back(my_tolower(text[i]));
286 return lower ==
"true" || lower ==
"yes" ||
287 lower ==
"false" || lower ==
"no";
291 bool parse_as<bool>(std::string
const& text) {
293 for (std::size_t i = 0; i < text.size(); ++i) {
294 lower.push_back(my_tolower(text[i]));
296 return !(lower ==
"false" || lower ==
"no");
301 ParameterEntry value;
322 int infer_type()
const {
323 if (tag_type != -1) {
329 if (is_parseable_as<bool>(text)) {
332 if (is_parseable_as<int>(text)) {
335 if (is_parseable_as<long long>(text)) {
338 if (is_parseable_as<double>(text)) {
345 bool operator==(Scalar
const&, Scalar
const&) {
return false; }
346 std::ostream& operator<<(std::ostream& os, Scalar
const&) {
return os; }
348 void safe_set_entry(ParameterList& list, std::string
const& name_in, ParameterEntry
const& entry_in) {
350 "Parameter \"" << name_in <<
"\" already exists in list \"" << list.name() <<
"\"\n");
351 list.setEntry(name_in, entry_in);
354 namespace YAMLParameterList {
358 Reader():Teuchos::
Reader(Teuchos::YAML::ask_reader_tables()) {}
365 virtual void at_shift(any& result_any,
int token, std::string& text) {
368 case Teuchos::YAML::TOK_NEWLINE: {
369 std::string& result = make_any_ref<std::string>(result_any);
373 case Teuchos::YAML::TOK_SPACE:
374 case Teuchos::YAML::TOK_OTHER: {
375 result_any = text.at(0);
380 virtual void at_reduce(any& result_any,
int prod, std::vector<any>& rhs) {
383 case Teuchos::YAML::PROD_DOC:
384 case Teuchos::YAML::PROD_DOC2: {
385 std::size_t offset = prod == Teuchos::YAML::PROD_DOC2 ? 1 : 0;
387 swap(result_any, rhs.at(offset));
391 case Teuchos::YAML::PROD_TOP_BMAP: {
394 PLPair& pair = any_ref_cast<PLPair>(rhs.at(0));
395 any& pair_rhs_any = pair.value.getAny(
false);
396 result_any = pair_rhs_any;
399 case Teuchos::YAML::PROD_TOP_FIRST: {
400 if (rhs.at(0).type() ==
typeid(ParameterList)) {
401 swap(result_any, rhs.at(0));
405 case Teuchos::YAML::PROD_TOP_NEXT: {
406 if (rhs.at(1).type() ==
typeid(ParameterList)) {
408 "Can't specify multiple top-level ParameterLists in one YAML file!\n");
409 swap(result_any, rhs.at(1));
411 swap(result_any, rhs.at(0));
415 case Teuchos::YAML::PROD_BMAP_FIRST:
416 case Teuchos::YAML::PROD_FMAP_FIRST: {
418 map_first_item(result_any, rhs.at(0));
422 case Teuchos::YAML::PROD_BMAP_NEXT: {
423 map_next_item(result_any, rhs.at(0), rhs.at(1));
426 case Teuchos::YAML::PROD_FMAP_NEXT: {
427 map_next_item(result_any, rhs.at(0), rhs.at(3));
430 case Teuchos::YAML::PROD_BMAP_SCALAR:
431 case Teuchos::YAML::PROD_FMAP_SCALAR:
432 case Teuchos::YAML::PROD_FMAP_FMAP:
433 case Teuchos::YAML::PROD_FMAP_FSEQ: {
434 int scalar_type = interpret_tag(rhs.at(3));
435 map_item(result_any, rhs.at(0), rhs.at(4), scalar_type);
438 case Teuchos::YAML::PROD_BMAP_BSCALAR: {
439 map_item(result_any, rhs.at(0), rhs.at(3), Scalar::STRING);
442 case Teuchos::YAML::PROD_BMAP_BVALUE: {
443 map_item(result_any, rhs.at(0), rhs.at(4));
446 case Teuchos::YAML::PROD_BVALUE_EMPTY: {
447 result_any = ParameterList();
450 case Teuchos::YAML::PROD_BVALUE_BMAP:
451 case Teuchos::YAML::PROD_BVALUE_BSEQ: {
452 swap(result_any, rhs.at(1));
455 case Teuchos::YAML::PROD_BMAP_FMAP: {
456 map_item(result_any, rhs.at(0), rhs.at(4));
459 case Teuchos::YAML::PROD_BMAP_FSEQ: {
461 rhs.at(4).type() ==
typeid(Array<Array<Scalar>>));
462 int scalar_type = interpret_tag(rhs.at(3));
463 map_item(result_any, rhs.at(0), rhs.at(4), scalar_type);
466 case Teuchos::YAML::PROD_BSEQ_FIRST: {
467 seq_first_item(result_any, rhs.at(0));
470 case Teuchos::YAML::PROD_BSEQ_NEXT: {
471 seq_next_item(result_any, rhs.at(0), rhs.at(1));
474 case Teuchos::YAML::PROD_BSEQ_SCALAR: {
475 swap(result_any, rhs.at(3));
476 Scalar& scalar = any_ref_cast<Scalar>(result_any);
477 scalar.tag_type = interpret_tag(rhs.at(2));
480 case Teuchos::YAML::PROD_BSEQ_BSCALAR: {
481 swap(result_any, rhs.at(2));
484 case Teuchos::YAML::PROD_BSEQ_BMAP:
485 case Teuchos::YAML::PROD_BSEQ_BMAP_TRAIL:
486 case Teuchos::YAML::PROD_BSEQ_FMAP: {
487 throw ParserFail(
"Can't interpret a map inside a sequence as a Teuchos Parameter");
489 case Teuchos::YAML::PROD_BSEQ_BSEQ: {
490 swap(result_any, rhs.at(3));
493 case Teuchos::YAML::PROD_BSEQ_BSEQ_TRAIL: {
494 swap(result_any, rhs.at(4));
497 case Teuchos::YAML::PROD_BSEQ_FSEQ: {
498 swap(result_any, rhs.at(3));
501 case Teuchos::YAML::PROD_FMAP: {
502 swap(result_any, rhs.at(2));
505 case Teuchos::YAML::PROD_FMAP_EMPTY: {
506 result_any = ParameterList();
509 case Teuchos::YAML::PROD_FSEQ: {
510 swap(result_any, rhs.at(2));
512 result_any.type() ==
typeid(Array<Array<Scalar>>));
515 case Teuchos::YAML::PROD_FSEQ_EMPTY: {
516 result_any = Array<Scalar>();
519 case Teuchos::YAML::PROD_FSEQ_FIRST: {
520 seq_first_item(result_any, rhs.at(0));
523 case Teuchos::YAML::PROD_FSEQ_NEXT: {
524 seq_next_item(result_any, rhs.at(0), rhs.at(3));
527 case Teuchos::YAML::PROD_FSEQ_SCALAR: {
528 swap(result_any, rhs.at(1));
529 Scalar& scalar = any_ref_cast<Scalar>(result_any);
530 scalar.tag_type = interpret_tag(rhs.at(0));
533 case Teuchos::YAML::PROD_FSEQ_FSEQ:
534 case Teuchos::YAML::PROD_FSEQ_FMAP: {
535 swap(result_any, rhs.at(1));
538 case Teuchos::YAML::PROD_SCALAR_QUOTED:
539 case Teuchos::YAML::PROD_MAP_SCALAR_QUOTED: {
540 swap(result_any, rhs.at(0));
543 case Teuchos::YAML::PROD_SCALAR_RAW:
544 case Teuchos::YAML::PROD_MAP_SCALAR_RAW: {
545 Scalar& scalar = make_any_ref<Scalar>(result_any);
547 scalar.text = any_ref_cast<std::string>(rhs.at(0));
548 scalar.text += any_ref_cast<std::string>(rhs.at(1));
549 if (prod == Teuchos::YAML::PROD_MAP_SCALAR_RAW) {
550 scalar.text += any_ref_cast<std::string>(rhs.at(2));
552 scalar.text = remove_trailing_whitespace(scalar.text);
553 scalar.source = Scalar::RAW;
554 scalar.tag_type = -1;
557 case Teuchos::YAML::PROD_SCALAR_HEAD_OTHER:
558 case Teuchos::YAML::PROD_SCALAR_HEAD_DOT:
559 case Teuchos::YAML::PROD_SCALAR_HEAD_DASH:
560 case Teuchos::YAML::PROD_SCALAR_HEAD_DOT_DOT: {
562 if (prod == Teuchos::YAML::PROD_SCALAR_HEAD_OTHER) offset = 0;
563 else if (prod == Teuchos::YAML::PROD_SCALAR_HEAD_DOT_DOT) offset = 2;
565 char second = any_cast<
char>(rhs.at(offset));
566 std::string& result = make_any_ref<std::string>(result_any);
567 if (prod == Teuchos::YAML::PROD_SCALAR_HEAD_DOT) result +=
'.';
568 else if (prod == Teuchos::YAML::PROD_SCALAR_HEAD_DASH) result +=
'-';
569 else if (prod == Teuchos::YAML::PROD_SCALAR_HEAD_DOT_DOT) result +=
"..";
573 case Teuchos::YAML::PROD_SCALAR_DQUOTED:
574 case Teuchos::YAML::PROD_SCALAR_SQUOTED: {
575 std::string& first = any_ref_cast<std::string>(rhs.at(1));
576 std::string& rest = any_ref_cast<std::string>(rhs.at(2));
577 Scalar& scalar = make_any_ref<Scalar>(result_any);
578 scalar.text += first;
580 if (prod == Teuchos::YAML::PROD_SCALAR_DQUOTED) {
581 scalar.source = Scalar::DQUOTED;
582 }
else if (prod == Teuchos::YAML::PROD_SCALAR_SQUOTED) {
583 scalar.source = Scalar::SQUOTED;
585 scalar.tag_type = -1;
588 case Teuchos::YAML::PROD_MAP_SCALAR_ESCAPED_EMPTY: {
589 result_any = std::string();
592 case Teuchos::YAML::PROD_MAP_SCALAR_ESCAPED_NEXT: {
593 swap(result_any, rhs.at(0));
594 std::string& str = any_ref_cast<std::string>(result_any);
596 str += any_ref_cast<std::string>(rhs.at(2));
599 case Teuchos::YAML::PROD_TAG: {
600 swap(result_any, rhs.at(2));
603 case Teuchos::YAML::PROD_BSCALAR: {
604 std::size_t parent_indent_level =
605 this->symbol_indentation_stack.at(
606 this->symbol_indentation_stack.size() - 5);
607 std::string& header = any_ref_cast<std::string>(rhs.at(0));
608 std::string& leading_empties_or_comments =
609 any_ref_cast<std::string>(rhs.at(2));
610 std::string& rest = any_ref_cast<std::string>(rhs.at(4));
611 std::string& content = make_any_ref<std::string>(result_any);
615 header, leading_empties_or_comments, rest,
619 case Teuchos::YAML::PROD_BSCALAR_FIRST: {
620 swap(result_any, rhs.at(0));
624 case Teuchos::YAML::PROD_BSCALAR_NEXT:
625 case Teuchos::YAML::PROD_BSCALAR_LINE:
626 case Teuchos::YAML::PROD_DESCAPE_NEXT:
627 case Teuchos::YAML::PROD_SESCAPE_NEXT: {
628 swap(result_any, rhs.at(0));
629 std::string& str = any_ref_cast<std::string>(result_any);
630 str += any_ref_cast<std::string>(rhs.at(1));
633 case Teuchos::YAML::PROD_BSCALAR_INDENT: {
634 swap(result_any, rhs.at(1));
637 case Teuchos::YAML::PROD_BSCALAR_HEADER_LITERAL:
638 case Teuchos::YAML::PROD_BSCALAR_HEADER_FOLDED: {
639 std::string& result = make_any_ref<std::string>(result_any);
640 if (prod == Teuchos::YAML::PROD_BSCALAR_HEADER_LITERAL) {
645 std::string& rest = any_ref_cast<std::string>(rhs.at(1));
649 case Teuchos::YAML::PROD_DESCAPE: {
650 std::string& str = make_any_ref<std::string>(result_any);
651 std::string& rest = any_ref_cast<std::string>(rhs.at(2));
652 str += any_cast<
char>(rhs.at(1));
656 case Teuchos::YAML::PROD_SESCAPE: {
657 std::string& str = make_any_ref<std::string>(result_any);
658 std::string& rest = any_ref_cast<std::string>(rhs.at(2));
663 case Teuchos::YAML::PROD_OTHER_FIRST:
664 case Teuchos::YAML::PROD_SPACE_PLUS_FIRST: {
665 std::string& str = make_any_ref<std::string>(result_any);
666 str.push_back(any_cast<char>(rhs.at(0)));
669 case Teuchos::YAML::PROD_SCALAR_TAIL_SPACE:
670 case Teuchos::YAML::PROD_SCALAR_TAIL_OTHER:
671 case Teuchos::YAML::PROD_DESCAPED_DQUOTED:
672 case Teuchos::YAML::PROD_DQUOTED_COMMON:
673 case Teuchos::YAML::PROD_SQUOTED_COMMON:
674 case Teuchos::YAML::PROD_ANY_COMMON:
675 case Teuchos::YAML::PROD_COMMON_SPACE:
676 case Teuchos::YAML::PROD_COMMON_OTHER:
677 case Teuchos::YAML::PROD_BSCALAR_HEAD_OTHER: {
678 swap(result_any, rhs.at(0));
682 case Teuchos::YAML::PROD_DQUOTED_NEXT:
683 case Teuchos::YAML::PROD_SQUOTED_NEXT:
684 case Teuchos::YAML::PROD_ANY_NEXT:
685 case Teuchos::YAML::PROD_SCALAR_TAIL_NEXT:
686 case Teuchos::YAML::PROD_SPACE_STAR_NEXT:
687 case Teuchos::YAML::PROD_SPACE_PLUS_NEXT:
688 case Teuchos::YAML::PROD_BSCALAR_HEAD_NEXT: {
690 "leading characters in " << prod <<
": any was empty\n");
691 swap(result_any, rhs.at(0));
692 std::string& str = any_ref_cast<std::string>(result_any);
693 str += any_cast<
char>(rhs.at(1));
696 case Teuchos::YAML::PROD_DQUOTED_EMPTY:
697 case Teuchos::YAML::PROD_SQUOTED_EMPTY:
698 case Teuchos::YAML::PROD_ANY_EMPTY:
699 case Teuchos::YAML::PROD_DESCAPE_EMPTY:
700 case Teuchos::YAML::PROD_SESCAPE_EMPTY:
701 case Teuchos::YAML::PROD_SCALAR_TAIL_EMPTY:
702 case Teuchos::YAML::PROD_SPACE_STAR_EMPTY:
703 case Teuchos::YAML::PROD_BSCALAR_HEAD_EMPTY: {
704 result_any = std::string();
707 case Teuchos::YAML::PROD_DESCAPED_DQUOT:
708 case Teuchos::YAML::PROD_SQUOTED_DQUOT:
709 case Teuchos::YAML::PROD_ANY_DQUOT: {
713 case Teuchos::YAML::PROD_DESCAPED_SLASH:
714 case Teuchos::YAML::PROD_SQUOTED_SLASH:
715 case Teuchos::YAML::PROD_ANY_SLASH: {
719 case Teuchos::YAML::PROD_SCALAR_TAIL_SQUOT:
720 case Teuchos::YAML::PROD_DQUOTED_SQUOT:
721 case Teuchos::YAML::PROD_ANY_SQUOT: {
725 case Teuchos::YAML::PROD_COMMON_COLON: {
729 case Teuchos::YAML::PROD_SCALAR_TAIL_DOT:
730 case Teuchos::YAML::PROD_COMMON_DOT: {
734 case Teuchos::YAML::PROD_SCALAR_TAIL_DASH:
735 case Teuchos::YAML::PROD_COMMON_DASH:
736 case Teuchos::YAML::PROD_BSCALAR_HEAD_DASH: {
740 case Teuchos::YAML::PROD_COMMON_PIPE: {
744 case Teuchos::YAML::PROD_COMMON_LSQUARE: {
748 case Teuchos::YAML::PROD_COMMON_RSQUARE: {
752 case Teuchos::YAML::PROD_COMMON_LCURLY: {
756 case Teuchos::YAML::PROD_COMMON_RCURLY: {
760 case Teuchos::YAML::PROD_COMMON_RANGLE: {
764 case Teuchos::YAML::PROD_COMMON_COMMA: {
768 case Teuchos::YAML::PROD_COMMON_PERCENT: {
772 case Teuchos::YAML::PROD_COMMON_EXCL: {
778 void map_first_item(any& result_any, any& first_item) {
779 ParameterList& list = make_any_ref<ParameterList>(result_any);
781 PLPair& pair = any_ref_cast<PLPair>(first_item);
782 safe_set_entry(list, pair.key, pair.value);
784 void map_next_item(any& result_any, any& items, any& next_item) {
786 swap(result_any, items);
787 ParameterList& list = any_ref_cast<ParameterList>(result_any);
788 PLPair& pair = any_ref_cast<PLPair>(next_item);
789 safe_set_entry(list, pair.key, pair.value);
791 void map_item(any& result_any, any& key_any, any& value_any,
int scalar_type = -1) {
793 PLPair& result = make_any_ref<PLPair>(result_any);
795 std::string& key = any_ref_cast<Scalar>(key_any).text;
796 swap(result.key, key);
798 resolve_map_value(value_any, scalar_type);
799 if (value_any.type() ==
typeid(bool)) {
800 bool value = any_cast<
bool>(value_any);
801 result.value = ParameterEntry(value);
802 }
else if (value_any.type() ==
typeid(int)) {
803 int value = any_cast<
int>(value_any);
804 result.value = ParameterEntry(value);
805 }
else if (value_any.type() ==
typeid(
long long)) {
806 long long value = any_cast<
long long>(value_any);
807 result.value = ParameterEntry(value);
808 }
else if (value_any.type() ==
typeid(double)) {
809 double value = any_cast<
double>(value_any);
810 result.value = ParameterEntry(value);
811 }
else if (value_any.type() ==
typeid(std::string)) {
812 std::string& value = any_ref_cast<std::string >(value_any);
813 result.value = ParameterEntry(value);
814 }
else if (value_any.type() ==
typeid(Array<int>)) {
815 Array<int>& value = any_ref_cast<Array<int> >(value_any);
816 result.value = ParameterEntry(value);
817 }
else if (value_any.type() ==
typeid(Array<long long>)) {
818 Array<long long>& value = any_ref_cast<Array<long long> >(value_any);
819 result.value = ParameterEntry(value);
820 }
else if (value_any.type() ==
typeid(Array<double>)) {
821 Array<double>& value = any_ref_cast<Array<double> >(value_any);
822 result.value = ParameterEntry(value);
823 }
else if (value_any.type() ==
typeid(Array<std::string>)) {
824 Array<std::string>& value = any_ref_cast<Array<std::string> >(value_any);
825 result.value = ParameterEntry(value);
826 }
else if (value_any.type() ==
typeid(TwoDArray<int>)) {
827 TwoDArray<int>& value = any_ref_cast<TwoDArray<int> >(value_any);
828 result.value = ParameterEntry(value);
829 }
else if (value_any.type() ==
typeid(TwoDArray<long long>)) {
830 TwoDArray<long long>& value = any_ref_cast<TwoDArray<long long> >(value_any);
831 result.value = ParameterEntry(value);
832 }
else if (value_any.type() ==
typeid(TwoDArray<double>)) {
833 TwoDArray<double>& value = any_ref_cast<TwoDArray<double> >(value_any);
834 result.value = ParameterEntry(value);
835 }
else if (value_any.type() ==
typeid(TwoDArray<std::string>)) {
836 TwoDArray<std::string>& value = any_ref_cast<TwoDArray<std::string> >(value_any);
837 result.value = ParameterEntry(value);
838 }
else if (value_any.type() ==
typeid(ParameterList)) {
839 ParameterList& value = any_ref_cast<ParameterList>(value_any);
840 ParameterList& result_pl = result.value.setList();
841 swap(result_pl, value);
842 result_pl.setName(result.key);
844 std::string msg =
"unexpected YAML map value type ";
845 msg += value_any.type().name();
846 msg +=
" for key \"";
849 throw ParserFail(msg);
852 void resolve_map_value(any& value_any,
int scalar_type = -1)
const {
853 if (value_any.type() ==
typeid(Scalar)) {
854 Scalar& scalar_value = any_ref_cast<Scalar>(value_any);
855 if (scalar_type == -1) {
856 scalar_type = scalar_value.infer_type();
858 if (scalar_type == Scalar::BOOL) {
859 value_any = parse_as<bool>(scalar_value.text);
860 }
else if (scalar_type == Scalar::INT) {
861 value_any = parse_as<int>(scalar_value.text);
862 }
else if (scalar_type == Scalar::LONG_LONG) {
863 value_any = parse_as<long long>(scalar_value.text);
864 }
else if (scalar_type == Scalar::DOUBLE) {
865 value_any = parse_as<double>(scalar_value.text);
867 value_any = scalar_value.text;
869 }
else if (value_any.type() ==
typeid(Array<Scalar>)) {
870 Array<Scalar>& scalars = any_ref_cast<Array<Scalar> >(value_any);
871 if (scalar_type == -1) {
872 if (scalars.size() == 0) {
873 throw ParserFail(
"implicitly typed arrays can't be empty\n"
874 "(need to determine their element type)\n");
878 scalar_type = Scalar::INT;
879 for (Teuchos_Ordinal i = 0; i < scalars.size(); ++i) {
880 scalar_type = std::min(scalar_type, scalars[i].infer_type());
883 if (scalar_type == Scalar::INT) {
884 Array<int> result(scalars.size());
885 for (Teuchos_Ordinal i = 0; i < scalars.size(); ++i) {
886 result[i] = parse_as<int>(scalars[i].text);
889 }
else if (scalar_type == Scalar::LONG_LONG) {
890 Array<long long> result(scalars.size());
891 for (Teuchos_Ordinal i = 0; i < scalars.size(); ++i) {
892 result[i] = parse_as<long long>(scalars[i].text);
895 }
else if (scalar_type == Scalar::DOUBLE) {
896 Array<double> result(scalars.size());
897 for (Teuchos_Ordinal i = 0; i < scalars.size(); ++i) {
898 result[i] = parse_as<double>(scalars[i].text);
901 }
else if (scalar_type == Scalar::STRING) {
902 Array<std::string> result(scalars.size());
903 for (Teuchos_Ordinal i = 0; i < scalars.size(); ++i) {
904 result[i] = scalars[i].text;
908 }
else if (value_any.type() ==
typeid(Array<Array<Scalar>>)) {
909 Array<Array<Scalar>>& scalars = any_ref_cast<Array<Array<Scalar>> >(value_any);
910 if (scalar_type == -1) {
911 if (scalars.size() == 0) {
912 throw ParserFail(
"implicitly typed 2D arrays can't be empty\n"
913 "(need to determine their element type)\n");
917 scalar_type = Scalar::INT;
918 for (Teuchos_Ordinal i = 0; i < scalars.size(); ++i) {
919 if (scalars[0].size() == 0) {
920 throw ParserFail(
"implicitly typed 2D arrays can't have empty rows\n"
921 "(need to determine their element type)\n");
923 if (scalars[i].size() != scalars[0].size()) {
924 throw ParserFail(
"2D array: sub-arrays are different sizes");
926 for (Teuchos_Ordinal j = 0; j < scalars[i].size(); ++j) {
927 int item_type = scalars[i][j].infer_type();
928 scalar_type = std::min(scalar_type, item_type);
932 if (scalar_type == Scalar::INT) {
933 TwoDArray<int> result(scalars.size(), scalars[0].size());
934 for (Teuchos_Ordinal i = 0; i < scalars.size(); ++i) {
935 for (Teuchos_Ordinal j = 0; j < scalars[0].size(); ++j) {
936 result(i, j) = parse_as<int>(scalars[i][j].text);
940 }
else if (scalar_type == Scalar::LONG_LONG) {
941 TwoDArray<long long> result(scalars.size(), scalars[0].size());
942 for (Teuchos_Ordinal i = 0; i < scalars.size(); ++i) {
943 for (Teuchos_Ordinal j = 0; j < scalars[0].size(); ++j) {
944 result(i, j) = parse_as<long long>(scalars[i][j].text);
948 }
else if (scalar_type == Scalar::DOUBLE) {
949 TwoDArray<double> result(scalars.size(), scalars[0].size());
950 for (Teuchos_Ordinal i = 0; i < scalars.size(); ++i) {
951 for (Teuchos_Ordinal j = 0; j < scalars[0].size(); ++j) {
952 result(i, j) = parse_as<double>(scalars[i][j].text);
956 }
else if (scalar_type == Scalar::STRING) {
957 TwoDArray<std::string> result(scalars.size(), scalars[0].size());
958 for (Teuchos_Ordinal i = 0; i < scalars.size(); ++i) {
959 for (Teuchos_Ordinal j = 0; j < scalars[0].size(); ++j) {
960 result(i, j) = scalars[i][j].text;
967 int interpret_tag(any& tag_any) {
968 if (tag_any.type() !=
typeid(std::string))
return -1;
969 std::string& text = any_ref_cast<std::string>(tag_any);
970 if (text.find(
"bool") != std::string::npos)
return Scalar::BOOL;
971 else if (text.find(
"int") != std::string::npos)
return Scalar::INT;
972 else if (text.find(
"double") != std::string::npos)
return Scalar::DOUBLE;
973 else if (text.find(
"string") != std::string::npos)
return Scalar::STRING;
975 std::string msg =
"Unable to parse type tag \"";
978 throw ParserFail(msg);
981 void seq_first_item(any& result_any, any& first_any) {
983 if (first_any.type() ==
typeid(Scalar)) {
984 Array<Scalar>& a = make_any_ref<Array<Scalar> >(result_any);
985 Scalar& v = any_ref_cast<Scalar>(first_any);
986 a.push_back(Scalar());
988 }
else if (first_any.type() ==
typeid(Array<Scalar>)) {
989 Array<Array<Scalar>>& a = make_any_ref<Array<Array<Scalar>> >(result_any);
990 Array<Scalar>& v = any_ref_cast<Array<Scalar> >(first_any);
991 a.push_back(Array<Scalar>());
995 "bug in YAMLParameterList::Reader: unexpected type for first sequence item");
998 void seq_next_item(any& result_any, any& items, any& next_item) {
1000 swap(result_any, items);
1001 if (result_any.type() ==
typeid(Array<Scalar>)) {
1002 Array<Scalar>& a = any_ref_cast<Array<Scalar> >(result_any);
1003 Scalar& val = any_ref_cast<Scalar>(next_item);
1004 a.push_back(Scalar());
1005 swap(a.back(), val);
1006 }
else if (result_any.type() ==
typeid(Array<Array<Scalar>>)) {
1007 Array<Array<Scalar>>& a = any_ref_cast<Array<Array<Scalar>> >(result_any);
1008 Array<Scalar>& v = any_ref_cast<Array<Scalar> >(next_item);
1009 a.push_back(Array<Scalar>());
1013 "bug in YAMLParameterList::Reader: unexpected type for next sequence item");
1017 void handle_block_scalar(
1018 std::size_t parent_indent_level,
1019 std::string
const& header,
1020 std::string
const& leading_empties_or_comments,
1021 std::string
const& rest,
1022 std::string& content,
1023 std::string& comment) {
1026 char chomping_indicator;
1027 std::size_t indentation_indicator = 0;
1029 std::stringstream ss(header.substr(1,std::string::npos));
1030 if (header.size() > 1 && my_isdigit(header[1])) {
1031 ss >> indentation_indicator;
1033 indentation_indicator += parent_indent_level;
1035 if (!(ss >> chomping_indicator)) chomping_indicator =
'\0';
1038 std::size_t first_newline = leading_empties_or_comments.find_first_of(
"\r\n");
1039 std::string newline;
1040 if (first_newline > 0 && leading_empties_or_comments[first_newline - 1] ==
'\r') {
1045 std::size_t keep_beg = first_newline + 1 - newline.size();
1046 if (leading_empties_or_comments[0] ==
'#') {
1047 comment = leading_empties_or_comments.substr(1, keep_beg);
1050 std::size_t content_beg = leading_empties_or_comments.find_first_not_of(
"\r\n ");
1051 if (content_beg == std::string::npos) content_beg = leading_empties_or_comments.size();
1052 std::size_t newline_before_content = leading_empties_or_comments.rfind(
"\n", content_beg);
1053 std::size_t num_indent_spaces = (content_beg - newline_before_content) - 1;
1056 if (indentation_indicator > 0) {
1059 "Indentation indicator " << indentation_indicator <<
" > leading spaces " << num_indent_spaces);
1060 num_indent_spaces = indentation_indicator;
1063 content = leading_empties_or_comments.substr(keep_beg, std::string::npos);
1072 auto last_newline = content.find_last_of(
"\n", content.size() - 2);
1073 if (last_newline == std::string::npos)
break;
1074 std::size_t num_spaces = 0;
1075 for (
auto ispace = last_newline + 1;
1076 ispace < content.size() && content[ispace] ==
' ';
1080 if (num_spaces >= num_indent_spaces)
break;
1081 content.erase(content.begin() + last_newline + 1, content.end());
1084 std::size_t unindent_pos = 0;
1086 std::size_t next_newline = content.find_first_of(
"\n", unindent_pos);
1087 if (next_newline == std::string::npos)
break;
1088 std::size_t start_cut = next_newline + 1;
1090 if (style ==
'>') start_cut -= newline.size();
1091 std::size_t end_cut = next_newline + 1;
1094 while (end_cut < content.size() && content[end_cut] ==
' ') {
1098 end_cut = std::min(next_newline + 1 + num_indent_spaces, end_cut);
1100 content = content.substr(0, start_cut) +
1101 content.substr(end_cut, std::string::npos);
1102 unindent_pos = start_cut;
1104 if (chomping_indicator !=
'+') {
1105 content = remove_trailing_whitespace_and_newlines(content);
1106 if (chomping_indicator !=
'-') content += newline;
1110 content = content.substr(newline.size(), std::string::npos);
1119 void updateParametersFromYamlFile(
const std::string& yamlFileName,
1124 if (paramList->
name() ==
"ANONYMOUS") {
1131 void updateParametersFromYamlCString(
const char*
const data,
1138 if (paramList->
name() ==
"ANONYMOUS") {
1149 void updateParametersFromYamlString(
const std::string& yamlData,
1152 const std::string& name)
1157 if (paramList->
name() ==
"ANONYMOUS") {
1170 return YAMLParameterList::parseYamlFile(yamlFileName);
1175 std::stringstream ss(yamlStr);
1176 return YAMLParameterList::parseYamlStream(ss);
1179 void writeParameterListToYamlOStream(
1181 std::ostream &yamlOut
1184 YAMLParameterList::writeYamlStream(yamlOut, paramList);
1187 void writeParameterListToYamlFile(
1189 const std::string &yamlFileName
1192 YAMLParameterList::writeYamlFile(yamlFileName, paramList);
1195 std::string convertXmlToYaml(
const std::string& xmlFileName)
1200 std::string yamlFileName;
1201 if(xmlFileName.find(
".xml") == std::string::npos)
1203 yamlFileName = xmlFileName +
".yaml";
1207 yamlFileName = xmlFileName.substr(0, xmlFileName.length() - 4) +
".yaml";
1209 YAMLParameterList::writeYamlFile(yamlFileName, *toConvert);
1210 return yamlFileName;
1213 void convertXmlToYaml(
const std::string& xmlFileName,
const std::string& yamlFileName)
1216 YAMLParameterList::writeYamlFile(yamlFileName, *toConvert);
1219 void convertXmlToYaml(std::istream& xmlStream, std::ostream& yamlStream)
1222 std::istreambuf_iterator<char> begin(xmlStream);
1223 std::istreambuf_iterator<char> end;
1224 std::string xmlString(begin, end);
1226 YAMLParameterList::writeYamlStream(yamlStream, *toConvert);
1229 namespace YAMLParameterList
1234 #ifdef HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
1235 auto yaml_input = ::YAML::LoadAll(text);
1236 return readParams(yaml_input);
1239 Teuchos::YAMLParameterList::Reader reader;
1240 reader.read_string(result, text, name);
1241 ParameterList& pl = any_ref_cast<ParameterList>(result);
1243 #endif // HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
1248 #ifdef HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
1249 auto yaml_input = ::YAML::LoadAllFromFile(yamlFile);
1250 return readParams(yaml_input);
1253 Teuchos::YAMLParameterList::Reader reader;
1254 reader.read_file(result, yamlFile);
1255 ParameterList& pl = any_ref_cast<ParameterList>(result);
1257 #endif // HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
1262 #ifdef HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
1263 auto yaml_input = ::YAML::LoadAll(yaml);
1264 return readParams(yaml_input);
1267 Teuchos::YAMLParameterList::Reader reader;
1268 reader.read_stream(result, yaml,
"parseYamlStream");
1269 ParameterList& pl = any_ref_cast<ParameterList>(result);
1271 #endif // HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
1277 #ifdef HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
1284 for(
size_t i = 0; i < lists.size(); i++)
1286 processMapNode(lists[i], *pl,
true);
1293 if (node.Type() != ::YAML::NodeType::Map)
1295 throw YamlStructureError(
"All top-level elements of the YAML file must be maps.");
1299 parent.
setName(node.begin()->first.as<std::string>());
1300 processMapNode(node.begin()->second, parent);
1304 for (::YAML::const_iterator i = node.begin(); i != node.end(); i++)
1307 if(i->first.Type() != ::YAML::NodeType::Scalar)
1309 throw YamlKeyError(
"Keys must be YAML scalars (int, double, or string)");
1312 const std::string key = quoted_as<std::string>(i->first);
1313 processKeyValueNode(key, i->second, parent, topLevel);
1318 void processKeyValueNode(
const std::string& key, const ::YAML::Node& node,
Teuchos::ParameterList& parent,
bool topLevel)
1322 if(node.Type() == ::YAML::NodeType::Scalar)
1326 safe_set_entry<int>(parent, key, quoted_as<int>(node));
1332 safe_set_entry<long long>(parent, key, quoted_as<long long>(node));
1338 safe_set_entry<double>(parent, key, quoted_as<double>(node));
1344 bool raw_bool = quoted_as<bool>(node);
1352 std::string raw_string = quoted_as<std::string>(node);
1353 if (is_parseable_as<bool>(raw_string))
1355 safe_set_entry<bool>(parent, key, raw_bool);
1359 safe_set_entry<std::string>(parent, key, raw_string);
1364 safe_set_entry<std::string>(parent, key, quoted_as<std::string>(node));
1370 else if(node.Type() == ::YAML::NodeType::Map)
1374 processMapNode(node, parent);
1379 processMapNode(node, sublist);
1382 else if(node.Type() == ::YAML::NodeType::Sequence)
1384 int ndim = getYamlArrayDim(node);
1387 ::YAML::Node
const& first_value = *(node.begin());
1390 quoted_as<int>(first_value);
1391 safe_set_entry<Teuchos::Array<int>>(parent, key, getYamlArray<int>(node));
1397 quoted_as<double>(first_value);
1398 safe_set_entry<Teuchos::Array<double>>(parent, key, getYamlArray<double>(node));
1404 quoted_as<std::string>(first_value);
1405 safe_set_entry<Teuchos::Array<std::string>>(parent, key, getYamlArray<std::string>(node));
1409 throw YamlSequenceError(std::string(
"Array \"") + key +
"\" must contain int, double, bool or string");
1416 bool is_ragged = checkYamlTwoDArrayIsRagged(node);
1417 ::YAML::Node
const& first_value = *(node.begin()->begin());
1420 quoted_as<int>(first_value);
1423 safe_set_entry<arr_t>(parent, key, getYaml2DRaggedArray<arr_t, int>(node, ndim, key));
1425 safe_set_entry<Teuchos::TwoDArray<int>>(parent, key, getYamlTwoDArray<int>(node));
1432 quoted_as<double>(first_value);
1435 safe_set_entry<arr_t>(parent, key, getYaml2DRaggedArray<arr_t, double>(node, ndim, key));
1437 safe_set_entry<Teuchos::TwoDArray<double>>(parent, key, getYamlTwoDArray<double>(node));
1444 quoted_as<std::string>(first_value);
1447 safe_set_entry<arr_t>(parent, key, getYaml2DRaggedArray<arr_t, std::string>(node, ndim, key));
1449 safe_set_entry<Teuchos::TwoDArray<std::string>>(parent, key, getYamlTwoDArray<std::string>(node));
1454 throw YamlSequenceError(std::string(
"TwoDArray \"") + key +
"\" must contain int, double, bool or string");
1461 ::YAML::Node
const& first_value = *(node.begin()->begin()->begin());
1464 quoted_as<int>(first_value);
1466 safe_set_entry<arr_t>(parent, key, getYaml3DArray<arr_t, int>(node, ndim, key));
1472 quoted_as<double>(first_value);
1474 safe_set_entry<arr_t>(parent, key, getYaml3DArray<arr_t, double>(node, ndim, key));
1481 quoted_as<std::string>(first_value);
1483 safe_set_entry<arr_t>(parent, key, getYaml3DArray<arr_t, std::string>(node, ndim, key));
1488 throw YamlSequenceError(std::string(
"3DArray \"") + key +
"\" must contain int, double, bool or string");
1494 else if(node.Type() == ::YAML::NodeType::Null)
1502 throw YamlUndefinedNodeError(
"Value type in a key-value pair must be one of: int, double, string, array, sublist.");
1506 #endif // HAVE_TEUCHOSPARAMETERLIST_YAMLCPP
1511 std::ios_base::fmtflags flags = yaml.flags();
1513 std::ostringstream testStream;
1514 testStream.flags(flags);
1516 testStream << testVal;
1517 bool popFlags =
false;
1518 if(testStream.str() ==
"1")
1524 std::cout <<
"Warning: yaml stream format flags would confuse double with integer value with int.\n";
1525 std::cout <<
"Setting std::ios::showpoint on the stream to fix this (will restore flags when done)\n";
1526 std::ios_base::fmtflags flagsCopy = flags;
1527 flagsCopy |= std::ios::showpoint;
1530 yaml <<
"%YAML 1.1\n---\n";
1531 yaml << pl.
name() <<
':';
1538 writeParameterList(pl, yaml, 2);
1550 std::ofstream yaml(yamlFile.c_str());
1557 yaml << std::scientific << std::setprecision(17);
1558 writeYamlStream(yaml, pl);
1570 for(PLIter it = pl.
begin(); it != pl.
end(); it++)
1572 writeParameter(pl.
name(it), pl.
entry(it), yaml, indentLevel);
1577 template <
typename T>
1579 static void write(T
const& x, std::ostream& stream) {
1585 struct YamlWrite<double> {
1586 static void write(
double const& x, std::ostream& stream) {
1587 generalWriteDouble(x, stream);
1592 struct YamlWrite<std::string> {
1593 static void write(std::string
const& x, std::ostream& stream) {
1594 generalWriteString(x, stream);
1598 template <
typename T>
1605 if (i) stream <<
", ";
1609 if (j) stream <<
", ";
1610 YamlWrite<T>::write(arr(i, j), stream);
1617 void writeParameter(
const std::string& paramName,
const Teuchos::ParameterEntry& entry, std::ostream& yaml,
int indentLevel)
1619 for(
int i = 0; i < indentLevel; i++)
1623 generalWriteString(paramName, yaml);
1627 writeParameterList(Teuchos::getValue<Teuchos::ParameterList>(entry), yaml, indentLevel + 2);
1636 for(
int i = 0; i < arr.
size(); i++)
1639 if(i != arr.size() - 1)
1646 for(
int i = 0; i < arr.
size(); i++)
1649 if(i != arr.size() - 1)
1656 for(
int i = 0; i < arr.
size(); i++)
1658 generalWriteDouble(arr[i], yaml);
1659 if(i != arr.
size() - 1)
1666 for(
int i = 0; i < arr.
size(); i++)
1668 generalWriteString(arr[i], yaml);
1669 if(i != arr.
size() - 1)
1679 writeYamlTwoDArray<int>(
1680 Teuchos::getValue<Teuchos::TwoDArray<int> >(entry), yaml);
1684 writeYamlTwoDArray<long long>(
1685 Teuchos::getValue<Teuchos::TwoDArray<long long> >(entry), yaml);
1689 writeYamlTwoDArray<double>(
1690 Teuchos::getValue<Teuchos::TwoDArray<double> >(entry), yaml);
1694 writeYamlTwoDArray<std::string>(
1695 Teuchos::getValue<Teuchos::TwoDArray<std::string> >(entry), yaml);
1698 else if(entry.
isType<
int>())
1700 yaml << Teuchos::getValue<int>(entry);
1702 else if(entry.
isType<
long long>())
1704 yaml << Teuchos::getValue<long long>(entry);
1706 else if(entry.
isType<
double>())
1708 generalWriteDouble(Teuchos::getValue<double>(entry), yaml);
1710 else if(entry.
isType<std::string>())
1712 std::string& str = Teuchos::getValue<std::string>(entry);
1713 if(strchr(str.c_str(),
'\n'))
1719 std::size_t first_non_newline_pos = str.find_first_not_of(
"\r\n");
1720 if (first_non_newline_pos != std::string::npos &&
1721 str[first_non_newline_pos] ==
' ') {
1724 if (str[str.size() - 1] !=
'\n') yaml <<
"-";
1730 size_t next = str.find(
'\n', index);
1731 for(
int i = 0; i < indentLevel + 2; i++)
1735 if(next == std::string::npos)
1737 yaml << str.substr(index, std::string::npos);
1742 yaml << str.substr(index, next - index) <<
'\n';
1749 generalWriteString(str, yaml);
1752 else if(entry.
isType<
bool>())
1754 yaml << (Teuchos::getValue<bool>(entry) ?
"true" :
"false");
1759 void generalWriteString(
const std::string& str, std::ostream& yaml)
1762 if(stringNeedsQuotes(str))
1765 for (std::size_t i = 0; i < str.size(); ++i) {
1766 if (str[i] ==
'\'') yaml <<
"''";
1767 else yaml << str[i];
1777 void generalWriteDouble(
double d, std::ostream& yaml)
1782 static bool containsSpecialCharacters(std::string
const& s) {
1783 char const*
const control_chars =
":'{}[],&*#?|<>=!%@\\";
1784 return s.find_first_of(control_chars) != std::string::npos;
1787 bool stringNeedsQuotes(
const std::string& s)
1790 containsSpecialCharacters(s) ||
1791 is_parseable_as<bool>(s) ||
1792 is_parseable_as<int>(s) ||
1793 is_parseable_as<long long>(s) ||
1794 is_parseable_as<double>(s);
A thin wrapper around the Teuchos Array class that allows for 2 dimensional arrays.
const std::string & name() const
The name of this ParameterList.
Reader(ReaderTablesPtr tables_in)
Constructor: accepts an RCP to ReaderTables.
ConstIterator end() const
An iterator pointing beyond the last entry.
Functions to convert between ParameterList and YAML.
This object is held as the "value" in the Teuchos::ParameterList std::map.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
bool isArray() const
Test if the type of data being contained is a Teuchos::Array.
Tries to create LALR(1) parser tables for a given grammar.
bool isType() const
Test the type of the data being contained.
Ordinal numParams() const
Get the number of stored parameters.
A TeuchosParser Language for a subset of YAML.
Simple helper functions that make it easy to read and write XML to and from a parameterlist.
A thin wrapper around the Array class which causes it to be interpreted as a 2D Array.
The main class for users to read text using TeuchosParser.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
size_type getNumCols() const
returns the number of columns in the TwoDArray.
void resizeCols(size_type numberOfCols)
Changes the number of rows in the matrix.
void resizeRows(size_type numberOfRows)
Changes the number of rows in the matrix.
ConstIterator begin() const
An iterator pointing to the first entry.
bool isList() const
Return whether or not the value itself is a list.
A list of parameters of arbitrary type.
ParameterList & setParameters(const ParameterList &source)
const ParameterEntry & entry(ConstIterator i) const
Access to ParameterEntry (i.e., returns i->second)
size_type getNumRows() const
returns the number of rows in the TwoDArray.
void push_back(const value_type &x)
ParameterList & setParametersNotAlreadySet(const ParameterList &source)
bool isTwoDArray() const
Test if the type of data being contained is a Teuchos::TwoDArray.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Creates an empty sublist and returns a reference to the sublist name. If the list already exists...
ParameterList & setName(const std::string &name)
Set the name of *this list.
#define TEUCHOS_ASSERT(assertion_test)
This macro is throws when an assert fails.
Simple helper functions that make it easy to read and write Yaml to and from a parameterlist.
Simple wrapper class for raw pointers to single objects where no persisting relationship exists...
Replacement for std::vector that is compatible with the Teuchos Memory Management classes...
Declares Teuchos::Reader.