本文整理汇总了C++中ReadTag函数的典型用法代码示例。如果您正苦于以下问题:C++ ReadTag函数的具体用法?C++ ReadTag怎么用?C++ ReadTag使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadTag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Connect
int Connect(PLC *Plc,char *TagName, char *responseValue)
{
int result=SUCCESS;
int path_size=0;
char ip[16];
BYTE path[40];
Eip_Session *Session=NULL;
Eip_Connection *Connection=NULL;
int dataType;
Log(LOG_DEBUG,"[Connect] Building Session for %s\n",Plc->PlcName);
path_size=ParsePath(Plc->PlcPath,ip,path);
if (path_size>0)
{
Session=OpenSession(ip);
if (Session!=NULL)
{
if (RegisterSession(Session)<0)
{
CloseSession(Session);
Log(LOG_CRIT,"[Connect] Unable to register session for Plc: %s (%s) \n",Plc->PlcName,cip_err_msg);
return ERROR;
}
} else
{
Log(LOG_CRIT,"[Connect] Unable to open session for Plc: %s (%s)\n",Plc->PlcName,cip_err_msg);
return ERROR;
}
if (Plc->NetWork)
Connection=ConnectPLCOverDHP(Session,Plc->PlcType,(int)Session,GetSerial(),MAX_SAMPLE,Plc->NetWork,path,path_size);
else
Connection=ConnectPLCOverCNET(Session,Plc->PlcType,(int)Session,GetSerial(),MAX_SAMPLE,path,path_size);
if (Connection!=NULL)
{
Log(LOG_DEBUG,"[Connect] Connection (%p) created for PLC : %s (%s) )\n",Connection,Plc->PlcName,cip_err_msg);
} else
{
Log(LOG_CRIT,"[Connect] Unable to create connection for Plc: %s (%s)\n",Plc->PlcName,cip_err_msg);
return ERROR;
}
} else Log(LOG_ERR,"[Connect] Invalid path : %s\n",Plc->PlcPath);
Log(LOG_DEBUG,"[Connect] Connect : %s [%s](%p / %p)\n",TagName,writeValue,Session,Connection);
if (ReadTag(Plc, Session, Connection, TagName, &dataType, responseValue)!=SUCCESS)
return ERROR;
else
{
if (isWrite)
{
if (WriteTag(Plc, Session, Connection, TagName,dataType)!=SUCCESS)
return ERROR;
Log(LOG_DEBUG,"[Connect] %s [%s] %x (%p / %p)\n",TagName,writeValue,dataType,Session,Connection);
if (ReadTag(Plc, Session, Connection, TagName, &dataType, responseValue)!=SUCCESS)
return ERROR;
}
}
return result;
}
示例2: switch
void OsmAnd::ObfRoutingSectionReader_P::readBorderLineHeader(
const std::unique_ptr<ObfReader_P>& reader,
const std::shared_ptr<ObfRoutingBorderLineHeader>& borderLine, uint32_t outerOffset)
{
auto cis = reader->_codedInputStream.get();
for(;;)
{
auto tag = cis->ReadTag();
switch(gpb::internal::WireFormatLite::GetTagFieldNumber(tag))
{
case 0:
return;
case OBF::OsmAndRoutingIndex_RouteBorderLine::kXFieldNumber:
cis->ReadVarint32(&borderLine->_x);
break;
case OBF::OsmAndRoutingIndex_RouteBorderLine::kYFieldNumber:
cis->ReadVarint32(&borderLine->_y);
break;
case OBF::OsmAndRoutingIndex_RouteBorderLine::kToxFieldNumber:
cis->ReadVarint32(&borderLine->_x2);
borderLine->_x2present = true;
break;
case OBF::OsmAndRoutingIndex_RouteBorderLine::kToyFieldNumber:
cis->ReadVarint32(&borderLine->_y2);
borderLine->_y2present = true;
break;
case OBF::OsmAndRoutingIndex_RouteBorderLine::kShiftToPointsBlockFieldNumber:
borderLine->_offset = outerOffset + ObfReaderUtilities::readBigEndianInt(cis);
break;
default:
ObfReaderUtilities::skipUnknownField(cis, tag);
break;
}
}
}
示例3: switch
void OsmAnd::ObfTransportSectionReader_P::readTransportStopsBounds( const std::unique_ptr<ObfReader_P>& reader, const std::shared_ptr<ObfTransportSectionInfo>& section )
{
auto cis = reader->_codedInputStream.get();
for(;;)
{
auto tag = cis->ReadTag();
switch(gpb::internal::WireFormatLite::GetTagFieldNumber(tag))
{
case 0:
return;
case OBF::TransportStopsTree::kLeftFieldNumber:
section->_area24.left = ObfReaderUtilities::readSInt32(cis);
break;
case OBF::TransportStopsTree::kRightFieldNumber:
section->_area24.right = ObfReaderUtilities::readSInt32(cis);
break;
case OBF::TransportStopsTree::kTopFieldNumber:
section->_area24.top = ObfReaderUtilities::readSInt32(cis);
break;
case OBF::TransportStopsTree::kBottomFieldNumber:
section->_area24.bottom = ObfReaderUtilities::readSInt32(cis);
break;
default:
ObfReaderUtilities::skipUnknownField(cis, tag);
break;
}
}
}
示例4: switch
void OsmAnd::ObfPoiSectionReader_P::readCategory( const std::unique_ptr<ObfReader_P>& reader, const std::shared_ptr<Model::AmenityCategory>& category )
{
auto cis = reader->_codedInputStream.get();
for(;;)
{
auto tag = cis->ReadTag();
switch(gpb::internal::WireFormatLite::GetTagFieldNumber(tag))
{
case 0:
return;
case OBF::OsmAndCategoryTable::kCategoryFieldNumber:
ObfReaderUtilities::readQString(cis, category->_name);
break;
case OBF::OsmAndCategoryTable::kSubcategoriesFieldNumber:
{
QString name;
if(ObfReaderUtilities::readQString(cis, name))
category->_subcategories.push_back(name);
}
break;
default:
ObfReaderUtilities::skipUnknownField(cis, tag);
break;
}
}
}
示例5: switch
void OsmAnd::ObfMapSectionReader_P::readEncodingDecodingRules(
const std::unique_ptr<ObfReader_P>& reader,
const std::shared_ptr<ObfMapSectionDecodingEncodingRules>& encodingDecodingRules)
{
auto cis = reader->_codedInputStream.get();
uint32_t defaultId = 1;
for(;;)
{
gpb::uint32 tag = cis->ReadTag();
switch(gpb::internal::WireFormatLite::GetTagFieldNumber(tag))
{
case 0:
{
encodingDecodingRules->createMissingRules();
}
return;
case OBF::OsmAndMapIndex::kRulesFieldNumber:
{
gpb::uint32 length;
cis->ReadVarint32(&length);
auto oldLimit = cis->PushLimit(length);
readEncodingDecodingRule(reader, defaultId++, encodingDecodingRules);
cis->PopLimit(oldLimit);
}
break;
default:
ObfReaderUtilities::skipUnknownField(cis, tag);
break;
}
}
}
示例6: SubRead
static long SubRead ( LFA_FileRef inFileRef, RiffState & inOutRiffState, long parentid, UInt32 parentlen, UInt64 & inOutPosition )
{
long tag;
long subtype = 0;
long parentnum;
UInt32 len, total, childlen;
UInt64 oldpos;
total = 0;
parentnum = (long) inOutRiffState.tags.size() - 1;
UInt64 maxOffset = inOutPosition + parentlen;
while ( parentlen > 0 ) {
oldpos = inOutPosition;
ReadTag ( inFileRef, &tag, &len, &subtype, inOutPosition, maxOffset );
AddTag ( inOutRiffState, tag, len, inOutPosition, parentid, parentnum, subtype );
len += (len & 1); //padding byte
if ( subtype == 0 ) {
childlen = 8 + len;
} else {
childlen = 12 + SubRead ( inFileRef, inOutRiffState, subtype, len, inOutPosition );
}
if ( parentlen < childlen ) parentlen = childlen;
parentlen -= childlen;
total += childlen;
}
return total;
}
示例7: if
void OsmAnd::ObfMapSectionReader_P::readTreeNodeChildren(
const std::unique_ptr<ObfReader_P>& reader, const std::shared_ptr<const ObfMapSectionInfo>& section,
const std::shared_ptr<ObfMapSectionLevelTreeNode>& treeNode,
MapFoundationType& foundation,
QList< std::shared_ptr<ObfMapSectionLevelTreeNode> >* nodesWithData,
const AreaI* bbox31,
IQueryController* controller)
{
auto cis = reader->_codedInputStream.get();
for(;;)
{
auto tag = cis->ReadTag();
switch(gpb::internal::WireFormatLite::GetTagFieldNumber(tag))
{
case 0:
return;
case OBF::OsmAndMapIndex_MapDataBox::kBoxesFieldNumber:
{
auto length = ObfReaderUtilities::readBigEndianInt(cis);
auto offset = cis->CurrentPosition();
auto oldLimit = cis->PushLimit(length);
std::shared_ptr<ObfMapSectionLevelTreeNode> childNode(new ObfMapSectionLevelTreeNode());
childNode->_foundation = treeNode->_foundation;
childNode->_offset = offset;
childNode->_length = length;
readTreeNode(reader, section, treeNode->_area31, childNode);
if(bbox31 && !bbox31->intersects(childNode->_area31))
{
cis->Skip(cis->BytesUntilLimit());
cis->PopLimit(oldLimit);
break;
}
cis->PopLimit(oldLimit);
if(childNode->_foundation != MapFoundationType::Undefined)
{
if(foundation == MapFoundationType::Undefined)
foundation = childNode->_foundation;
else if(foundation != childNode->_foundation)
foundation = MapFoundationType::Mixed;
}
if(nodesWithData && childNode->_dataOffset > 0)
nodesWithData->push_back(childNode);
cis->Seek(offset);
oldLimit = cis->PushLimit(length);
cis->Skip(childNode->_childrenInnerOffset);
readTreeNodeChildren(reader, section, childNode, foundation, nodesWithData, bbox31, controller);
assert(cis->BytesUntilLimit() == 0);
cis->PopLimit(oldLimit);
}
break;
default:
ObfReaderUtilities::skipUnknownField(cis, tag);
break;
}
}
}
示例8: Handle
void Handle(char c)
{
switch(state)
{
case State::Default:
ReadDefault(c);
break;
case State::ReadTagName:
ReadTagName(c);
break;
case State::SkipTag:
SkipTag(c);
break;
case State::ReadTag:
ReadTag(c);
break;
case State::ReadAttribute:
ReadAttribute(c);
break;
case State::SkipAttribute:
SkipAttribute(c);
break;
case State::SkipComment:
SkipComment(c);
break;
}
}
示例9: NEEDBYTES
bool cParsedNBT::ReadList(eTagType a_ChildrenType)
{
// Reads the latest tag as a list of items of type a_ChildrenType
// Read the count:
NEEDBYTES(4);
int Count = ntohl(*((int *)(m_Data + m_Pos)));
m_Pos += 4;
if (Count < 0)
{
return false;
}
// Read items:
int ParentIdx = m_Tags.size() - 1;
int PrevSibling = -1;
for (int i = 0; i < Count; i++)
{
m_Tags.push_back(cFastNBTTag(a_ChildrenType, ParentIdx, PrevSibling));
if (PrevSibling >= 0)
{
m_Tags[PrevSibling].m_NextSibling = m_Tags.size() - 1;
}
else
{
m_Tags[ParentIdx].m_FirstChild = m_Tags.size() - 1;
}
PrevSibling = m_Tags.size() - 1;
RETURN_FALSE_IF_FALSE(ReadTag());
} // for (i)
m_Tags[ParentIdx].m_LastChild = PrevSibling;
return true;
}
示例10: GTIFImport
int GTIFImport(GTIF *gtif, GTIFReadMethod scan,void *aux)
{
int status;
char message[1024];
if (!scan) scan = (GTIFReadMethod) &DefaultRead;
if (!aux) aux=stdin;
scan(message,aux);
if (strncmp(message,FMT_GEOTIFF,8)) return 0;
scan(message,aux);
if (!sscanf(message,FMT_VERSION,(short int*)>if->gt_version)) return 0;
scan(message,aux);
if (sscanf(message,FMT_REV,(short int*)>if->gt_rev_major,
(short int*)>if->gt_rev_minor) !=2) return 0;
scan(message,aux);
if (strncmp(message,FMT_TAGS,8)) return 0;
while ((status=ReadTag(gtif,scan,aux))>0);
if (status < 0) return 0;
scan(message,aux);
if (strncmp(message,FMT_KEYS,8)) return 0;
while ((status=ReadKey(gtif,scan,aux))>0);
return (status==0); /* success */
}
示例11: while
bool cParsedNBT::ReadCompound(void)
{
// Reads the latest tag as a compound
int ParentIdx = m_Tags.size() - 1;
int PrevSibling = -1;
while (true)
{
NEEDBYTES(1);
eTagType TagType = (eTagType)(m_Data[m_Pos]);
m_Pos++;
if (TagType == TAG_End)
{
break;
}
m_Tags.push_back(cFastNBTTag(TagType, ParentIdx, PrevSibling));
if (PrevSibling >= 0)
{
m_Tags[PrevSibling].m_NextSibling = m_Tags.size() - 1;
}
else
{
m_Tags[ParentIdx].m_FirstChild = m_Tags.size() - 1;
}
PrevSibling = m_Tags.size() - 1;
RETURN_FALSE_IF_FALSE(ReadString(m_Tags.back().m_NameStart, m_Tags.back().m_NameLength));
RETURN_FALSE_IF_FALSE(ReadTag());
} // while (true)
m_Tags[ParentIdx].m_LastChild = PrevSibling;
return true;
}
示例12: ReadTag
bool InstallerTagData::FindAndParseTag(const std::wstring& filename) {
// Get tag from original installer (mini_installer, parent process)
omaha::TagExtractor extractor;
if (!extractor.OpenFile(filename.c_str()))
return false;
bool res = ReadTag(&extractor);
extractor.CloseFile();
return res;
}
示例13: ReadTag
//***************************************************************************************
BOOL CBCGPXMLSettings::Read(LPCTSTR pszKey, int& iVal)
{
LPCTSTR lpszVal = ReadTag (pszKey);
if (lpszVal == NULL)
{
return FALSE;
}
iVal = _ttoi (lpszVal);
return TRUE;
}
示例14: if
void OsmAnd::ObfRoutingSectionReader_P::readBorderBoxLinesHeaders(const std::unique_ptr<ObfReader_P>& reader,
QList< std::shared_ptr<const ObfRoutingBorderLineHeader> >* resultOut /*= nullptr*/,
IQueryFilter* filter /*= nullptr*/,
std::function<bool (const std::shared_ptr<const ObfRoutingBorderLineHeader>&)> visitor /*= nullptr*/)
{
auto cis = reader->_codedInputStream.get();
for(;;)
{
auto tag = cis->ReadTag();
switch(gpb::internal::WireFormatLite::GetTagFieldNumber(tag))
{
case 0:
return;
case OBF::OsmAndRoutingIndex_RouteBorderBox::kBorderLinesFieldNumber:
{
auto offset = cis->CurrentPosition();
gpb::uint32 length;
cis->ReadVarint32(&length);
auto oldLimit = cis->PushLimit(length);
const std::shared_ptr<ObfRoutingBorderLineHeader> line(new ObfRoutingBorderLineHeader());
readBorderLineHeader(reader, line, offset);
cis->PopLimit(oldLimit);
bool isValid = true;
if(filter)
{
if(line->_x2present)
isValid = filter->acceptsArea(AreaI(line->_x, line->_y, line->_x2, line->_y));
else
isValid = false;
/*FIXME: borders approach
else if(ln.hasToy())
isValid = req.intersects(ln.getX(), ln.getY(), ln.getX(), ln.getToy());*/
}
if(isValid)
{
if(!visitor || (visitor && visitor(line)))
{
if(resultOut)
resultOut->push_back(qMove(line));
}
}
}
break;
case OBF::OsmAndRoutingIndex_RouteBorderBox::kBlocksFieldNumber:
return;
default:
ObfReaderUtilities::skipUnknownField(cis, tag);
break;
}
}
}
示例15: switch
void OsmAnd::ObfTransportSectionReader_P::read( const ObfReader_P& reader, const std::shared_ptr<ObfTransportSectionInfo>& section )
{
const auto cis = reader.getCodedInputStream().get();
for(;;)
{
const auto tag = cis->ReadTag();
switch(gpb::internal::WireFormatLite::GetTagFieldNumber(tag))
{
case 0:
if (!ObfReaderUtilities::reachedDataEnd(cis))
return;
return;
case OBF::OsmAndTransportIndex::kRoutesFieldNumber:
ObfReaderUtilities::skipUnknownField(cis, tag);
break;
case OBF::OsmAndTransportIndex::kNameFieldNumber:
ObfReaderUtilities::readQString(cis, section->name);
break;
case OBF::OsmAndTransportIndex::kStopsFieldNumber:
{
section->_stopsLength = ObfReaderUtilities::readBigEndianInt(cis);
section->_stopsOffset = cis->CurrentPosition();
auto oldLimit = cis->PushLimit(section->_stopsLength);
readTransportStopsBounds(reader, section);
ObfReaderUtilities::ensureAllDataWasRead(cis);
cis->PopLimit(oldLimit);
}
break;
case OBF::OsmAndTransportIndex::kStringTableFieldNumber:
{
gpb::uint32 length;
cis->ReadVarint32(&length);
auto offset = cis->CurrentPosition();
cis->Seek(offset + length);
}
//TODO:
/*IndexStringTable st = new IndexStringTable();
st.length = codedIS.readRawVarint32();
st.fileOffset = codedIS.getTotalBytesRead();
// Do not cache for now save memory
// readStringTable(st, 0, 20, true);
ind.stringTable = st;
codedIS.seek(st.length + st.fileOffset);*/
break;
default:
ObfReaderUtilities::skipUnknownField(cis, tag);
break;
}
}
}