value-traits.cxx 534 B

123456789101112131415161718192021
  1. // file : xml/value-traits.cxx
  2. // copyright : Copyright (c) 2013-2014 Code Synthesis Tools CC
  3. // license : MIT; see accompanying LICENSE file
  4. #include <xml/parser>
  5. using namespace std;
  6. namespace xml
  7. {
  8. bool default_value_traits<bool>::
  9. parse (string s, const parser& p)
  10. {
  11. if (s == "true" || s == "1" || s == "True" || s == "TRUE")
  12. return true;
  13. else if (s == "false" || s == "0" || s == "False" || s == "FALSE")
  14. return false;
  15. else
  16. throw parsing (p, "invalid bool value '" + s + "'");
  17. }
  18. }