[Scummvm-git-logs] scummvm master -> b5d6716d1d506d48614b1fdfa7443dcee91b6ad7
dreammaster
dreammaster at scummvm.org
Wed Dec 16 01:39:30 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b5d6716d1d COMMON: Add ReadStream::readString() and use it in the Ultima engine
Commit: b5d6716d1d506d48614b1fdfa7443dcee91b6ad7
https://github.com/scummvm/scummvm/commit/b5d6716d1d506d48614b1fdfa7443dcee91b6ad7
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2020-12-15T17:39:25-08:00
Commit Message:
COMMON: Add ReadStream::readString() and use it in the Ultima engine
Changed paths:
common/stream.cpp
common/stream.h
engines/ultima/shared/core/file.cpp
engines/ultima/shared/core/file.h
diff --git a/common/stream.cpp b/common/stream.cpp
index 8a7359865b..437d68e74e 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -52,6 +52,16 @@ SeekableReadStream *ReadStream::readStream(uint32 dataSize) {
return new MemoryReadStream((byte *)buf, dataSize, DisposeAfterUse::YES);
}
+Common::String ReadStream::readString(char terminator) {
+ Common::String result;
+ char c;
+
+ while ((c = (char)readByte()) != terminator && !eos())
+ result += c;
+
+ return result;
+}
+
Common::String ReadStream::readPascalString(bool transformCR) {
Common::String s;
char *buf;
diff --git a/common/stream.h b/common/stream.h
index 9c735b4577..1e13d690d9 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -637,6 +637,15 @@ public:
*/
SeekableReadStream *readStream(uint32 dataSize);
+ /**
+ * Reads in a terminated string. Upon successful completion,
+ * return a string with the content of the line, *without*
+ * the terminating character.
+ *
+ * @param terminator The terminating character to use.
+ */
+ String readString(char terminator = 0);
+
/**
* Read a string in Pascal format, that is, one byte is
* string length, followed by string data.
diff --git a/engines/ultima/shared/core/file.cpp b/engines/ultima/shared/core/file.cpp
index 7def6fc839..aeb225163f 100644
--- a/engines/ultima/shared/core/file.cpp
+++ b/engines/ultima/shared/core/file.cpp
@@ -27,18 +27,6 @@
namespace Ultima {
namespace Shared {
-Common::String readStringFromStream(Common::SeekableReadStream *s) {
- Common::String result;
- char c;
- while ((c = s->readByte()) != '\0')
- result += c;
-
- return result;
-}
-
-/*------------------------------------------------------------------------*/
-
-
#define ERROR error("Could not open file - %s", name.c_str())
File::File(const Common::String &name) : Common::File(), _filesize(-1) {
@@ -93,15 +81,5 @@ bool File::eof() {
return pos() >= _filesize;
}
-Common::String File::readString() {
- Common::String result;
- char c;
-
- while (!eof() && (c = (char)readByte()) != '\0')
- result += c;
-
- return result;
-}
-
} // End of namespace Shared
} // End of namespace Ultima
diff --git a/engines/ultima/shared/core/file.h b/engines/ultima/shared/core/file.h
index bf3b471017..647cdb3cc2 100644
--- a/engines/ultima/shared/core/file.h
+++ b/engines/ultima/shared/core/file.h
@@ -74,11 +74,6 @@ public:
* Differing eof that returns true when pos == size as well as beyond
*/
bool eof();
-
- /**
- * Reads in a null terminated string
- */
- Common::String readString();
};
} // End of namespace Shared
More information about the Scummvm-git-logs
mailing list