You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
3.7KB

  1. /* Arduino SdFat Library
  2. * Copyright (C) 2012 by William Greiman
  3. *
  4. * This file is part of the Arduino SdFat Library
  5. *
  6. * This Library is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This Library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with the Arduino SdFat Library. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef iostream_h
  21. #define iostream_h
  22. /**
  23. * \file
  24. * \brief \ref iostream class
  25. */
  26. #include <istream.h>
  27. #include <ostream.h>
  28. /** Skip white space
  29. * \param[in] is the Stream
  30. * \return The stream
  31. */
  32. inline istream& ws(istream& is) {
  33. is.skipWhite();
  34. return is;
  35. }
  36. /** insert endline
  37. * \param[in] os The Stream
  38. * \return The stream
  39. */
  40. inline ostream& endl(ostream& os) {
  41. os.put('\n');
  42. #if ENDL_CALLS_FLUSH
  43. os.flush();
  44. #endif // ENDL_CALLS_FLUSH
  45. return os;
  46. }
  47. /** flush manipulator
  48. * \param[in] os The stream
  49. * \return The stream
  50. */
  51. inline ostream& flush(ostream& os) {
  52. os.flush();
  53. return os;
  54. }
  55. /**
  56. * \struct setfill
  57. * \brief type for setfill manipulator
  58. */
  59. struct setfill {
  60. /** fill character */
  61. char c;
  62. /** constructor
  63. *
  64. * \param[in] arg new fill character
  65. */
  66. explicit setfill(char arg) : c(arg) {}
  67. };
  68. /** setfill manipulator
  69. * \param[in] os the stream
  70. * \param[in] arg set setfill object
  71. * \return the stream
  72. */
  73. inline ostream &operator<< (ostream &os, const setfill &arg) {
  74. os.fill(arg.c);
  75. return os;
  76. }
  77. /** setfill manipulator
  78. * \param[in] obj the stream
  79. * \param[in] arg set setfill object
  80. * \return the stream
  81. */
  82. inline istream &operator>>(istream &obj, const setfill &arg) {
  83. obj.fill(arg.c);
  84. return obj;
  85. }
  86. //------------------------------------------------------------------------------
  87. /** \struct setprecision
  88. * \brief type for setprecision manipulator
  89. */
  90. struct setprecision {
  91. /** precision */
  92. unsigned int p;
  93. /** constructor
  94. * \param[in] arg new precision
  95. */
  96. explicit setprecision(unsigned int arg) : p(arg) {}
  97. };
  98. /** setprecision manipulator
  99. * \param[in] os the stream
  100. * \param[in] arg set setprecision object
  101. * \return the stream
  102. */
  103. inline ostream &operator<< (ostream &os, const setprecision &arg) {
  104. os.precision(arg.p);
  105. return os;
  106. }
  107. /** setprecision manipulator
  108. * \param[in] is the stream
  109. * \param[in] arg set setprecision object
  110. * \return the stream
  111. */
  112. inline istream &operator>>(istream &is, const setprecision &arg) {
  113. is.precision(arg.p);
  114. return is;
  115. }
  116. //------------------------------------------------------------------------------
  117. /** \struct setw
  118. * \brief type for setw manipulator
  119. */
  120. struct setw {
  121. /** width */
  122. unsigned w;
  123. /** constructor
  124. * \param[in] arg new width
  125. */
  126. explicit setw(unsigned arg) : w(arg) {}
  127. };
  128. /** setw manipulator
  129. * \param[in] os the stream
  130. * \param[in] arg set setw object
  131. * \return the stream
  132. */
  133. inline ostream &operator<< (ostream &os, const setw &arg) {
  134. os.width(arg.w);
  135. return os;
  136. }
  137. /** setw manipulator
  138. * \param[in] is the stream
  139. * \param[in] arg set setw object
  140. * \return the stream
  141. */
  142. inline istream &operator>>(istream &is, const setw &arg) {
  143. is.width(arg.w);
  144. return is;
  145. }
  146. //==============================================================================
  147. /**
  148. * \class iostream
  149. * \brief Input/Output stream
  150. */
  151. class iostream : public istream, public ostream {
  152. };
  153. #endif // iostream_h