本文整理汇总了C++中VString::GetSubString方法的典型用法代码示例。如果您正苦于以下问题:C++ VString::GetSubString方法的具体用法?C++ VString::GetSubString怎么用?C++ VString::GetSubString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VString
的用法示例。
在下文中一共展示了VString::GetSubString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateSpanText
//.........这里部分代码省略.........
outTaggedText += ":"+ value;
addcoma = true;
}
}
if(addforecolortag)
{
VString value;
if(addcoma)
outTaggedText+=";";
ColorToValue(vforecolor,value);
outTaggedText += MS_COLOR;
outTaggedText += ":"+ value;
addcoma = true;
}
if(addbackcolortag)
{
VString value;
if(addcoma)
outTaggedText+=";";
ColorToValue(vbackcolor,value);
outTaggedText += MS_BACKGROUND;
outTaggedText += ":"+ value;
addcoma = true;
}
outTaggedText +="\">";
}
VString text;
VString tmp;
sLONG count = inStyles.GetChildCount();
//prevent assert in GetSubString
if (end > inPlainText.GetLength())
end = inPlainText.GetLength();
if (begin > inPlainText.GetLength())
begin = inPlainText.GetLength();
if(count == 0)
{
if(end>begin)
{
inPlainText.GetSubString(begin+1, end-begin, text);
ToXMLCompatibleText(text, tmp);
outTaggedText += tmp;
}
}
else
{
sLONG start = begin;
for(sLONG i = 1; i <= count; i++)
{
VTreeTextStyle* child = inStyles.GetNthChild(i);
sLONG b,e;
child->GetData()->GetRange(b,e);
//prevent assert in GetSubString
if (e > inPlainText.GetLength())
e = inPlainText.GetLength();
if (b > inPlainText.GetLength())
b = inPlainText.GetLength();
//if(start < b-1)
if(start < b)
{
inPlainText.GetSubString(start+1, b-start, text);
ToXMLCompatibleText(text, tmp);
outTaggedText += tmp;
}
GenerateSpanText(*child, inPlainText, outTaggedText, defaultStyleInherit);
start = e;
}
if(start < end)
{
inPlainText.GetSubString(start+1, end-start, text);
ToXMLCompatibleText(text, tmp);
outTaggedText += tmp;
}
}
if (addtag)
outTaggedText +="</SPAN>";
//JQ 24/12/2012: ensure tagged text is bracketed with SPAN tag
else if (isInitialEmpty)
{
if (!outTaggedText.BeginsWith(CVSTR("<SPAN"), true))
outTaggedText = CVSTR("<SPAN>")+outTaggedText+CVSTR("</SPAN>");
}
if (defaultStyleInherit)
delete defaultStyleInherit;
}
示例2: GetSuggestions
void VHTMLSyntax::GetSuggestions( ICodeEditorDocument* inDocument, sLONG inLineNumber, sLONG inPos, ITipInfoArray *outSuggestions, sLONG& outStartOffset, bool inAll )
{
// Get the text for the line up to the point of insertion, and we'll lex that to see if we can come up
// with some rational suggestions for the user.
VString xstr;
inDocument->GetLine( inLineNumber, xstr );
xstr.Truncate( inPos );
char *lexinput = CreateUTF8String( xstr );
struct htmlLexeme *list = parseHTML( lexinput );
// Gin up some line params for tracking state information
VLineSyntaxParams *currentLineParams = currentLineParams = new VLineSyntaxParams();
if (inLineNumber > 0) {
// We're starting where we left off on the previous line
currentLineParams->CopyState( static_cast< VLineSyntaxParams * >( inDocument->GetLineSyntaxParams( inLineNumber - 1 ) ) );
}
// Given the list of HTML tokens, let's walk over the list and try to make some sense
// of them. Walk over the list one token at a time, and see if we can make sense of
// what we've got. This is going to be awfully similar to the way we do things in the
// SetLine method, except that we're not actually updating the line state for the current
// line. Instead, we're working on a copy of the existing information.
struct htmlLexeme *cur = list;
int lastTokenProcessed = 0;
while (cur) {
if (kKeyword == cur->fStyle) {
lastTokenProcessed = 3;
// Keywords a bit trickier than you might think because we need to be sure they're actually part of a
// tag. If the user types something like: <b>This table rocks</b>, we only want to highlight the b in the
// begin and end tag, and not the "table" in the user's text. To deal with this, we have an "in tag" flag
// that basically turns keyword highlighting on and off.
if (currentLineParams->IsProcessingTag()) {
// If we're processing an opening tag, then we want to push the keyword onto the tag stack. But if we're
// processing a closing tag, then we want to pop the last keyword off the tag stack and try to match it up
// to what we just processed. If they match, we're golden. If not, we just assume the user's mismatching
// their tags because they're an idiot.
VString tagName;
xstr.GetSubString( cur->fOffset + 1, cur->fLength, tagName );
if (currentLineParams->IsProcessingStartTag()) {
currentLineParams->PushTag( tagName );
// Note that we are no longer processing the start of a tag. This allows us to handle attributes
// separately from the tag itself.
currentLineParams->SetIsProcessingStartTag( false );
} else {
VString lastTag;
currentLineParams->PopTag( lastTag );
if (!lastTag.EqualTo( tagName, false )) {
// The tags don't match, so we're just going to ignore the issue
// TODO: do something more sensible here
}
}
}
} else if (kTagOpen == cur->fStyle || kEndTagOpen == cur->fStyle) {
lastTokenProcessed = (kTagOpen == cur->fStyle) ? 1 : 2;
currentLineParams->SetIsProcessingTag( true );
currentLineParams->SetIsProcessingStartTag( kTagOpen == cur->fStyle );
} else if (kTagClose == cur->fStyle || kTagSelfClose == cur->fStyle) {
lastTokenProcessed = 0;
currentLineParams->SetIsProcessingTag( false );
// If we just handled a self-closing tag (like <br />), then we want to pop it from the stack
// TODO: some tags can't have matching pairs, like <br>, so even if it's not self-closing, we want
// to pop it off the tag stack. Handle that here
if (kTagSelfClose == cur->fStyle) {
VString toss;
currentLineParams->PopTag( toss );
}
} else {
lastTokenProcessed = 0;
}
cur = cur->fNext;
}
if (lastTokenProcessed == 1) {
// We processed a tag opener, but no keyword for the tag. So let's make a bunch of suggestions!
} else if (lastTokenProcessed == 2) {
// We processed a tag closer, but no keyword for the tag. Grab the last opened tag from the list
// and suggest it as the closer
VString suggestion;
currentLineParams->LastTag( suggestion );
outSuggestions->AddTip( new VCodeEditorTipInfo( inDocument, suggestion, htmlcolorShadow[ keyword_col ] ) );
}
delete currentLineParams;
FreeLexemeList( list );
}
示例3: ParseSpanText
/** parse span text element or XHTML fragment
@param inTaggedText
tagged text to parse (span element text only if inParseSpanOnly == true, XHTML fragment otherwise)
@param outStyles
parsed styles
@param outPlainText
parsed plain text
@param inParseSpanOnly
true (default): only <span> element(s) with CSS styles are parsed
false: all XHTML text fragment is parsed (parse also mandatory HTML text styles)
*/
void VSpanTextParser::ParseSpanText( const VString& inTaggedText, VTreeTextStyle*& outStyles, VString& outPlainText, bool inParseSpanOnly)
{
outPlainText = "";
if(outStyles)
outStyles->Release();
outStyles = NULL;
if (inTaggedText.IsEmpty())
return;
//fixed ACI0076343: for compatibility with older bases which do not have support for multistyle var or field
// we need to convert to xml text the text which is not bracketed with SPAN
// otherwise parser would fail
VString vtext;
sLONG posStartSPAN = 1; //pos of first SPAN tag
sLONG posEndSPAN = inTaggedText.GetLength()+1; //pos of character following ending SPAN tag
if (inParseSpanOnly)
{
//search for opening SPAN tag
posStartSPAN = inTaggedText.Find("<SPAN", 1, false);
if (!posStartSPAN)
{
//convert full text to xml
inTaggedText.GetXMLString( vtext, XSO_Default);
vtext = VString("<SPAN>")+vtext+"</SPAN>";
}
else
{
VString before, after;
if (posStartSPAN > 1)
{
//convert to XML text preceeding first SPAN
VString temp;
inTaggedText.GetSubString( 1, posStartSPAN-1, temp);
temp.GetXMLString( before, XSO_Default);
}
//search for ending SPAN tag
const UniChar *c = inTaggedText.GetCPointer()+inTaggedText.GetLength()-1;
sLONG pos = inTaggedText.GetLength()-1;
VString spanEndTag = "</SPAN>";
VString spanEndTag2 = "</span>";
do
{
while (pos >= 0 && *c != '>')
{
pos--;
if (pos >= 0)
c--;
}
if (pos >= 0)
{
if (memcmp( (void*)(c+1-spanEndTag.GetLength()), spanEndTag.GetCPointer(), spanEndTag.GetLength()*sizeof(UniChar)) == 0
||
memcmp( (void*)(c+1-spanEndTag2.GetLength()), spanEndTag2.GetCPointer(), spanEndTag2.GetLength()*sizeof(UniChar)) == 0)
{
posEndSPAN = pos+2;
break;
}
else
{
pos--;
if (pos >= 0)
c--;
}
}
} while (pos >= 0);
if (posEndSPAN <= inTaggedText.GetLength())
{
//convert to XML text following ending SPAN tag
VString temp;
inTaggedText.GetSubString( posEndSPAN, inTaggedText.GetLength()-posEndSPAN+1, temp);
temp.GetXMLString( after, XSO_Default);
}
if (!before.IsEmpty() || !after.IsEmpty())
{
inTaggedText.GetSubString( posStartSPAN, posEndSPAN-posStartSPAN, vtext);
vtext = VString("<SPAN>")+before+vtext+after+"</SPAN>";
}
else
vtext = VString("<SPAN>")+inTaggedText+"</SPAN>";
}
}
else
vtext = inTaggedText;
vtext.ExchangeAll(0x0B,0x0D);//[MI] le 28/12/2010 ACI0069253
#if VERSIONWIN
vtext.ConvertCarriageReturns(eCRM_CR); //important here on Windows before parsing because styles are assumed to use one character size for line ending on any platform
//and so pair of 0x0D 0x0A should be treated as a single 0x0D character
#endif
VTaggedTextSAXHandler vsaxhandler(outStyles, &outPlainText, inParseSpanOnly);
//.........这里部分代码省略.........
示例4: SetLine
//.........这里部分代码省略.........
cur = cur->fNext;
continue;
}
if (kCompleteComment == cur->fStyle) {
// A complete comment is the easiest of the three cases. Just highlight it
inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ comment_col ] );
} else if (kCommentOpen == cur->fStyle) {
// An open comment must be the last token in the list
xbox_assert( !cur->fNext );
// We want to highlight from here to the end of the line
inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ comment_col ] );
// We also want to flag that this line ends with an open comment
currentLineParams->SetIsOpenComment( true );
} else if (kCommentClose == cur->fStyle) {
// If we got a close comment token, then something's off. That means the user put in a close comment
// token, but they never opened it. We're going to ignore that state, and flag this as being normal
inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ scommentend_col ] );
} else if (kString == cur->fStyle) {
inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ string_col ] );
} else if (kKeyword == cur->fStyle) {
// Keywords a bit trickier than you might think because we need to be sure they're actually part of a
// tag. If the user types something like: <b>This table rocks</b>, we only want to highlight the b in the
// begin and end tag, and not the "table" in the user's text. To deal with this, we have an "in tag" flag
// that basically turns keyword highlighting on and off.
if (currentLineParams->IsProcessingTag()) {
inDocument->SetLineStyle( inLineNumber, cur->fOffset, cur->fOffset + cur->fLength, htmlcolorShadow[ keyword_col ] );
// If we're processing an opening tag, then we want to push the keyword onto the tag stack. But if we're
// processing a closing tag, then we want to pop the last keyword off the tag stack and try to match it up
// to what we just processed. If they match, we're golden. If not, we just assume the user's mismatching
// their tags because they're an idiot.
VString tagName;
xstr.GetSubString( cur->fOffset + 1, cur->fLength, tagName );
if (currentLineParams->IsProcessingStartTag()) {
if (!IsTagWithoutClose( tagName )) {
openList.push_back( tagName );
}
currentLineParams->PushTag( tagName );
// Note that we are no longer processing the start of a tag. This allows us to handle attributes
// separately from the tag itself.
currentLineParams->SetIsProcessingStartTag( false );
} else {
// Check to see if this closed tag is on the open list. If it is, we want to remove it from the
// list. Otherwise, we want to add it to the close list.
bool bAddToClose = true;
for (std::vector< VString >::iterator iter = openList.begin(); bAddToClose && iter != openList.end();) {
if (tagName.EqualTo( *iter, false )) {
iter = openList.erase( iter );
bAddToClose = false;
} else {
++iter;
}
}
if (bAddToClose) closeList.push_back( tagName );
VString lastTag;
currentLineParams->PopTag( lastTag );
if (!lastTag.EqualTo( tagName, false )) {
// The tags don't match, so we're just going to ignore the issue
// TODO: do something more sensible here
}
}