当然,标题可能会误导。 各位都希望你尽快研究以下两条幻灯片,并就如何尽可能改善业绩,避免过于夸张。 守则只需要双赢。 不幸的是,STL集装箱现在不是一个选择。
改为......
bool TextFile::Read(const char *pFilePath)
{
bool bSuccess = false;
std::ifstream oFile(pFilePath, std::ios_base::in);
if(oFile.is_open())
{
std::string stLineNow;
std::size_t siLineLength;
if(this->pLines)
{
this->Clear();
}
this->stFilePath = pFilePath;
oFile.seekg(0, std::ios::end);
this->pLines = new unsigned char *[static_cast<unsigned int> (oFile.tellg())];
oFile.seekg(0, std::ios::beg);
for(this->ulLinesCount = 0; std::getline(oFile, stLineNow).good(); this->ulLinesCount++)
{
siLineLength = stLineNow.length() + 1;
this->pLines[this->ulLinesCount] = new unsigned char[siLineLength];
memcpy(this->pLines[this->ulLinesCount], stLineNow.c_str(), siLineLength);
}
bSuccess = true;
oFile.close();
}
return bSuccess;
}
......
bool TextFile::Save(const char *pFilePath)
{
bool bSuccess = false;
if(this->pLines)
{
std::ofstream oFile(pFilePath ? pFilePath : this->stFilePath, std::ios_base::out);
if(oFile.is_open())
{
for(unsigned long ulPosition = 0; ulPosition < this->GetCount(); ulPosition++)
{
oFile << this->Get(ulPosition) <<
;
}
bSuccess = true;
oFile.close();
}
}
return bSuccess;
}
......,请以假装形式。
提前感谢!