MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / CreatePropVector

Method CreatePropVector

src/twparser/parserhelper.cpp:668–754  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// CreatePropVector -- given the string representation of the attribute vector, create an FCOPropVector //////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

666// create an FCOPropVector
667///////////////////////////////////////////////////////////////////////////////
668void cParserUtil::CreatePropVector(const TSTRING& strPropListC, class cFCOPropVector& v, iParserGenreUtil* pHelper)
669{
670 ASSERT(pHelper != NULL);
671
672 // state: turning modes on or off
673 enum Mode
674 {
675 MO_TURNON,
676 MO_TURNOFF
677 };
678 Mode mode = MO_TURNON;
679
680 // clear out all spaces in the string
681 TSTRING strPropList = strPropListC;
682 strPropList.erase(std::remove_if(strPropList.begin(), strPropList.end(), std::ptr_fun<int, int>(std::isspace)),
683 strPropList.end());
684
685 // zero it out
686 v.Clear();
687
688 TSTRING::const_iterator iter;
689 TSTRING::size_type i; // index into string
690 for (iter = strPropList.begin(), i = 0; iter != strPropList.end(); ++iter, ++i)
691 {
692 int propIndex = -1; // index into propvector
693
694 switch (*iter)
695 {
696 /////////////////////////////////////////////////////////////
697 // parsing modes
698 case '+':
699 mode = MO_TURNON;
700 continue;
701 case '-':
702 mode = MO_TURNOFF;
703 continue;
704 /////////////////////////////////////////////////////////////
705
706 /////////////////////////////////////////////////////////////
707 // long attribute names
708 case '&':
709 {
710 //
711 // collect string
712 //
713
714 // find next '&', '+', or '-'
715 TSTRING::size_type next = util_FindNextDelim(strPropList, i + 1);
716
717 // get attribute name
718 TSTRING strProp;
719 if (next == TSTRING::npos)
720 strProp = strPropList.substr(i + 1);
721 else
722 strProp = strPropList.substr(i + 1, next - i - 1);
723
724 // increment past string
725 iter += strProp.length();

Callers

nothing calls this directly

Calls 8

util_FindNextDelimFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
MapStringToPropertyMethod · 0.80
AddItemAndGrowMethod · 0.80
ClearMethod · 0.45
lengthMethod · 0.45
RemoveItemMethod · 0.45

Tested by

no test coverage detected