io.cxx 833 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // io.cxx
  3. // dice
  4. //
  5. // Created by Sam Jaffe on 1/16/21.
  6. // Copyright © 2021 Sam Jaffe. All rights reserved.
  7. //
  8. #include <iostream>
  9. #include <sstream>
  10. #include "dice-roll/die.h"
  11. #include "dice-roll/io.h"
  12. #include "dice-roll/parser.h"
  13. #include "dice-roll/roll.h"
  14. namespace dice {
  15. std::ostream & operator<<(std::ostream & out, sign s) {
  16. return ::dice::template operator<<(out, s);
  17. }
  18. std::ostream & operator<<(std::ostream & out, dice const & d) {
  19. return ::dice::template operator<<(out, d);
  20. }
  21. std::ostream & operator<<(std::ostream & out, dice_roll const & r) {
  22. return ::dice::template operator<<(out, r);
  23. }
  24. std::istream & operator>>(std::istream & in, dice & d) {
  25. d = parser(in).parse();
  26. return in;
  27. }
  28. dice from_string(std::string const & str) {
  29. std::stringstream ss(str);
  30. return parser(ss).parse();
  31. }
  32. }