本文整理汇总了C++中Annotation::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Annotation::clear方法的具体用法?C++ Annotation::clear怎么用?C++ Annotation::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Annotation
的用法示例。
在下文中一共展示了Annotation::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
bool Annotation::read(const QString& p_sFileName, Annotation &p_Annotation)
{
p_Annotation.clear();
printf("Reading annotation...\n");
QFile t_File(p_sFileName);
QFileInfo fileInfo(t_File.fileName());
p_Annotation.m_sFileName = fileInfo.fileName();
p_Annotation.m_sFilePath = fileInfo.filePath();
if (!t_File.open(QIODevice::ReadOnly))
{
printf("\tError: Couldn't open the file\n");
return false;
}
QDataStream t_Stream(&t_File);
t_Stream.setByteOrder(QDataStream::BigEndian);
qint32 numEl;
t_Stream >> numEl;
p_Annotation.m_Vertices = VectorXi(numEl);
p_Annotation.m_LabelIds = VectorXi(numEl);
for(qint32 i = 0; i < numEl; ++i)
{
t_Stream >> p_Annotation.m_Vertices[i];
t_Stream >> p_Annotation.m_LabelIds[i];
}
qint32 hasColortable;
t_Stream >> hasColortable;
if (hasColortable)
{
p_Annotation.m_Colortable.clear();
//Read colortable
qint32 numEntries;
t_Stream >> numEntries;
qint32 len;
if(numEntries > 0)
{
printf("\tReading from Original Version\n");
p_Annotation.m_Colortable.numEntries = numEntries;
t_Stream >> len;
QByteArray tmp;
tmp.resize(len);
t_Stream.readRawData(tmp.data(),len);
p_Annotation.m_Colortable.orig_tab = tmp;
for(qint32 i = 0; i < numEntries; ++i)
p_Annotation.m_Colortable.struct_names.append("");
p_Annotation.m_Colortable.table = MatrixXi(numEntries,5);
for(qint32 i = 0; i < numEntries; ++i)
{
t_Stream >> len;
tmp.resize(len);
t_Stream.readRawData(tmp.data(),len);
p_Annotation.m_Colortable.struct_names[i]= tmp;
for(qint32 j = 0; j < 4; ++j)
t_Stream >> p_Annotation.m_Colortable.table(i,j);
p_Annotation.m_Colortable.table(i,4) = p_Annotation.m_Colortable.table(i,0)
+ p_Annotation.m_Colortable.table(i,1) * 256 //(2^8)
+ p_Annotation.m_Colortable.table(i,2) * 65536 //(2^16)
+ p_Annotation.m_Colortable.table(i,3) * 16777216; //(2^24);
}
}
else
{
示例2: if
void
Decoder::decodeVariation(Consumer& consumer, util::ByteStream& data, ByteStream& text)
{
MarkSet marks;
MoveInfoSet moveInfo;
Annotation annotation;
mstl::string buf;
Comment comment;
Comment preComment;
bool hasNote(false); // satisfies the compiler
unsigned pieceNum(0); // satisfies the compiler
Move move;
Move lastMove;
while (true)
{
Byte b = m_strm.get();
if (__builtin_expect(b > token::Last, 1))
{
if (move)
{
if (hasNote)
{
consumer.putMove(move, annotation, preComment, comment, marks);
if (!moveInfo.isEmpty())
{
consumer.putMoveInfo(moveInfo);
moveInfo.clear();
}
marks.clear();
annotation.clear();
comment.clear();
preComment.clear();
hasNote = false;
}
else
{
consumer.putMove(move);
}
m_position.doMove(move, pieceNum);
}
else
{
if (lastMove)
{
m_position.doMove(lastMove, pieceNum);
lastMove.clear();
}
if (hasNote)
{
consumer.putPrecedingComment(comment, annotation, marks);
marks.clear();
annotation.clear();
comment.clear();
hasNote = false;
}
}
pieceNum = decodeMove(b, move);
}
else
{
switch (b)
{
case token::End_Marker:
if (move)
{
if (hasNote)
{
consumer.putMove(move, annotation, preComment, comment, marks);
if (!moveInfo.isEmpty())
consumer.putMoveInfo(moveInfo);
}
else
{
consumer.putMove(move);
}
}
else if (hasNote)
{
consumer.putPrecedingComment(comment, annotation, marks);
hasNote = false;
}
switch (m_strm.get())
{
case token::Comment:
{
uint8_t flag = data.get();
buf.clear();
text.get(buf);
comment.swap(buf, bool(flag & comm::Ante_Eng), bool(flag & comm::Ante_Oth));
consumer.putTrailingComment(comment);
break;
}
case token::End_Marker: break;
//.........这里部分代码省略.........