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


C++ wxCharBuffer::data方法代码示例

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


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

示例1: GetEnvBlock

const char* cxEnv::GetEnvBlock() const {
	// Add all lines together to a single string
	m_envStr.clear();
	m_envStr.reserve(m_env.size() * 40);
	for (map<wxString, wxString>::const_iterator p = m_env.begin(); p != m_env.end(); ++p) {
		wxString line = p->first;
		line += wxT('=');
		line += p->second;

		//wxLogDebug(wxT("%d: %s"), i, line);

		// Convert
		const wxCharBuffer buf = line.mb_str(wxConvUTF8);
		const char* str = buf.data();

		m_envStr.insert(m_envStr.end(), str, str+strlen(str));
		m_envStr.push_back('\0');
	}

	// Add end marker
	m_envStr.push_back('\0');

	return &*m_envStr.begin();
}
开发者ID:boulerne,项目名称:e,代码行数:24,代码来源:Env.cpp

示例2: XmlText

void Styler_Syntax::XmlText(unsigned int offset, const submatch& sm, unsigned int start, unsigned int end, vector<char>& text) const {
	unsigned int textstart = start;

	for (auto_vector<stxmatch>::const_iterator p = sm.matches.begin(); p != sm.matches.end(); ++p) {
		const stxmatch& m = *(*p);

		// Check if there is overlap
		if (m.end <= start) continue;
		if (m.start >= m.end) break;
		const unsigned int matchstart = wxMax(start, m.start);
		const unsigned int matchend = wxMin(end, m.end);

		// Print text before submatch
		if (textstart < matchstart) {
			const unsigned int len = matchstart - textstart;
			text.resize(text.size() + len);
			cxLOCKDOC_READ(m_doc)
				doc.GetTextPart(offset + textstart, offset + matchstart, (unsigned char*)(&*text.end() - len));
			cxENDLOCK
		}

		// Start tag
		const wxCharBuffer name = m.m_name.mb_str();
		const size_t len = strlen(name.data());
		if (len) {
			text.push_back('<');
			text.insert(text.end(), name.data(), name.data() + len);
			text.push_back('>');
		}

		// Subscopes
		if (m.subMatch.get()) {
			XmlText(offset + m.start, *m.subMatch, matchstart - m.start, matchend - m.start, text);
		}
		else {
			// Print text contained in submatch
			if (matchstart < matchend) {
				const unsigned int len = matchend - matchstart;
				text.resize(text.size() + len);
				cxLOCKDOC_READ(m_doc)
					doc.GetTextPart(offset + matchstart, offset + matchend, (unsigned char*)(&*text.end() - len));
				cxENDLOCK
			}
		}

		// End tag
		if (len) {
			text.push_back('<');
			text.push_back('/');
			text.insert(text.end(), name.data(), name.data() + len);
			text.push_back('>');
		}

		textstart = matchend;
	}

	// Print text after last submatch
	if (textstart < end) {
		const unsigned int len = end - textstart;
		text.resize(text.size() + len);
		cxLOCKDOC_READ(m_doc)
			doc.GetTextPart(offset + textstart, offset + end, (unsigned char*)(&*text.end() - len));
		cxENDLOCK
	}
}
开发者ID:BBkBlade,项目名称:e,代码行数:65,代码来源:styler_syntax.cpp

示例3: InsertStyle

bool PreviewDlg::InsertStyle(vector<char>& html) {
	// Check if we should replace style sheet ref
	if (!m_pinnedEditor) return false;
	if (html.empty()) return false;
	const wxString cssFilePath = m_editorCtrl->GetPath();
	if (!cssFilePath.EndsWith(wxT(".css"))) return false;

	// Compile patterns
	const char *error;
	int erroffset;
	if (!m_re_style) {
		m_re_style = pcre_compile(
			"<link[^>]+rel=\"stylesheet\"[^>]*>",   // the pattern
			PCRE_UTF8|PCRE_MULTILINE|PCRE_CASELESS,  // options
			&error,               // for error message
			&erroffset,           // for error offset
			NULL);                // use default character tables
	}
	if (!m_re_href) {
		m_re_href = pcre_compile(
			"href=\"(.*?.css).*?\"",   // the pattern
			PCRE_UTF8|PCRE_MULTILINE|PCRE_CASELESS,  // options
			&error,               // for error message
			&erroffset,           // for error offset
			NULL);                // use default character tables
	}

	// Do the search for style tag
	const int OVECCOUNT = 30;
	int ovector[OVECCOUNT];
	const int rc1 = pcre_exec(
		m_re_style,              // the compiled pattern
		NULL,                    // extra data - if we study the pattern
		&*html.begin(),            // the subject string
		wxMin(800, html.size()), // the length of the subject
		0,                       // start at offset in the subject
		PCRE_NO_UTF8_CHECK,      // options
		ovector,                 // output vector for substring information
		OVECCOUNT);              // number of elements in the output vector
	if (rc1 == 0) return false;

	const unsigned int tag_start_pos = ovector[0];
	const char* tag_start = &*html.begin() + tag_start_pos;
	const unsigned int tag_len = ovector[1] - ovector[0];

	// Do the search for href tag with css path
	const int rc2 = pcre_exec(
		m_re_href,               // the compiled pattern
		NULL,                    // extra data - if we study the pattern
		tag_start,               // the subject string
		tag_len,                 // the length of the subject
		0,                       // start at offset in the subject
		PCRE_NO_UTF8_CHECK,      // options
		ovector,                 // output vector for substring information
		OVECCOUNT);              // number of elements in the output vector

	if (rc2 == 2) {
		const unsigned int style_start = tag_start_pos + ovector[2];
		const unsigned int style_end = tag_start_pos + ovector[3];

		// Get match
		const wxString stylePath(&*html.begin()+style_start, wxConvUTF8, style_end-style_start);
		wxString localPath = cssFilePath;
		localPath.Replace(wxT("\\"), wxT("/"));

		if (localPath.EndsWith(stylePath)) {
			// Make sure we have temp file
			// Since css does not offer a base url, we have to place it in same location
			const wxString cssPath = wxPathOnly(cssFilePath);
			if (wxPathOnly(m_tempCssPath) != cssPath) {
				if (!m_tempCssPath.empty() && wxFileExists(m_tempCssPath)) wxRemoveFile(m_tempCssPath);
				m_tempCssPath = cssPath + wxFILE_SEP_PATH + wxT(".e_preview_temp.css");
				wxFile file(m_tempCssPath, wxFile::write); // create the temp file
				if (file.IsOpened()) {
					file.Close(); // allow file to be modified
#ifdef __WXMSW__
					// Make sure the file is marked as hidden and temporary
					//::SetFileAttributes(m_tempCssPath, FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_NOT_CONTENT_INDEXED|FILE_ATTRIBUTE_TEMPORARY); // Hiding seems to give problems on Vista
					::SetFileAttributes(m_tempCssPath, FILE_ATTRIBUTE_NOT_CONTENT_INDEXED|FILE_ATTRIBUTE_TEMPORARY);
#endif
				}
			}

			const wxCharBuffer buff = m_tempCssPath.mb_str(wxConvUTF8);
			html.erase(html.begin()+style_start, html.begin()+style_end);
			html.insert(html.begin()+style_start, buff.data(), buff.data()+strlen(buff.data()));

			return true;
		}
	}

	return false;
}
开发者ID:baguatuzi,项目名称:e,代码行数:93,代码来源:PreviewDlg.cpp

示例4: OnMenuNew

void BundlePane::OnMenuNew(wxCommandEvent& event) {
	const int menuId = event.GetId();

	switch (menuId) {
		case MENU_NEW_BUNDLE:
			{
				// Get name from user
				const wxString name = wxGetTextFromUser(_("Name of new item:"), _("New Item"), _("New Bundle"), this);
				if (name.empty()) return; // user cancel

				// Create a new  bundle item
				const unsigned int bundleId = m_plistHandler.NewBundle(name);
				m_plistHandler.SaveBundle(bundleId);

				// Add to tree
				const wxTreeItemId rootItem = m_bundleTree->GetRootItem();
				const wxTreeItemId bundleItem = m_bundleTree->AppendItem(rootItem, name, 0, -1, new BundleItemData(bundleId));
				const wxTreeItemId menuItem = m_bundleTree->AppendItem(bundleItem, _("Menu"), 6, -1, new BundleItemData(BUNDLE_MENU, bundleId));
				m_bundleTree->SortChildren(rootItem);
				m_bundleTree->SelectItem(bundleItem);
			}
			break;
		case MENU_NEW_COMMAND:
			NewItem(BUNDLE_COMMAND);
			break;
		case MENU_NEW_SNIPPET:
			NewItem(BUNDLE_SNIPPET);
			break;
		case MENU_NEW_DRAGCMD:
			NewItem(BUNDLE_DRAGCMD);
			break;
		case MENU_NEW_PREF:
			NewItem(BUNDLE_PREF);
			break;
		case MENU_NEW_LANGUAGE:
			NewItem(BUNDLE_LANGUAGE);
			break;
		case MENU_NEW_SEPARATOR:
			{
				const wxTreeItemId selItem = m_bundleTree->GetSelection();
				const BundleItemData* data = (BundleItemData*)m_bundleTree->GetItemData(selItem);

				PListDict infoDict = GetEditableMenuPlist(data->m_bundleId);
				InsertMenuItem(selItem, wxT("---- separator ----"), new BundleItemData(BUNDLE_SEPARATOR, data->m_bundleId), infoDict);
				m_plistHandler.SaveBundle(data->m_bundleId);

				// Update menu in editorFrame
				m_syntaxHandler.ReParseBundles(true/*onlyMenu*/);
			}
			break;
		case MENU_NEW_SUBMENU:
			{
				// Get name from user
				const wxString name = wxGetTextFromUser(_("Name of new item:"), _("New Item"), _("New SubMenu"), this);
				if (name.empty()) return; // user cancel

				const wxTreeItemId selItem = m_bundleTree->GetSelection();
				const BundleItemData* data = (BundleItemData*)m_bundleTree->GetItemData(selItem);
				
				// Get a new uuid
				const wxString newUuid = PListHandler::GetNewUuid();
				const wxCharBuffer uuidBuf = newUuid.ToUTF8();
				const char* uuid = uuidBuf.data();

				// Create the new group
				PListDict infoDict = GetEditableMenuPlist(data->m_bundleId);
				PListDict menuDict;
				if (!infoDict.GetDict("mainMenu", menuDict)) {
					wxFAIL_MSG(wxT("No mainMenu in info.plist"));
					return;
				}
				PListDict submenuDict = menuDict.NewDict("submenus");
				PListDict subDict = submenuDict.NewDict(uuid);
				subDict.NewArray("items");
				subDict.wxSetString("name", name);

				// Insert in menu
				InsertMenuItem(selItem, name, new BundleItemData(BUNDLE_SUBDIR, data->m_bundleId, newUuid), infoDict);
				m_plistHandler.SaveBundle(data->m_bundleId);

				// Update menu in editorFrame
				m_syntaxHandler.ReParseBundles(true/*onlyMenu*/);
			}
			break;
		default: wxASSERT(false);
	}
};
开发者ID:khmerlovers,项目名称:e,代码行数:87,代码来源:BundlePane.cpp


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