本文整理汇总了C++中DataBuffer::Buffer方法的典型用法代码示例。如果您正苦于以下问题:C++ DataBuffer::Buffer方法的具体用法?C++ DataBuffer::Buffer怎么用?C++ DataBuffer::Buffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBuffer
的用法示例。
在下文中一共展示了DataBuffer::Buffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writer
bool
File::Test( )
{
bool ok = true;
cout << "Testing File" << endl;
try
{
const string testDataFileName = "FileTest.dat";
char testData[ 266 ]
= { 0, '\r', '\n', '\r', '\n', '\n', '\r', '\r', 0, '\n' };
for ( int i = 0; i < 256; ++i )
testData[ i + 10 ] = static_cast< char >( i );
DataBuffer buff;
buff.Add( testData, 266 );
{
cout << "FileWriter( string ) constructor" << endl;
FileWriter writer( testDataFileName );
cout << "writer.Save( DataBuffer )" << endl;
writer.Save( buff );
}
TESTCHECK( FileExists( testDataFileName ), true, &ok );
TESTCHECK( FileSize( testDataFileName ),
(int) (ARRAY_LENGTH( testData )), &ok );
DateTime now( true );
DateTime then = now;
then.Increment( 0, 0, 0, 0, -1 ); //1 minute ago
TESTCHECK( (now < FileModDate( testDataFileName )), false, &ok );
TESTCHECK( (then < FileModDate( testDataFileName )), true, &ok );
buff.Clear( );
{
cout << "FileReader( string ) constructor" << endl;
FileReader reader( testDataFileName );
cout << "writer.Load( DataBuffer * )" << endl;
reader.Load( &buff );
}
const vector< char > & testData1 = buff.Buffer();
TESTCHECK( testData1.size(), ARRAY_LENGTH( testData ), &ok );
TESTCHECK( memcmp( &testData1[0], testData, ARRAY_LENGTH( testData ) ),
0, &ok );
cout << "DeleteFile( string )" << endl;
DeleteFile( testDataFileName );
TESTCHECK( FileExists( testDataFileName ), false, &ok );
const string testTextFileName = "FileTest.txt";
const string testText = "Four score and seven years ago\n"
"our fathers set forth upon this continent\n\r"
"a new nation,\r\n"
"conceived in liberty\r"
"and dedicated to the proposition\x0"
"that all men are created equal.";
{
cout << "FileWriter( string, File::Text ) constructor" << endl;
FileWriter writer( testTextFileName, File::Text );
cout << "writer.Save( string )" << endl;
writer.Save( testText );
}
TESTCHECK( FileExists( testTextFileName ), true, &ok );
string testText1;
{
cout << "FileReader( string, File::Text ) constructor" << endl;
FileReader reader( testTextFileName, File::Text );
cout << "reader.Load( string * )" << endl;
reader.Load( &testText1 );
}
TESTCHECK( (testText1 == testText), true, &ok );
cout << "DeleteFile( string )" << endl;
DeleteFile( testTextFileName );
TESTCHECK( FileExists( testTextFileName ), false, &ok );
}
catch ( FileException & except )
{
cout << except.Description() << endl;
ok = false;
}
if ( ok )
cout << "File PASSED." << endl << endl;
else
cout << "File FAILED." << endl << endl;
return ok;
}