本文整理汇总了C++中VString::Truncate方法的典型用法代码示例。如果您正苦于以下问题:C++ VString::Truncate方法的具体用法?C++ VString::Truncate怎么用?C++ VString::Truncate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VString
的用法示例。
在下文中一共展示了VString::Truncate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DebugDump
CharSet VValueBag::DebugDump(char* inTextBuffer, sLONG& inBufferSize) const
{
if (VProcess::Get() != NULL)
{
VString dump;
VString temp;
VIndex i;
VIndex count = GetAttributesCount();
for (i = 1 ; i <= count ; ++i)
{
const VValueSingle* theValue = GetNthAttribute( i, &temp);
dump.AppendPrintf("%S = %A\n", &temp, theValue);
}
count = GetElementNamesCount();
for (i = 1 ; i <= count ; ++i)
{
const VBagArray *theBagArray = GetNthElementName( i, &temp);
dump.AppendPrintf("=======\n%d %S :\n", theBagArray->GetCount(), &temp);
for (sLONG j = 1 ; j <= theBagArray->GetCount() ; ++j) {
dump.AppendPrintf("--\n%V", theBagArray->RetainNth(j));
}
}
dump.Truncate(inBufferSize/2);
inBufferSize = (sLONG) dump.ToBlock(inTextBuffer, inBufferSize, VTC_UTF_16, false, false);
} else
inBufferSize = 0;
return VTC_UTF_16;
}
示例2: ResolveAliasFolder
/*
static
*/
VError VFolder::ResolveAliasFolder( VFolder **ioFolder, bool inDeleteInvalidAlias)
{
VError err = VE_OK;
if ( (*ioFolder != NULL) && (*ioFolder)->fPath.IsFolder() && !(*ioFolder)->fFolder.Exists( false /* doesn't check alias */) )
{
// the folder doesn't exists
// maybe is it an alias file?
VString path = (*ioFolder)->fPath.GetPath();
if (testAssert( path[path.GetLength()-1] == FOLDER_SEPARATOR))
{
path.Truncate( path.GetLength()-1);
#if VERSIONWIN
path += ".lnk";
#endif
VFile file( path);
if (file.IsAliasFile() && file.Exists())
{
VFilePath resolvedPath;
err = file.GetImpl()->ResolveAlias( resolvedPath); // nothrow
if (err == VE_OK)
{
if (resolvedPath.IsFolder())
{
(*ioFolder)->Release();
*ioFolder = new VFolder( resolvedPath);
}
else if (inDeleteInvalidAlias)
{
err = file.Delete();
}
else
{
StThrowFileError errThrow( *ioFolder, VE_FILE_CANNOT_RESOLVE_ALIAS_TO_FOLDER);
err = errThrow.GetError();
}
}
else if (inDeleteInvalidAlias)
{
err = file.Delete();
}
else
{
if (IS_NATIVE_VERROR( err))
{
StThrowFileError errThrow( &file, VE_FILE_CANNOT_RESOLVE_ALIAS, err);
err = errThrow.GetError();
}
}
}
}
}
return err;
}
示例3: SwapComment
void VHTMLSyntax::SwapComment( ICodeEditorDocument* inDocument, VString& ioString, bool inComment )
{
if ( inComment )
{
ioString.Insert( CVSTR( "<!--" ), 1 );
ioString += CVSTR( "-->" );
}
else
{
if ( ioString.BeginsWith( CVSTR( "<!--" ) ) )
ioString.Remove( 1, 4 );
if ( ioString.EndsWith( CVSTR( "-->" ) ) )
ioString.Truncate( ioString.GetLength() - 3 );
}
}
示例4: SetFontSize
void VSpanHandler::SetFontSize(const VString& inValue, float inDPI)
{
Real size = 0;
VTextStyle* TheStyle = fStyles->GetData();
if(!TheStyle)
return;
if(inValue.EndsWith("pt", true))
{
VString textsize = inValue;
textsize.Truncate( inValue.GetLength()-2);
size = textsize.GetReal();
//we need convert from format dpi to 72 dpi
#if VERSIONWIN
TheStyle->SetFontSize(floor(size*(inDPI ? inDPI : VSpanTextParser::Get()->GetDPI())/72.0f+0.5f));
#else
TheStyle->SetFontSize(size);
#endif
}
}
示例5: _HandlePacket
VError VServiceDiscoveryServer::_HandlePacket (VUDPEndPoint *inEndPoint, uBYTE *inPacket, uLONG inPacketSize, uLONG inBufferSize)
{
xbox_assert(inEndPoint != NULL);
xbox_assert(inPacket != NULL);
uLONG numberQuestions, size, i, offset;
VError error;
const uBYTE *p;
VString vString;
std::list<VServiceRecord>::iterator j;
std::map<VString, bool> queriedServices, queriedAddresses;
std::map<VString, bool>::iterator k;
if (inPacketSize < 12)
return VE_SRVR_BONJOUR_MALFORMED_PACKET;
if ((inPacket[2] & 0x80)
|| (inPacket[3] & 0x0f)
|| !(numberQuestions = Bonjour::Read2Bytes(&inPacket[4])))
return VE_OK;
p = &inPacket[12];
for (i = 0; i < numberQuestions; i++) {
uWORD questionType, questionClass;
size = inPacketSize;
if ((error = Bonjour::ParseDNSName(inPacket, &size, p - inPacket, &vString)) != VE_OK)
return error;
p += size;
questionType = Bonjour::Read2Bytes(p);
questionClass = Bonjour::Read2Bytes(p + 2);
p += 4;
if (questionClass != 1)
continue;
if (questionType == Bonjour::kTypePTR) {
if (vString.EndsWith(".local", true)) {
vString.Truncate(vString.GetLength() - 6);
for (j = fServiceRecords.begin(); j != fServiceRecords.end(); j++)
if (j->fServiceName.EqualToString(vString, true)) {
queriedServices[vString] = true;
break;
} else if (vString.EqualToString("_services._dns-sd._udp", true)) {
queriedServices[vString] = true;
break;
}
}
} else if (questionType == Bonjour::kTypeA)
queriedAddresses[vString] = true;
// Ignore all other types of queries.
}
error = VE_OK;
offset = p - inPacket;
for (k = queriedServices.begin(); k != queriedServices.end(); k++)
if (k->first.EqualToString("_services._dns-sd._udp", true))
error = _SendServiceList(inEndPoint, inPacket, inBufferSize, offset);
else
error = _AnswerQuery(inEndPoint, inPacket, inBufferSize, offset, k->first);
// Note that a hostname can have several network address(es).
for (k = queriedAddresses.begin(); k != queriedAddresses.end(); k++)
for (j = fServiceRecords.begin(); j != fServiceRecords.end(); j++)
if (j->fHostName.EqualToString(k->first, false))
error = _SendAddressAnswer(inEndPoint, inPacket, inBufferSize, offset, *j);
return error;
}
示例6: _ParsePacket
//.........这里部分代码省略.........
case Bonjour::kTypeAAAA: {
if (dataSize != 16) {
error = VE_SRVR_BONJOUR_MALFORMED_PACKET;
break;
}
for (j = 0; j < pendingRecords.size(); j++)
if (pendingRecords[j].fHasSRV
&& pendingRecords[j].fTarget.EqualToString(name, true)) {
VNetAddress address(*((IP6 *) data));
pendingRecords[j].fServiceRecord.fIPv6Address = address.GetIP(NULL);
pendingRecords[j].fHasAAAA = true;
}
break;
}
case Bonjour::kTypePTR: {
VString notSuffixedName;
notSuffixedName = name;
if (notSuffixedName.EndsWith(".local", true))
notSuffixedName.Truncate(notSuffixedName .GetLength() - 6);
for (j = 0; j < inServiceNames.size(); j++)
if (inServiceNames[j].EqualToString(notSuffixedName, true))
break;
if (j == inServiceNames.size())
break;
size = inPacketSize;
if ((error = Bonjour::ParseDNSName(inPacket, &size , data - inPacket, &vString)) != VE_OK)
break;
if (size != dataSize) {
error = VE_SRVR_BONJOUR_MALFORMED_PACKET;
break;
}
for (j = 0; j < pendingRecords.size(); j++)
if (pendingRecords[j].fServiceRecord.fServiceName.EqualToString(name, true)
&& pendingRecords[j].fServiceRecord.fProviderName.EqualToString(vString, true))
break;
if (j == pendingRecords.size()) {
示例7: 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 );
}