当前位置: 首页>>代码示例>>C++>>正文


C++ wstring::cend方法代码示例

本文整理汇总了C++中std::wstring::cend方法的典型用法代码示例。如果您正苦于以下问题:C++ wstring::cend方法的具体用法?C++ wstring::cend怎么用?C++ wstring::cend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::wstring的用法示例。


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

示例1: if

void
editor_type::substhere (
    std::wstring::const_iterator const bos,
    std::wstring const& replacement,
    std::vector<std::size_t>& cap, std::wstring& doc)
{
    std::wstring::const_iterator i;
    for (i = replacement.cbegin (); i < replacement.cend (); ++i)
        if ('$' == i[0] && i + 1 < replacement.cend ()
                && ('&' == i[1] || ('0' <= i[1] && i[1] <= '9'))) {
            std::size_t n = '&' == i[1] ? 0 : i[1] - '0';
            if (n * 2 + 1 < cap.size ()
                    && cap[n * 2] != std::wstring::npos
                    && cap[n * 2 + 1] != std::wstring::npos)
                doc.append (bos + cap[n * 2], bos + cap[n * 2 + 1]);
            ++i;
        }
        else if ('\\' == *i && i + 1 < replacement.cend ()) {
            int c = *++i;
            c = 'n' == c ? '\n' : 't' == c ? '\t' : c;
            doc.push_back (c);
        }
        else
            doc.push_back (*i);
}
开发者ID:tociyuki,项目名称:edit-cxx11,代码行数:25,代码来源:editor.cpp

示例2:

void
editor_type::unquote (std::wstring const& src, std::wstring& dst)
{
    std::wstring::const_iterator i;
    for (i = src.cbegin (); i < src.cend (); ++i)
        if ('\\' == *i && i + 1 < src.cend ()) {
            int c = *++i;
            c = 'n' == c ? '\n' : 't' == c ? '\t' : c;
            dst.push_back (c);
        }
        else
            dst.push_back (*i);
}
开发者ID:tociyuki,项目名称:edit-cxx11,代码行数:13,代码来源:editor.cpp

示例3: LineWrap

std::wstring MultiLineTextView::LineWrap(const std::wstring& str, int wrap)
{
    uint32_t lCh = -1;
    int adv = 0;

    std::wstring ret;
    ret.reserve(str.size());
    std::wstring::const_iterator lastSpaceIt = str.cend();
    size_t rollbackPos;
    for (std::wstring::const_iterator it = str.cbegin() ; it != str.cend() ; ++it)
    {
        wchar_t ch = *it;
        if (ch == L'\n')
        {
            ret += L'\n';
            lCh = -1;
            lastSpaceIt = str.cend();
            adv = 0;
            continue;
        }

        const FontAtlas::Glyph* glyph = m_fontAtlas.lookupGlyph(ch);
        if (!glyph)
            continue;

        if (lCh != -1)
            adv += TextView::DoKern(m_fontAtlas.lookupKern(lCh, glyph->m_glyphIdx), m_fontAtlas);
        adv += glyph->m_advance;

        if (adv > wrap && lastSpaceIt != str.cend())
        {
            ret.assign(ret.cbegin(), ret.cbegin() + rollbackPos);
            ret += L'\n';
            lCh = -1;
            it = lastSpaceIt;
            lastSpaceIt = str.cend();
            adv = 0;
            continue;
        }

        if (ch == L' ' || ch == L'-')
        {
            lastSpaceIt = it + 1;
            rollbackPos = ret.size() + 1;
        }
        ret += ch;
        lCh = glyph->m_glyphIdx;
    }

    return ret;
}
开发者ID:zoujiaqing,项目名称:specter,代码行数:51,代码来源:MultiLineTextView.cpp

示例4: ParseExtensionFromString

std::wstring ParseExtensionFromString(const std::wstring& src)
{
	std::wstring::const_iterator extensionStart = src.cend();

	for (auto it = src.cbegin(); it != src.cend(); it++)
	{
		if ((*it) == '.')
		{
			extensionStart = it;
		}
	}

	return std::wstring(extensionStart, src.cend());
}
开发者ID:legersun,项目名称:Novus-Engine,代码行数:14,代码来源:StringUtils.cpp

示例5: format_value

 // Format wide character versions of the above.
 std::string format_value(std::wstring const& value)
 {
     static_assert(sizeof(wchar_t) == 2, "This method needs to be inspected / updated if wchar_t is not UTF-16.");
     std::string result;
     result.reserve(value.size());
     utf8::utf16to8(value.cbegin(), value.cend(), std::back_inserter(result));
     return result;
 }
开发者ID:BillyONeal,项目名称:Instalog,代码行数:9,代码来源:LogSink.cpp

示例6:

    path::path(std::wstring const& string)
        : capacity_(0)
        , base_(nullptr)
    {
        this->size_ = string.size();
        this->ensure_capacity(string.size());

        auto upperStart = this->upperBase();
        std::copy(string.cbegin(), string.cend(), this->base_);
        this->base_[this->size_] = L'\0';
        path::uppercase_range(this->size_, this->base_, upperStart);
        upperStart[this->size_] = L'\0';
    }
开发者ID:BillyONeal,项目名称:pevFind,代码行数:13,代码来源:Path.cpp

示例7: msg

ulong CCmdLog::msg(ulong id, const std::wstring& msg, bool append)
{
	std::wstring *pmsg; LPLOGGER plog; if (id <= 0) return 0;

	EnterCriticalSection(&m_csShare);

	// Initialize the sorted data if it hasn't initialize yet ..
	if (Issortedinit(&m_Table.sorted) == 0) {
		if (Createsorteddata (				// Make sure it's already initialized.
			&m_Table.sorted,			// Descriptor of sorted data
			sizeof(LOGGER),					// Size of single data item
			10,									// Initial number of allocated items
			(SORTFUNC *)CCmdLog::SortProc,	// Sorting function
			(DESTFUNC *)CCmdLog::DestProc,	// Data destructor
			0
		) != 0)  { LeaveCriticalSection(&m_csShare); return 0; }
	}
	
	
	// Get the logger ..
	void *temp = Findsorteddata(&m_Table.sorted, id, 0);
	if ((plog = reinterpret_cast<LPLOGGER>(temp)) != nullptr) {

		m_Table.custommode -= plog->rows;

		pmsg = reinterpret_cast<std::wstring*>(plog->msge);
		if (pmsg == nullptr) pmsg = new std::wstring();
		if (append == false) { pmsg->clear(); plog->rows = 0; }
		else if (pmsg->back() != text('\n')) --plog->rows;
		// Extract the message ...
		std::wstring::const_iterator itr, eitr = msg.cend();
		for (itr = msg.cbegin(); itr != eitr; ++itr) {
			// We don't support old mac format ...
			if (*itr == text('\t')) { pmsg->append(8, text(' ')); continue; }
			if (*itr == text('\r')) continue;
			if (*itr == text('\n')) ++ plog->rows;
			pmsg->push_back(*itr);
		} if (pmsg->back() != text('\n')) ++ plog->rows;
		plog->msge = pmsg;			// Set the string ...

		m_Table.custommode += plog->rows;

	} else id = 0;	// return 0 if the logger doesn't exist.

	LeaveCriticalSection(&m_csShare);

	// Redrawing the logger window and return ..
	if (m_Table.offset <= 0) Updatetable(&m_Table, false);
	else PostMessage(m_Table.hw,WM_VSCROLL,SB_PAGEDOWN,0); 
	return id;
}
开发者ID:zzydog,项目名称:OllyDog,代码行数:51,代码来源:CmdLog.cpp

示例8: WStrToUtf8

bool WStrToUtf8(const std::wstring& wstr, std::string& utf8str)
{
    try
    {
        std::string utf8str2;
        utf8str2.resize(wstr.size() * 4);                   // allocate for most long case

        auto end = utf8::utf16to8(wstr.cbegin(), wstr.cend(), utf8str2.begin());
        if (end != utf8str2.end())
            utf8str2.erase(end, utf8str2.end());

        utf8str = utf8str2;
    }
    catch (const std::exception&)
    {
        utf8str = "";
        return false;
    }

    return true;
}
开发者ID:lduguid,项目名称:mangos-tbc,代码行数:21,代码来源:Util.cpp

示例9: log

ulong CCmdLog::log(ulong id, int code, int type, const std::wstring &msg)
{
	std::wstring *pmsg = nullptr; void *temp = nullptr;
	LPLOGGER plog = nullptr; ulong ulNewId = 0;

	EnterCriticalSection(&m_csShare);

	if (Issortedinit(&m_Table.sorted) == 0) {
		if (Createsorteddata (				// Make sure it's already initialized.
			&m_Table.sorted,					// Descriptor of sorted data
			sizeof(LOGGER),					// Size of single data item
			10,									// Initial number of allocated items
			(SORTFUNC *)CCmdLog::SortProc,	// Sorting function
			(DESTFUNC *)CCmdLog::DestProc,	// Data destructor
			0
		) != 0) { LeaveCriticalSection(&m_csShare); return 0; }
	}
	
	if (id <= 0) {							// Add new record ..
		// Can't add logger any more ...
		if (m_Table.custommode < MAXINT) {

			// Find a new id ..
			while (Findsorteddata(&m_Table.sorted, m_nNextId, 0))
				++ m_nNextId;

			// Initialize a new item ...
			time_t timer; time(&timer); LOGGER logger = {
				m_nNextId, 1, type, 0, LOGGER_FLAG_IDLE, 
				timer, code, nullptr
			};
			// Initialize a new string.. (it's suck without c++11)
			std::wstring *pmsg = new std::wstring();
			std::wstring::const_iterator itr, eitr = msg.cend();
			for (itr = msg.cbegin(); itr != eitr; ++itr) {
				// We don't support old mac format ...
				if (*itr == text('\r')) continue;
				if (*itr == text('\n')) ++logger.rows;
				pmsg->push_back(*itr);
			} if (pmsg->back() != text('\n')) {
				pmsg->push_back(text('\n')); ++logger.rows;
			}	logger.msge = pmsg;	// Set the string ....

			// Add a new item and return it's id ..
			temp = Addsorteddata(&m_Table.sorted, &logger);;
			plog = reinterpret_cast<LPLOGGER>(temp);
			if (plog != nullptr) ulNewId = plog->addr;
			else { ulNewId = 0; delete logger.msge; }
			
			// Update the line count ..
			if (plog) m_Table.custommode += plog->rows;
			
		}
		
	} else {									// Modify existed records .
		temp = Findsorteddata(&m_Table.sorted, id, 0);
		if ((plog = reinterpret_cast<LPLOGGER>(temp)) != nullptr) {

			m_Table.custommode -= plog->rows;

			// Update the logger ..
			plog->code = code; plog->type = type; plog->rows = 0;
			pmsg = reinterpret_cast<std::wstring*>(plog->msge);
			if (pmsg == nullptr) pmsg = new std::wstring();
			else pmsg->clear();		// Clear the message first..
			std::wstring::const_iterator itr, eitr = msg.cend();
			for (itr = msg.cbegin(); itr != eitr; ++itr) {
				// We don't support old mac format ...
				if (*itr == text('\r')) continue;
				if (*itr == text('\n')) ++plog->rows;
				pmsg->push_back(*itr);
			} if (pmsg->back() != text('\n')) {
				pmsg->push_back(text('\n')); ++plog->rows;
			}	plog->msge = pmsg;		// Set the string ....

			m_Table.custommode += plog->rows;

			// Return this id .
			ulNewId = plog->addr;
		
		}
	}

	LeaveCriticalSection(&m_csShare);

	// Redrawing the logger window and return ..
	if (m_Table.offset <= 0) Updatetable(&m_Table, false);
	else PostMessage(m_Table.hw,WM_VSCROLL,SB_PAGEDOWN,0); 
	return ulNewId;
}
开发者ID:zzydog,项目名称:OllyDog,代码行数:90,代码来源:CmdLog.cpp

示例10: serializeString

	Message::bytes Message::serializeUTF16(const std::wstring& str)
	{
		std::string u;
		utf8::utf16to8(str.cbegin(), str.cend(), std::back_inserter(u));
		return serializeString(u);
	}
开发者ID:axnsan12,项目名称:Airplanes,代码行数:6,代码来源:Message.cpp


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