9.04 beta

This commit is contained in:
Igor Pavlov
2009-06-02 00:00:00 +00:00
committed by Kornel Lesiński
parent 8874e4fbc9
commit 829409452d
440 changed files with 19803 additions and 9941 deletions

View File

@@ -3,7 +3,10 @@
#include "StdAfx.h"
#include <tchar.h>
#include "StdInStream.h"
#include "StringConvert.h"
#include "UTFConvert.h"
#ifdef _MSC_VER
// "was declared deprecated" disabling
@@ -19,6 +22,8 @@ static const char *kIllegalCharMessage = "Illegal character in input stream";
static LPCTSTR kFileOpenMode = TEXT("r");
extern int g_CodePage;
CStdInStream g_StdIn(stdin);
bool CStdInStream::Open(LPCTSTR fileName)
@@ -42,14 +47,18 @@ CStdInStream::~CStdInStream()
Close();
}
AString CStdInStream::ScanStringUntilNewLine()
AString CStdInStream::ScanStringUntilNewLine(bool allowEOF)
{
AString s;
for (;;)
{
int intChar = GetChar();
if (intChar == EOF)
{
if (allowEOF)
break;
throw kEOFMessage;
}
char c = char(intChar);
if (c == kIllegalChar)
throw kIllegalCharMessage;
@@ -60,6 +69,20 @@ AString CStdInStream::ScanStringUntilNewLine()
return s;
}
UString CStdInStream::ScanUStringUntilNewLine()
{
AString s = ScanStringUntilNewLine(true);
int codePage = g_CodePage;
if (codePage == -1)
codePage = CP_OEMCP;
UString dest;
if (codePage == CP_UTF8)
ConvertUTF8ToUnicode(s, dest);
else
dest = MultiByteToUnicodeString(s, (UINT)codePage);
return dest;
}
void CStdInStream::ReadToString(AString &resultString)
{
resultString.Empty();