DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
TextReader.cpp
Go to the documentation of this file.
1#include "pch.h"
4
5using namespace DotNetDupe::System::Text;
6
7namespace DotNetDupe {
8 namespace System {
9 namespace IO {
11 Dispose();
12 }
13
15 // Base implementation does nothing
16 }
17
19 return -1;
20 }
21
23 return -1;
24 }
25
26 int TextReader::Read(char* pBuffer, int iIndex, int nCount) {
28 if (pBuffer == nullptr) return 0;
29
31 int iN = 0;
32 while (iN < nCount) {
33 int iCh = Read();
34 if (iCh == -1) break;
35 pBuffer[iIndex + iN] = (char)iCh;
36 iN++;
37 }
38 return iN;
39 }
40
42 StringBuilder sbOutput;
43
45 while (true) {
46 int iCh = Read();
47 if (iCh == -1) {
48 if (sbOutput.GetLength() > 0) return sbOutput.ToString();
49 return String("");
50 }
51 if (iCh == '\r' || iCh == '\n') {
52 if (iCh == '\r' && Peek() == '\n') Read();
53 return sbOutput.ToString();
54 }
55 sbOutput.Append((char)iCh);
56 }
57 }
58
60 StringBuilder sbOutput;
61
63 int iCh;
64 while ((iCh = Read()) != -1) {
65 sbOutput.Append((char)iCh);
66 }
67 return sbOutput.ToString();
68 }
69 }
70 }
71}
Represents a mutable string of characters for efficient dynamic text composition.
virtual void Close()=0
Closes the TextReader and releases any system resources associated with the reader.
virtual int Read()=0
Reads the next character from the text reader and advances the character position by one character.
virtual int Peek()=0
Reads the next character without changing the state of the reader or the character source.
virtual String ReadLine()=0
Reads a line of characters from the text reader and returns the data as a string.
virtual void Dispose() override=0
Releases all resources used by the TextReader.
virtual String ReadToEnd()=0
Reads all characters from the current position to the end of the text reader and returns them as one ...
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition String.h:74
String()
Initializes a new instance of the String class to an empty string.
Definition String.cpp:64
Represents a mutable string of characters.
StringBuilder & Append(const String &value)
Appends a copy of the specified string to this instance.
String ToString() const
Converts the value of this instance to a String.
int GetLength() const
Gets the length of the current StringBuilder object.