stringstream.C 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. // $XConsortium: stringstream.C /main/5 1996/08/21 15:55:17 drk $
  24. #include "utility/c_stringstream.h"
  25. #include "utility/c_charbuf.h"
  26. #include <string.h>
  27. istringstream::istringstream() : istream(0)
  28. {
  29. char str[BUF_INITSZ];
  30. sbuf = new charbuf(str, strlen(str), 1);
  31. }
  32. istringstream::istringstream(char* str) :
  33. //ios(new charbuf(str, strlen(str))), istream(0)
  34. istream(0)
  35. {
  36. sbuf = new charbuf(str, strlen(str), 1);
  37. }
  38. istringstream::~istringstream()
  39. {
  40. }
  41. ostringstream::ostringstream() : ostream(0)
  42. {
  43. char str[BUF_INITSZ];
  44. sbuf = new charbuf(str, strlen(str));
  45. }
  46. ostringstream::ostringstream(char* str, int) :
  47. //ios(new charbuf(str, size)), ostream(0)
  48. ostream(0)
  49. {
  50. sbuf = new charbuf(str, strlen(str));
  51. }
  52. ostringstream::~ostringstream()
  53. {
  54. }
  55. string ostringstream::str()
  56. {
  57. string x = sbuf -> get_buf();
  58. // x[pcount()] = 0;
  59. return x;
  60. }
  61. stringstream::stringstream() : istringstream(), ostringstream()
  62. {
  63. }
  64. stringstream::stringstream(char* str) : istringstream(str), ostringstream(str)
  65. {
  66. sbuf = new charbuf(str, strlen(str));
  67. }