DotNetDupe
4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Toggle main menu visibility
Loading...
Searching...
No Matches
TextReader.cpp
Go to the documentation of this file.
1
#include "
pch.h
"
2
#include "
System/IO/TextReader.h
"
3
#include "
System/Text/StringBuilder.h
"
4
5
using namespace
DotNetDupe::System::Text
;
6
7
namespace
DotNetDupe
{
8
namespace
System
{
9
namespace
IO
{
10
void
TextReader::Close
() {
11
Dispose
();
12
}
13
14
void
TextReader::Dispose
() {
15
// Base implementation does nothing
16
}
17
18
int
TextReader::Peek
() {
19
return
-1;
20
}
21
22
int
TextReader::Read
() {
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
41
String
TextReader::ReadLine
() {
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
59
String
TextReader::ReadToEnd
() {
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
}
StringBuilder.h
Represents a mutable string of characters for efficient dynamic text composition.
TextReader.h
DotNetDupe::System::IO::TextReader::Close
virtual void Close()=0
Closes the TextReader and releases any system resources associated with the reader.
Definition
TextReader.cpp:10
DotNetDupe::System::IO::TextReader::Read
virtual int Read()=0
Reads the next character from the text reader and advances the character position by one character.
Definition
TextReader.cpp:22
DotNetDupe::System::IO::TextReader::Peek
virtual int Peek()=0
Reads the next character without changing the state of the reader or the character source.
Definition
TextReader.cpp:18
DotNetDupe::System::IO::TextReader::ReadLine
virtual String ReadLine()=0
Reads a line of characters from the text reader and returns the data as a string.
Definition
TextReader.cpp:41
DotNetDupe::System::IO::TextReader::Dispose
virtual void Dispose() override=0
Releases all resources used by the TextReader.
Definition
TextReader.cpp:14
DotNetDupe::System::IO::TextReader::ReadToEnd
virtual String ReadToEnd()=0
Reads all characters from the current position to the end of the text reader and returns them as one ...
Definition
TextReader.cpp:59
DotNetDupe::System::String
Represents text as a sequence of UTF-8 code units with culture-invariant operations.
Definition
String.h:74
DotNetDupe::System::String::String
String()
Initializes a new instance of the String class to an empty string.
Definition
String.cpp:64
DotNetDupe::System::Text::StringBuilder
Represents a mutable string of characters.
Definition
StringBuilder.h:21
DotNetDupe::System::Text::StringBuilder::Append
StringBuilder & Append(const String &value)
Appends a copy of the specified string to this instance.
Definition
StringBuilder.cpp:66
DotNetDupe::System::Text::StringBuilder::ToString
String ToString() const
Converts the value of this instance to a String.
Definition
StringBuilder.cpp:126
DotNetDupe::System::Text::StringBuilder::GetLength
int GetLength() const
Gets the length of the current StringBuilder object.
Definition
StringBuilder.cpp:44
DotNetDupe::System::IO
Definition
Console.h:17
DotNetDupe::System::Text
Definition
JsonElement.h:16
DotNetDupe::System
Definition
Action.h:11
DotNetDupe
Definition
IServiceCollection.h:7
pch.h
DotNetDupe
TextReader.cpp
Generated by
1.18.0