本文整理汇总了C++中IOBuffer::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ IOBuffer::Clear方法的具体用法?C++ IOBuffer::Clear怎么用?C++ IOBuffer::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOBuffer
的用法示例。
在下文中一共展示了IOBuffer::Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Pack
bool Student::Pack(IOBuffer& buffer) {
int numBytes;
// 일단 비우고
buffer.Clear ();
// 살아있으면 +
if( _alive ) {
numBytes = buffer.Pack("+");
} else {
// 죽은 레코드면 -
numBytes = buffer.Pack("-");
}
// integer들을 string으로 생성
string idString = to_string(_id);
string completedCreditHoursString = to_string(_completedCreditHours);
// string들을 모두 pack
numBytes = buffer.Pack (idString.c_str());
if (numBytes == -1) return false;
numBytes = buffer.Pack (_name.c_str());
if (numBytes == -1) return false;
numBytes = buffer.Pack (_address.c_str());
if (numBytes == -1) return false;
numBytes = buffer.Pack (_dateOfFirstEnrollment.c_str());
if (numBytes == -1) return false;
numBytes = buffer.Pack (completedCreditHoursString.c_str());
if (numBytes == -1) return false;
return true;
}
示例2: Pack
int Person::Pack(IOBuffer &Buffer) const{
int numBytes;
Buffer.Clear();
numBytes = Buffer.Pack(LastName);
if(numBytes==-1) return 0;
numBytes = Buffer.Pack(FirstName);
if(numBytes==-1) return 0;
numBytes = Buffer.Pack(Address);
if(numBytes==-1) return 0;
numBytes = Buffer.Pack(City);
if(numBytes==-1) return 0;
numBytes = Buffer.Pack(State);
if(numBytes==-1) return 0;
numBytes = Buffer.Pack(ZipCode);
if(numBytes==-1) return 0;
return 1;
}