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


C++ wxJSONValue::ItemAt方法代码示例

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


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

示例1: GetRemoteProfileName

wxString eSettings::GetRemoteProfileName(size_t profile_id) const {
	const wxJSONValue remotes = m_jsonRoot.ItemAt(wxT("remoteProfiles"));
	wxASSERT((int)profile_id < remotes.Size());
	const wxJSONValue profile = remotes.ItemAt(profile_id);
	
	return profile.ItemAt(wxT("name")).AsString();
}
开发者ID:boulerne,项目名称:e,代码行数:7,代码来源:eSettings.cpp

示例2: GetPagePath

wxString eSettings::GetPagePath(size_t page_id) const {
	const wxJSONValue pages = m_jsonRoot.ItemAt(wxT("pages"));
	wxASSERT((int)page_id < pages.Size());
	const wxJSONValue page = pages.ItemAt(page_id);

	return page.ItemAt(wxT("path")).AsString();
}
开发者ID:boulerne,项目名称:e,代码行数:7,代码来源:eSettings.cpp

示例3: GetSearch

void eSettings::GetSearch(size_t ndx, wxString& pattern, bool& isRegex, bool& matchCase) const {
	const wxJSONValue searches = m_jsonRoot.ItemAt(wxT("searchHistory"));
	wxASSERT((int)ndx < searches.Size());

	const wxJSONValue item = searches.ItemAt(ndx);
	pattern = item.ItemAt(wxT("pattern")).AsString();
	isRegex = item.ItemAt(wxT("isRegex")).AsBool();
	matchCase = item.ItemAt(wxT("matchCase")).AsBool();
}
开发者ID:boulerne,项目名称:e,代码行数:9,代码来源:eSettings.cpp

示例4: GetPageDoc

doc_id eSettings::GetPageDoc(size_t page_id) const {
	const wxJSONValue pages = m_jsonRoot.ItemAt(wxT("pages"));
	wxASSERT((int)page_id < pages.Size());
	const wxJSONValue page = pages.ItemAt(page_id);

	doc_id di;
	di.type = (doc_type)page.ItemAt(wxT("doc_type")).AsInt();
	di.document_id = page.ItemAt(wxT("doc_doc")).AsInt();
	di.version_id = page.ItemAt(wxT("doc_version")).AsInt();

	return di;
}
开发者ID:boulerne,项目名称:e,代码行数:12,代码来源:eSettings.cpp

示例5: GetSettingString

bool eSettings::GetSettingString(const wxString& name, wxString& value) const {
	if (!m_jsonRoot.HasMember(wxT("settings"))) return false;

	const wxJSONValue settings = m_jsonRoot.ItemAt(wxT("settings"));
	if (!settings.HasMember(name)) return false;

	const wxJSONValue val = settings.ItemAt(name);
	if (!val.IsString()) return false;

	value = val.AsString();
	return true;
}
开发者ID:boulerne,项目名称:e,代码行数:12,代码来源:eSettings.cpp

示例6: GetSettingBool

bool eSettings::GetSettingBool(const wxString& name, bool& value) const {
	if (!m_jsonRoot.HasMember(wxT("settings"))) return false;

	const wxJSONValue settings = m_jsonRoot.ItemAt(wxT("settings"));
	if (!settings.HasMember(name)) return false;

	// old bool values may have been stored as ints
	const wxJSONValue val = settings.ItemAt(name);
	if (val.IsInt()) return (val.AsInt() > 0);

	if (!val.IsBool()) return false;

	value = val.AsBool();
	return true;
}
开发者ID:boulerne,项目名称:e,代码行数:15,代码来源:eSettings.cpp

示例7: AddToRecent

void eSettings::AddToRecent(const wxString& key, wxJSONValue& jsonArray, size_t max) {
	const wxJSONValue value(key);

	// Check if value is already in array
	int ndx = -1;
	for (int i = 0; i < jsonArray.Size(); ++i) {
		if (value.IsSameAs(jsonArray.ItemAt(i))) {
			ndx = i;
			break;
		}
	}

	if (ndx == 0) return; // No need to do anything if path is already top
	
	if (ndx > 0) jsonArray.Remove(ndx); // remove duplicate entry

	// Insert value at top
	jsonArray.Insert(0, value);

	// Make sure we have no more than max entries
	if (jsonArray.Size() > (int)max) jsonArray.Remove(max);
}
开发者ID:boulerne,项目名称:e,代码行数:22,代码来源:eSettings.cpp

示例8: DoGetRemoteProfile

RemoteProfile* eSettings::DoGetRemoteProfile(size_t profile_id)  {
	// Check if profile is already in cache
	for (auto_vector<RemoteProfile>::iterator p = m_tempRemotes.begin(); p != m_tempRemotes.end(); ++p) {
		if ((*p)->m_id == (int)profile_id) return *p;
	}

	// Get the profile
	const wxJSONValue remotes = m_jsonRoot.ItemAt(wxT("remoteProfiles"));
	wxASSERT((int)profile_id < remotes.Size());
	const wxJSONValue profile = remotes.ItemAt(profile_id);
	
	// Add profile to cache
	auto_ptr<RemoteProfile> rp(new RemoteProfile());
	rp->m_id = profile_id;
	rp->m_protocol = profile.ItemAt(wxT("protocol")).AsString();
	rp->m_name = profile.ItemAt(wxT("name")).AsString();
	rp->m_address = profile.ItemAt(wxT("address")).AsString();
	rp->m_dir = profile.ItemAt(wxT("dir")).AsString();
	rp->m_username = profile.ItemAt(wxT("username")).AsString();
	rp->m_pwd = profile.ItemAt(wxT("pwd")).AsString();
	m_tempRemotes.push_back(rp);

	return m_tempRemotes.back();
}
开发者ID:boulerne,项目名称:e,代码行数:24,代码来源:eSettings.cpp

示例9: if


//.........这里部分代码省略.........

    case wxJSONTYPE_MEMORYBUFF :
        lastChar = WriteMemoryBuff( os, value.AsMemoryBuff());
        break;

    case wxJSONTYPE_ARRAY :
        ++m_level;
        os.PutC( '[' );
        // the inline comment for objects and arrays are printed in the open char
        if ( commentPos == wxJSONVALUE_COMMENT_INLINE )   {
            commentPos = -1;  // we have already written the comment
            lastChar = WriteComment( os, value, false );
            if ( lastChar < 0 )   {
                return lastChar;
            }
            if ( lastChar != '\n' )   {
                lastChar = WriteSeparator( os );
            }
        }
        else   {    // comment is not to be printed inline, so write a LF
            lastChar = WriteSeparator( os );
            if ( lastChar < 0 )   {
                return lastChar;
            }
        }

        // now iterate through all sub-items and call DoWrite() recursively
        size = value.Size();
        for ( int i = 0; i < size; i++ )  {
            bool comma = false;
            if ( i < size - 1 )  {
                comma = true;
            }
            wxJSONValue v = value.ItemAt( i );
            lastChar = DoWrite( os, v, 0, comma );
            if ( lastChar < 0 )  {
                return lastChar;
            }

        }
        --m_level;
        lastChar = WriteIndent( os );
        if ( lastChar < 0 )   {
            return lastChar;
        }
        os.PutC( ']' );
        break;

    case wxJSONTYPE_OBJECT :
        ++m_level;

        os.PutC( '{' );
        // the inline comment for objects and arrays are printed in the open char
        if ( commentPos == wxJSONVALUE_COMMENT_INLINE )   {
            commentPos = -1;  // we have already written the comment
            lastChar = WriteComment( os, value, false );
            if ( lastChar < 0 )   {
                return lastChar;
            }
            if ( lastChar != '\n' )   {
                WriteSeparator( os );
            }
        }
        else   {
            lastChar = WriteSeparator( os );
        }
开发者ID:CarCode,项目名称:Cocoa-OCPN,代码行数:67,代码来源:jsonwriter.cpp

示例10: GetFilterCommand

wxString eSettings::GetFilterCommand(size_t ndx) const {
	const wxJSONValue values = m_jsonRoot.ItemAt(wxT("filterCommandHistory"));
	wxASSERT((int)ndx < values.Size());

	return values.ItemAt(ndx).AsString();
}
开发者ID:boulerne,项目名称:e,代码行数:6,代码来源:eSettings.cpp

示例11: GetReplace

wxString eSettings::GetReplace(size_t ndx) const {
	const wxJSONValue replacements = m_jsonRoot.ItemAt(wxT("replaceHistory"));
	wxASSERT((int)ndx < replacements.Size());

	return replacements.ItemAt(ndx).AsString();
}
开发者ID:boulerne,项目名称:e,代码行数:6,代码来源:eSettings.cpp

示例12: GetRemoteProfileFromUrl

const RemoteProfile* eSettings::GetRemoteProfileFromUrl(const wxString& url, bool withDir) {
	// Split url up in elements
	wxRegEx reUrl(wxT("([[:alpha:]]+)://(([^:@]*):([^:@]*)@)?([^/]+)(.*)"));
	if (!reUrl.Matches(url)) return NULL; // invalid url

	const wxString protocol = reUrl.GetMatch(url, 1);
	const wxString username = reUrl.GetMatch(url, 3);
	const wxString pwd = reUrl.GetMatch(url, 4);
	const wxString address = reUrl.GetMatch(url, 5);
	const wxString dir = reUrl.GetMatch(url, 6);
	const wxString sDir = StripSlashes(dir);

	// See if we can find a matching profile in cache
	for (auto_vector<RemoteProfile>::iterator p = m_tempRemotes.begin(); p != m_tempRemotes.end(); ++p) {
		RemoteProfile* rp = (*p);
		if (rp->IsActive() && rp->m_address == address && rp->m_protocol == protocol) {
			if (!username.empty() && rp->m_username != username) continue;
			if (withDir && StripSlashes(rp->m_dir) != sDir) continue;
			if (!pwd.empty() && rp->m_pwd != pwd) {
				rp->m_pwd = pwd; // Password may have changed
				if (!rp->IsTemp()) SaveRemoteProfile(rp);
			}
			return rp;
		}
	}

	// See if we can find a matching profile in settings
	const wxJSONValue remotes = m_jsonRoot.ItemAt(wxT("remoteProfiles"));
	const int profile_count = remotes.Size();
	for (int i = 0; i < profile_count; ++i) {
		const wxJSONValue profile = remotes.ItemAt(i);
		if (profile.ItemAt(wxT("address")).AsString() != address) continue;

		// Ftp is default protocol
		wxString prot = profile.ItemAt(wxT("protocol")).AsString();
		if (prot.empty()) prot = wxT("ftp");

		if (prot != protocol) continue; // ftp is default
		if (!username.empty() && profile.ItemAt(wxT("username")).AsString() != username) continue;

		RemoteProfile* rp = DoGetRemoteProfile(i);
		if (withDir && StripSlashes(rp->m_dir) != sDir) continue;

		// Password may have changed
		if (!pwd.empty() && rp->m_pwd != pwd) {
			rp->m_pwd = pwd;
			SaveRemoteProfile(rp);
		}

		return rp;
	}

	// Add new temp profile
	auto_ptr<RemoteProfile> newRp(new RemoteProfile());
	newRp->m_protocol = protocol;
	newRp->m_name = address;
	newRp->m_address = address;
	newRp->m_dir = dir;
	newRp->m_username = username;
	newRp->m_pwd = pwd;
	m_tempRemotes.push_back(newRp);
	return m_tempRemotes.back();
}
开发者ID:boulerne,项目名称:e,代码行数:63,代码来源:eSettings.cpp

示例13: GetPageSettings

void eSettings::GetPageSettings(size_t page_id, wxString& path, doc_id& di, int& pos, int& topline, wxString& syntax, vector<unsigned int>& folds, vector<unsigned int>& bookmarks) const {
	const wxJSONValue pages = m_jsonRoot.ItemAt(wxT("pages"));
	wxASSERT((int)page_id < pages.Size());
	const wxJSONValue page = pages.ItemAt(page_id);

	path = page.ItemAt(wxT("path")).AsString();
	pos = page.ItemAt(wxT("pos")).AsInt();
	topline = page.ItemAt(wxT("topline")).AsInt();
	syntax = page.ItemAt(wxT("syntax")).AsString();

	// doc_id
	di.type = (doc_type)page.ItemAt(wxT("doc_type")).AsInt();
	di.document_id = page.ItemAt(wxT("doc_doc")).AsInt();
	di.version_id = page.ItemAt(wxT("doc_version")).AsInt();

	// Set folds
	const wxJSONValue foldsArray = page.ItemAt(wxT("folds"));
	for (int f = 0; f < foldsArray.Size(); ++f) {
		folds.push_back(foldsArray.ItemAt(f).AsInt());
	}

	// Set bookmarks
	const wxJSONValue bookmarksArray = page.ItemAt(wxT("bookmarks"));
	for (int b = 0; b < bookmarksArray.Size(); ++b) {
		bookmarks.push_back(bookmarksArray.ItemAt(b).AsInt());
	}
}
开发者ID:boulerne,项目名称:e,代码行数:27,代码来源:eSettings.cpp

示例14: GetRecents

void eSettings::GetRecents(const wxJSONValue& jarray, wxArrayString& recents) const {
	for (int i = 0; i < jarray.Size(); ++i) {
		recents.Add(jarray.ItemAt(i).AsString());
	}
}
开发者ID:boulerne,项目名称:e,代码行数:5,代码来源:eSettings.cpp


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