added size_t LineReader::readLine(String& wstr) for convenience.

This commit is contained in:
beard%netscape.com 2000-05-05 05:24:02 +00:00
Родитель d8def353a3
Коммит 70fd8a8a97
4 изменённых файлов: 22 добавлений и 4 удалений

Просмотреть файл

@ -1970,7 +1970,7 @@ JS::AsciiFileFormatter JS::stdErr(stderr);
// Return the total number of characters read, which is str's length.
// Translate <CR> and <CR><LF> sequences to <LF> characters; a <CR><LF> sequence
// only counts as one character.
size_t JS::LineReader::readLine(string &str)
size_t JS::LineReader::readLine(string& str)
{
int ch;
bool oldCRWasLast = crWasLast;
@ -1995,6 +1995,14 @@ size_t JS::LineReader::readLine(string &str)
return str.size();
}
size_t JS::LineReader::readLine(String& wstr)
{
string str;
size_t n = readLine(str);
wstr.resize(n);
std::transform(str.begin(), str.end(), wstr.begin(), widen);
return n;
}
//
// Exceptions

Просмотреть файл

@ -824,7 +824,8 @@ namespace JavaScript {
public:
explicit LineReader(FILE *in): in(in), crWasLast(false) {}
size_t readLine(string &str);
size_t readLine(string& str);
size_t readLine(String& wstr);
};

Просмотреть файл

@ -1970,7 +1970,7 @@ JS::AsciiFileFormatter JS::stdErr(stderr);
// Return the total number of characters read, which is str's length.
// Translate <CR> and <CR><LF> sequences to <LF> characters; a <CR><LF> sequence
// only counts as one character.
size_t JS::LineReader::readLine(string &str)
size_t JS::LineReader::readLine(string& str)
{
int ch;
bool oldCRWasLast = crWasLast;
@ -1995,6 +1995,14 @@ size_t JS::LineReader::readLine(string &str)
return str.size();
}
size_t JS::LineReader::readLine(String& wstr)
{
string str;
size_t n = readLine(str);
wstr.resize(n);
std::transform(str.begin(), str.end(), wstr.begin(), widen);
return n;
}
//
// Exceptions

Просмотреть файл

@ -824,7 +824,8 @@ namespace JavaScript {
public:
explicit LineReader(FILE *in): in(in), crWasLast(false) {}
size_t readLine(string &str);
size_t readLine(string& str);
size_t readLine(String& wstr);
};