• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Utf8String类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Utf8String的典型用法代码示例。如果您正苦于以下问题:C++ Utf8String类的具体用法?C++ Utf8String怎么用?C++ Utf8String使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Utf8String类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getPrevComponent

jjm::Utf8String jjm::Path::getFileName() const
{
    Utf8String result; 
    pair<size_t, size_t> const lastComponent = getPrevComponent(path, path.size()); 
    result.append(path.data() + lastComponent.first, path.data() + lastComponent.second); 
    return result; 
}
开发者ID:joshuamaurice,项目名称:jjmake,代码行数:7,代码来源:jpath.cpp


示例2: ClangCodeCompleteResults

ClangCodeCompleteResults CodeCompleter::completeSmartPointerCreation(uint line,
                                                                     uint column,
                                                                     int funcNameStartLine,
                                                                     int funcNameStartColumn)
{
    if (column <= 1 || funcNameStartLine == -1)
        return ClangCodeCompleteResults();

    UnsavedFile &file = unsavedFiles.unsavedFile(translationUnit.filePath());
    if (!file.hasCharacterAt(line, column - 1, '('))
        return ClangCodeCompleteResults();

    bool ok;
    const uint startPos = file.toUtf8Position(funcNameStartLine, funcNameStartColumn, &ok);
    const uint endPos = file.toUtf8Position(line, column - 1, &ok);

    Utf8String content = file.fileContent();
    const QString oldName = content.mid(startPos, endPos - startPos);
    const QString updatedName = tweakName(oldName);
    if (updatedName.isEmpty())
        return ClangCodeCompleteResults();

    column += updatedName.length();
    file.replaceAt(endPos + 1, 0, updatedName);

    ClangCodeCompleteResults results = completeHelper(line, column);
    if (results.isEmpty()) {
        column -= updatedName.length();
        file.replaceAt(endPos + 1, updatedName.length(), QString());
    }
    return results;
}
开发者ID:choenig,项目名称:qt-creator,代码行数:32,代码来源:codecompleter.cpp


示例3:

bool operator<(const Utf8String &first, const Utf8String &second)
{
    if (first.byteSize() == second.byteSize())
        return first.byteArray < second.byteArray;

    return first.byteSize() < second.byteSize();
}
开发者ID:DuinoDu,项目名称:qt-creator,代码行数:7,代码来源:utf8string.cpp


示例4: ExtractFileNameNoExt

const Utf8String ExtractFileNameNoExt(const Utf8String& fileName)
{
	Utf8String result = ExtractFileName(fileName);
	int Qpos = result.find_last_of('.');
	if(Qpos>=0) result = result.substr(0, Qpos);
	return result;
}
开发者ID:akostrikov,项目名称:curl-cpp-wrapper,代码行数:7,代码来源:CoreUtils.cpp


示例5: ObjectHeader

			String::String(Utf8String & str, Class * classPtr): ObjectHeader(classPtr)
			{
				this->dataLength = str.bytes();
				this->hash = str.getHash();
				this->stringLength = str.length();

				memcpy(this->data, str.toAsciiString(), str.bytes());
			}
开发者ID:klinki,项目名称:MI-RUN,代码行数:8,代码来源:String.cpp


示例6: PutFileContents

bool PutFileContents(const Utf8String& utf8Filename, const Utf8String& content)
{
	FILE *stream = fopen_utf8(utf8Filename.c_str(), "wb");
	if(!stream) return false;
	fwrite(content.c_str(), content.length(),1, stream);
	fclose(stream);
	return true;
}
开发者ID:akostrikov,项目名称:curl-cpp-wrapper,代码行数:8,代码来源:CoreUtils.cpp


示例7: StrReplace

Utf8String StrReplace(Utf8String text, Utf8String s, Utf8String d)
{
    for(int index=0; index=text.find(s, index), index!=std::string::npos;)
	{
		text.replace(index, s.length(), d);
		index += d.length();
	}
	return text;
}
开发者ID:akostrikov,项目名称:curl-cpp-wrapper,代码行数:9,代码来源:CoreUtils.cpp


示例8: tokens

SourceRangeContainer FollowSymbol::followSymbol(CXTranslationUnit tu,
                                                const Cursor &fullCursor,
                                                uint line,
                                                uint column)
{
    std::unique_ptr<Tokens> tokens(new Tokens(fullCursor));

    if (!tokens->tokenCount)
        tokens.reset(new Tokens(tu));

    if (!tokens->tokenCount)
        return SourceRangeContainer();

    QVector<CXCursor> cursors(static_cast<int>(tokens->tokenCount));
    clang_annotateTokens(tu, tokens->data, tokens->tokenCount, cursors.data());
    int tokenIndex = getTokenIndex(tu, *tokens, line, column);
    QTC_ASSERT(tokenIndex >= 0, return SourceRangeContainer());

    const Utf8String tokenSpelling = ClangString(
                clang_getTokenSpelling(tu, tokens->data[tokenIndex]));
    if (tokenSpelling.isEmpty())
        return SourceRangeContainer();

    Cursor cursor{cursors[tokenIndex]};

    if (cursor.kind() == CXCursor_InclusionDirective) {
        CXFile file = clang_getIncludedFile(cursors[tokenIndex]);
        const ClangString filename(clang_getFileName(file));
        const SourceLocation loc(tu, filename, 1, 1);
        return SourceRange(loc, loc);
    }

    // For definitions we can always find a declaration in current TU
    if (cursor.isDefinition())
        return extractMatchingTokenRange(cursor.canonical(), tokenSpelling);

    if (!cursor.isDeclaration()) {
        // This is the symbol usage
        // We want to return definition
        cursor = cursor.referenced();
        if (cursor.isNull() || !cursor.isDefinition()) {
            // We can't find definition in this TU
            return SourceRangeContainer();
        }
        return extractMatchingTokenRange(cursor, tokenSpelling);
    }

    cursor = cursor.definition();
    // If we are able to find a definition in current TU
    if (!cursor.isNull())
        return extractMatchingTokenRange(cursor, tokenSpelling);

    return SourceRangeContainer();
}
开发者ID:choenig,项目名称:qt-creator,代码行数:54,代码来源:clangfollowsymbol.cpp


示例9: ExtractFilePath

const Utf8String ExtractFilePath(const Utf8String& fileName)
{
	int i, len = fileName.length();
	for(i = len-1; i >= 0; i--)
	{
		if(fileName[i] == '\\' || fileName[i]=='/')
		{
			return fileName.substr(0, i+1);
		}
			
	}
	return "";
}
开发者ID:akostrikov,项目名称:curl-cpp-wrapper,代码行数:13,代码来源:CoreUtils.cpp


示例10: completeHelper

ClangCodeCompleteResults CodeCompleter::completeHelper(uint line, uint column)
{
    const Utf8String nativeFilePath = FilePath::toNativeSeparators(translationUnit.filePath());
    UnsavedFilesShallowArguments unsaved = unsavedFiles.shallowArguments();

    return clang_codeCompleteAt(translationUnit.cxTranslationUnit(),
                                nativeFilePath.constData(),
                                line,
                                column,
                                unsaved.data(),
                                unsaved.count(),
                                defaultOptions());
}
开发者ID:choenig,项目名称:qt-creator,代码行数:13,代码来源:codecompleter.cpp


示例11: ExtractFileName

Utf8String ExtractFileName(const Utf8String fileName)
{
		Utf8String temp = fileName;
		int Qpos = temp.find_last_of('?');
		if(Qpos>=0) temp = temp.substr(0, Qpos-1);
		int i,len = temp.length();
		for(i=len-1; i>=0; i--)
		{
			if(temp[i] == '\\' || temp[i]=='/')
				break;
		}
		return temp.substr(i+1);
}
开发者ID:akostrikov,项目名称:curl-cpp-wrapper,代码行数:13,代码来源:CoreUtils.cpp


示例12: ExtractFileExt

Utf8String ExtractFileExt(const Utf8String fileName)
{
	int nLen = fileName.length();

	Utf8String result;
	for( int i=nLen-1; i>=0; i-- )
	{
		if(fileName[i] == '.')
		{
			result = fileName.substr(i + 1);
			break;
		}
		else if(fileName[i] == '\\' || fileName[i] == '/') break;
	}
	return result;
}
开发者ID:akostrikov,项目名称:curl-cpp-wrapper,代码行数:16,代码来源:CoreUtils.cpp


示例13: parseText

void CompletionChunksToTextConverter::parseText(const Utf8String &text)
{
    if (canAddSpace()
            && m_previousCodeCompletionChunk.kind() == ClangBackEnd::CodeCompletionChunk::RightBrace) {
        m_text += QChar(QChar::Space);
    }

    m_text += text.toString();
}
开发者ID:raphaelcotty,项目名称:qt-creator,代码行数:9,代码来源:completionchunkstotextconverter.cpp


示例14: PutText

/*
**==============================================================================
**
**  Change the stored text for this element to one that has characters encoded
**  for output
**
**==============================================================================
*/
void CXElement::PutText(Utf8String& sOut, Utf8String& TextIn)
{
    if (!TextIn.Empty())
    {
        // Encode each character of the input string and add it to the output
        // string.
        Utf8String replacementString;
        Utf8String::Iterator start = TextIn.Begin();
        Utf8String::Iterator end = TextIn.End();
        for (; start != end; ++start)
        {
            Utf8String encodedStr;
            EncodeChar (*start, encodedStr);
            replacementString.Append(encodedStr);
        }

        sOut += replacementString;
    }

}
开发者ID:Microsoft,项目名称:pal,代码行数:28,代码来源:XMLWriter.cpp


示例15: ulong

UnsavedFile::UnsavedFile(const Utf8String &filePath, const Utf8String &fileContent)
{
    char *cxUnsavedFilePath = new char[filePath.byteSize() + 1];
    char *cxUnsavedFileContent = new char[fileContent.byteSize() + 1];

    std::memcpy(cxUnsavedFilePath, filePath.constData(), filePath.byteSize() + 1);
    std::memcpy(cxUnsavedFileContent, fileContent.constData(), fileContent.byteSize() + 1);

    cxUnsavedFile = CXUnsavedFile{cxUnsavedFilePath,
                                  cxUnsavedFileContent,
                                  ulong(fileContent.byteSize())};
}
开发者ID:DuinoDu,项目名称:qt-creator,代码行数:12,代码来源:unsavedfile.cpp


示例16: cxSourceLocation

SourceLocation::SourceLocation(CXTranslationUnit cxTranslationUnit,
                               const Utf8String &filePath,
                               uint line,
                               uint column)
    : cxSourceLocation(clang_getLocation(cxTranslationUnit,
                                         clang_getFile(cxTranslationUnit,
                                                 filePath.constData()),
                                         line,
                                         column)),
      filePath_(filePath),
      line_(line),
      column_(column)
{
}
开发者ID:KeeganRen,项目名称:qt-creator,代码行数:14,代码来源:sourcelocation.cpp


示例17: ReadUtf8TextFile

bool ReadUtf8TextFile(Utf8String utf8Filename, Utf8String& data)
{
	FILE *stream = fopen_utf8(utf8Filename.c_str(), "rb");
	if(!stream) return false;
        long size = getFileSize(utf8Filename);
	unsigned char buf[3];
	fread(buf, 1, 3, stream);	


	if(buf[0] == 0xEF || buf[1] == 0xBB || buf[2] == 0xBF) // UTF8 Byte Order Mark (BOM)
	{	
		size -= 3;	
	}
	else if(buf[0] == 0xFF || buf[1] == 0xFE ) {
		// UTF-16LE encoding
		size -= 2;
		fseek( stream, 2L,  SEEK_SET );
		std::wstring res;
		int charCount = size/2;
		res.resize(charCount);
		size_t charsRead = fread(&res[0], 2, charCount, stream);	
		res[charsRead]=0;
		fclose(stream);
		data = WstringToUtf8(res);
		return true;
	} 
	else {
		// no BOM was found; seeking backward
		fseek( stream, 0L,  SEEK_SET );
	}
	data.resize(size + 1);
	size_t bytesRead = fread(&data[0], 1, size, stream);	
	data[bytesRead] = 0;
	fclose(stream);
	return true;
}
开发者ID:akostrikov,项目名称:curl-cpp-wrapper,代码行数:36,代码来源:CoreUtils.cpp


示例18: toNativeSeparators

Utf8String FilePath::toNativeSeparators(const Utf8String &pathName)
{
    const QByteArray pathNameAsByteArray = pathName.toByteArray();

    return Utf8String::fromUtf8(toNativeSeparatorsForQByteArray(pathNameAsByteArray));
}
开发者ID:choenig,项目名称:qt-creator,代码行数:6,代码来源:clangfilepath.cpp


示例19: isOperator

bool isOperator(CXCursorKind cxCursorKind, const Utf8String &name)
{
    return cxCursorKind == CXCursor_ConversionFunction
            || (cxCursorKind == CXCursor_CXXMethod
                && name.startsWith(Utf8StringLiteral("operator")));
}
开发者ID:jlehtoranta,项目名称:sailfish-qtcreator,代码行数:6,代码来源:codecompletionsextractor.cpp


示例20: bindingIndexForName

int SqliteStatement::bindingIndexForName(const Utf8String &name)
{
    return  sqlite3_bind_parameter_index(compiledStatement.get(), name.constData());
}
开发者ID:qtproject,项目名称:qt-creator,代码行数:4,代码来源:sqlitestatement.cpp



注:本文中的Utf8String类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Utilities类代码示例发布时间:2022-05-31
下一篇:
C++ Utf8Str类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap