|
From: <pst...@us...> - 2009-01-01 03:18:32
|
Revision: 671
http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=671&view=rev
Author: pstieber
Date: 2009-01-01 03:18:28 +0000 (Thu, 01 Jan 2009)
Log Message:
-----------
Changed to use STL strings instead of char*.
Modified Paths:
--------------
trunk/jazz/src/StringReadWrite.cpp
trunk/jazz/src/StringReadWrite.h
Modified: trunk/jazz/src/StringReadWrite.cpp
===================================================================
--- trunk/jazz/src/StringReadWrite.cpp 2009-01-01 03:17:48 UTC (rev 670)
+++ trunk/jazz/src/StringReadWrite.cpp 2009-01-01 03:18:28 UTC (rev 671)
@@ -21,44 +21,39 @@
//*****************************************************************************
#include <iostream>
+#include <string>
using namespace std;
//*****************************************************************************
//*****************************************************************************
-istream& ReadString(istream& Is, char* pString, int MaximumLength)
+istream& ReadString(istream& Is, string& String)
{
- // Save space for the trailing 0.
- --MaximumLength;
-
- int c;
+ int Character;
do
{
// Ignore through the first ".
- c = Is.get();
- } while (c != '"' && c != EOF);
+ Character = Is.get();
+ } while (Character != '"' && Character != EOF);
- int i;
- for (i = 0; i < MaximumLength; ++i)
+ // This is an intention infinite for loop.
+ for (;;)
{
- c = Is.get();
- if (c == '"' || c == EOF)
+ Character = Is.get();
+ if (Character == '"' || Character != EOF)
{
break;
}
- pString[i] = c;
+ String += Character;
}
- // Terminate the C-style string.
- pString[i] = 0;
-
return Is;
}
//*****************************************************************************
//*****************************************************************************
-ostream& WriteString(ostream& Os, const char* pString)
+ostream& WriteString(ostream& Os, const string& String)
{
- Os << '"' << pString << '"';
+ Os << '"' << String << '"';
return Os;
}
Modified: trunk/jazz/src/StringReadWrite.h
===================================================================
--- trunk/jazz/src/StringReadWrite.h 2009-01-01 03:17:48 UTC (rev 670)
+++ trunk/jazz/src/StringReadWrite.h 2009-01-01 03:18:28 UTC (rev 671)
@@ -23,14 +23,15 @@
#ifndef JZ_STRINGREADWRITE_H
#define JZ_STRINGREADWRITE_H
-#include <iostream>
+#include <iosfwd>
+#include <string>
//*****************************************************************************
//*****************************************************************************
-std::istream& ReadString(std::istream& Is, char* pString, int MaximumLength);
+std::istream& ReadString(std::istream& Is, std::string& String);
//*****************************************************************************
//*****************************************************************************
-std::ostream& WriteString(std::ostream& Os, const char* pString);
+std::ostream& WriteString(std::ostream& Os, const std::string& String);
#endif // !defined(JZ_STRINGREADWRITE_H)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|