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

Method Encode

src/core/displayencoder.cpp:613–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611//////////////////////////////////////////////////////////////////////////////
612
613void cEncoder::Encode(TSTRING& strIn) const
614{
615 // TODO:BAM -- reserve space for strOut as an optimization?
616 TSTRING strOut; // encoded string we will build up
617
618 TSTRING::const_iterator cur = strIn.begin(); // pointer to working position in strIn
619 const TSTRING::const_iterator end = strIn.end(); // end of strIn
620 TSTRING::const_iterator first = end; // identifies beginning of current character
621 TSTRING::const_iterator last = end; // identifies end of current character
622
623 // while get next char (updates cur)
624 while (cCharUtil::PopNextChar(cur, end, first, last))
625 {
626 bool fCharEncoded = false; // answers: did char need encoding?
627 sack_type::const_iterator atE;
628
629 // for all encoders
630 for (atE = m_encodings.begin(); atE != m_encodings.end(); atE++)
631 {
632 // does char need encoding?
633 if ((*atE)->NeedsEncoding(first, last))
634 {
635 strOut += Encode(first, last, atE);
636 fCharEncoded = true;
637 break; // each char should only fail at most one
638 // encoding test, so it should be cool to quit
639 }
640 }
641
642 if (!fCharEncoded)
643 {
644 strOut.append(first, last); // simply add current char to output since it needed no encoding
645 }
646 }
647
648 // pass back encoded string
649 strIn = strOut;
650}
651
652TSTRING
653cEncoder::Encode(TSTRING::const_iterator first, TSTRING::const_iterator last, sack_type::const_iterator encoding) const

Callers 3

PrintErrorMsgMethod · 0.45
EncodeInlineMethod · 0.45
EncodeInlineAllowWSMethod · 0.45

Calls 5

beginMethod · 0.80
endMethod · 0.80
NeedsEncodingMethod · 0.80
EncodeRoundtripMethod · 0.80
EncodePrettyMethod · 0.80

Tested by

no test coverage detected