本文整理汇总了C++中JSONElement::arrayItem方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONElement::arrayItem方法的具体用法?C++ JSONElement::arrayItem怎么用?C++ JSONElement::arrayItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONElement
的用法示例。
在下文中一共展示了JSONElement::arrayItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseRefsArray
void NodeJSDebuggerPane::ParseRefsArray(const JSONElement& refs)
{
int refsCount = refs.arraySize();
for(int i = 0; i < refsCount; ++i) {
JSONElement ref = refs.arrayItem(i);
int handleId = ref.namedObject("handle").toInt();
Handle h;
h.type = ref.namedObject("type").toString();
if(h.type == "undefined") {
h.value = "undefined";
} else if(h.type == "number" || h.type == "boolean") {
h.value = ref.namedObject("text").toString();
} else if(h.type == "string") {
h.value << "\"" << ref.namedObject("text").toString() << "\"";
} else if(h.type == "script" || h.type == "function") {
h.value = ref.namedObject("name").toString();
} else if(h.type == "null") {
h.value = "null";
} else if(h.type == "object") {
h.value = "{...}";
JSONElement props = ref.namedObject("properties");
int propsCount = props.arraySize();
for(int n = 0; n < propsCount; ++n) {
JSONElement prop = props.arrayItem(n);
wxString propName = prop.namedObject("name").toString();
int propId = prop.namedObject("ref").toInt();
h.properties.insert(std::make_pair(propId, propName));
}
}
m_handles.insert(std::make_pair(handleId, h));
}
}
示例2: FromJSON
void LLDBReply::FromJSON(const JSONElement& json)
{
m_replyType = json.namedObject("m_replyType").toInt(kReplyTypeInvalid);
m_interruptResaon = json.namedObject("m_stopResaon").toInt(kInterruptReasonNone);
m_line = json.namedObject("m_line").toInt(wxNOT_FOUND);
m_filename = json.namedObject("m_filename").toString();
m_lldbId = json.namedObject("m_lldbId").toInt();
m_expression = json.namedObject("m_expression").toString();
m_debugSessionType = json.namedObject("m_debugSessionType").toInt(kDebugSessionTypeNormal);
m_text = json.namedObject("m_text").toString();
m_breakpoints.clear();
JSONElement arr = json.namedObject("m_breakpoints");
for(int i = 0; i < arr.arraySize(); ++i) {
LLDBBreakpoint::Ptr_t bp(new LLDBBreakpoint());
bp->FromJSON(arr.arrayItem(i));
m_breakpoints.push_back(bp);
}
m_variables.clear();
JSONElement localsArr = json.namedObject("m_locals");
m_variables.reserve(localsArr.arraySize());
for(int i = 0; i < localsArr.arraySize(); ++i) {
LLDBVariable::Ptr_t variable(new LLDBVariable());
variable->FromJSON(localsArr.arrayItem(i));
m_variables.push_back(variable);
}
m_backtrace.Clear();
JSONElement backtrace = json.namedObject("m_backtrace");
m_backtrace.FromJSON(backtrace);
m_threads = LLDBThread::FromJSON(json, "m_threads");
}
示例3: FromJSON
void GitCommandsEntries::FromJSON(const JSONElement& json)
{
m_commands.clear();
m_commandName = json.namedObject("m_commandName").toString();
m_lastUsed = json.namedObject("m_lastUsed").toInt();
JSONElement arrCommandChoices = json.namedObject("m_commands");
for(int i = 0; i < arrCommandChoices.arraySize(); ++i) {
GitLabelCommand item;
item.label = arrCommandChoices.arrayItem(i).namedObject("label").toString();
item.command = arrCommandChoices.arrayItem(i).namedObject("command").toString();
m_commands.push_back(item);
}
}
示例4: FromJSON
void LexerConf::FromJSON(const JSONElement& json)
{
m_name = json.namedObject("Name").toString();
m_lexerId = json.namedObject("Id").toInt();
m_themeName = json.namedObject("Theme").toString();
if(json.hasNamedObject("Flags")) {
m_flags = json.namedObject("Flags").toSize_t();
} else {
SetIsActive(json.namedObject("IsActive").toBool());
SetUseCustomTextSelectionFgColour(json.namedObject("UseCustomTextSelFgColour").toBool());
SetStyleWithinPreProcessor(json.namedObject("StylingWithinPreProcessor").toBool());
}
SetKeyWords(json.namedObject("KeyWords0").toString(), 0);
SetKeyWords(json.namedObject("KeyWords1").toString(), 1);
SetKeyWords(json.namedObject("KeyWords2").toString(), 2);
SetKeyWords(json.namedObject("KeyWords3").toString(), 3);
SetKeyWords(json.namedObject("KeyWords4").toString(), 4);
SetFileSpec(json.namedObject("Extensions").toString());
m_properties.clear();
JSONElement properties = json.namedObject("Properties");
int arrSize = properties.arraySize();
for(int i = 0; i < arrSize; ++i) {
// Construct a style property
StyleProperty p;
p.FromJSON(properties.arrayItem(i));
m_properties.insert(std::make_pair(p.GetId(), p));
}
}
示例5: ParseRef
NodeJSHandle NodeJSOuptutParser::ParseRef(const JSONElement& ref, std::map<int, NodeJSHandle>& handles)
{
int handleId = ref.namedObject("handle").toInt();
NodeJSHandle h;
h.handleID = handleId;
h.type = ref.namedObject("type").toString();
if(h.type == "undefined") {
h.value = "undefined";
} else if(h.type == "number" || h.type == "boolean") {
h.value = ref.namedObject("text").toString();
} else if(h.type == "string") {
h.value << "\"" << ref.namedObject("text").toString() << "\"";
} else if(h.type == "script" || h.type == "function") {
h.value = ref.namedObject("name").toString();
} else if(h.type == "null") {
h.value = "null";
} else if(h.type == "object") {
h.value = "{...}";
JSONElement props = ref.namedObject("properties");
int propsCount = props.arraySize();
for(int n = 0; n < propsCount; ++n) {
JSONElement prop = props.arrayItem(n);
wxString propName = prop.namedObject("name").toString();
int propId = prop.namedObject("ref").toInt();
h.properties.insert(std::make_pair(propId, propName));
}
}
handles.insert(std::make_pair(handleId, h));
return h;
}
示例6: fn
clKeyboardBindingConfig& clKeyboardBindingConfig::Load()
{
wxFileName fn(clStandardPaths::Get().GetUserDataDir(), "keybindings.conf");
fn.AppendDir("config");
if(!fn.Exists()) return *this;
m_bindings.clear();
JSONRoot root(fn);
{
JSONElement menus = root.toElement().namedObject("menus");
int arrSize = menus.arraySize();
for(int i = 0; i < arrSize; ++i) {
JSONElement item = menus.arrayItem(i);
MenuItemData binding;
binding.action = item.namedObject("description").toString();
binding.accel = item.namedObject("accelerator").toString();
binding.parentMenu = item.namedObject("parentMenu").toString();
binding.resourceID = item.namedObject("resourceID").toString();
if(binding.resourceID == "text_word_complete") {
// This entry was moved from Word Completion plugin to CodeLite Edit menu entry
binding.resourceID = "simple_word_completion";
binding.parentMenu = "Edit";
binding.action = "Complete Word";
} else if(binding.resourceID == "complete_word") {
// The "action" was changed
binding.action = "Code Complete";
} else if(binding.resourceID == "word_complete") {
binding.resourceID = "complete_word";
}
m_bindings.insert(std::make_pair(binding.resourceID, binding));
}
}
return *this;
}
示例7: FromJSON
void PHPWorkspace::FromJSON(const JSONElement& e)
{
m_projects.clear();
if(e.hasNamedObject("projects")) {
PHPProject::Ptr_t firstProject;
JSONElement projects = e.namedObject("projects");
int count = projects.arraySize();
for(int i = 0; i < count; ++i) {
PHPProject::Ptr_t p(new PHPProject());
wxString project_file = projects.arrayItem(i).toString();
wxFileName fnProject(project_file);
fnProject.MakeAbsolute(m_workspaceFile.GetPath());
p->Load(fnProject);
m_projects.insert(std::make_pair(p->GetName(), p));
if(!firstProject) {
firstProject = p;
}
}
PHPProject::Ptr_t activeProject = GetActiveProject();
if(!activeProject && firstProject) {
// No active project found, mark the first project as active
activeProject = firstProject;
SetProjectActive(firstProject->GetName());
}
if(activeProject) {
// Notify about active project been set
clProjectSettingsEvent evt(wxEVT_ACTIVE_PROJECT_CHANGED);
evt.SetProjectName(activeProject->GetName());
evt.SetFileName(activeProject->GetFilename().GetFullPath());
EventNotifier::Get()->AddPendingEvent(evt);
}
}
}
示例8: ProcessOutput
void clTernServer::ProcessOutput(const wxString& output, wxCodeCompletionBoxEntry::Vec_t& entries)
{
// code completion response:
// ================================
// {
// "start": 78,
// "end": 78,
// "isProperty": true,
// "isObjectKey": false,
// "completions": [
// {
// "name": "concat",
// "type": "fn(other: [?])",
// "doc": "Returns a new array comprised of this array joined with other array(s) and/or value(s).",
// "url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/concat"
// },
// {
// "name": "every",
// "type": "fn(test: fn(elt: ?, i: number) -> bool, context?: ?) -> bool",
// "doc": "Tests whether all elements in the array pass the test implemented by the provided function.",
// "url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/every"
// }]}
entries.clear();
JSONRoot root(output);
JSONElement completionsArr = root.toElement().namedObject("completions");
for(int i = 0; i < completionsArr.arraySize(); ++i) {
JSONElement item = completionsArr.arrayItem(i);
wxString name = item.namedObject("name").toString();
wxString doc = item.namedObject("doc").toString();
wxString url = item.namedObject("url").toString();
bool isKeyword = item.namedObject("isKeyword").toBool();
int imgId;
if(!isKeyword) {
doc = this->PrepareDoc(doc, url);
wxString type = item.namedObject("type").toString();
wxString sig, ret;
ProcessType(type, sig, ret, imgId);
// Remove double quotes
name.StartsWith("\"", &name);
name.EndsWith("\"", &name);
wxCodeCompletionBoxEntry::Ptr_t entry = wxCodeCompletionBoxEntry::New(name /* + sig*/, imgId);
entry->SetComment(doc);
entries.push_back(entry);
} else {
imgId = 17; // keyword
wxCodeCompletionBoxEntry::Ptr_t entry = wxCodeCompletionBoxEntry::New(name, imgId);
entries.push_back(entry);
}
}
}
示例9: FromJSON
void LLDBBacktrace::FromJSON(const JSONElement& json)
{
m_callstack.clear();
m_threadId = json.namedObject("m_threadId").toInt(0);
JSONElement arr = json.namedObject("m_callstack");
for(int i=0; i<arr.arraySize(); ++i) {
LLDBBacktrace::Entry entry;
entry.FromJSON( arr.arrayItem(i) );
m_callstack.push_back( entry );
}
}
示例10: FromJSON
void PluginInfoArray::FromJSON(const JSONElement& json)
{
m_disabledPlugins = json.namedObject("disabledPlugins").toArrayString();
m_plugins.clear();
JSONElement arr = json.namedObject("installed-plugins");
for(int i=0; i<arr.arraySize(); ++i) {
PluginInfo pi;
pi.FromJSON( arr.arrayItem(i) );
m_plugins.insert(std::make_pair(pi.GetName(), pi));
}
}
示例11: OnUpdateCallstack
void NodeJSDebuggerPane::OnUpdateCallstack(clDebugEvent& event)
{
event.Skip();
wxWindowUpdateLocker locker(m_dataviewLocals);
ClearCallstack();
JSONRoot root(event.GetString());
JSONElement frames = root.toElement().namedObject("body").namedObject("frames");
JSONElement refs = root.toElement().namedObject("refs");
// Load the handlers into a map
m_handles.clear();
ParseRefsArray(refs);
int count = frames.arraySize();
for(int i = 0; i < count; ++i) {
JSONElement frame = frames.arrayItem(i);
int index = frame.namedObject("index").toInt();
int funcRef = frame.namedObject("func").namedObject("ref").toInt();
int fileRef = frame.namedObject("script").namedObject("ref").toInt();
int line = frame.namedObject("line").toInt() + 1;
wxVector<wxVariant> cols;
cols.push_back(wxString() << index);
wxString file, func;
if(m_handles.count(funcRef)) {
func = m_handles.find(funcRef)->second.value;
}
if(m_handles.count(funcRef)) {
file = m_handles.find(fileRef)->second.value;
}
cols.push_back(func);
cols.push_back(file);
cols.push_back(wxString() << line);
FrameData* cd = new FrameData();
cd->file = file;
cd->line = line;
cd->function = func;
cd->index = i;
m_dvListCtrlCallstack->AppendItem(cols, (wxUIntPtr)cd);
if(i == 0) {
// Notify the debugger to use frame #0 for the indicator
clDebugEvent event(wxEVT_NODEJS_DEBUGGER_MARK_LINE);
event.SetLineNumber(line);
event.SetFileName(file);
EventNotifier::Get()->AddPendingEvent(event);
BuildLocals(frame);
BuildArguments(frame);
}
}
}
示例12: FromJSON
void SFTPSettings::FromJSON(const JSONElement& json)
{
m_accounts.clear();
m_sshClient = json.namedObject("sshClient").toString(m_sshClient);
JSONElement arrAccounts = json.namedObject("accounts");
int size = arrAccounts.arraySize();
for(int i=0; i<size; ++i) {
SSHAccountInfo account;
account.FromJSON(arrAccounts.arrayItem(i));
m_accounts.push_back( account );
}
}
示例13: fn
clKeyboardBindingConfig& clKeyboardBindingConfig::Load()
{
wxFileName fn(clStandardPaths::Get().GetUserDataDir(), "keybindings.conf");
fn.AppendDir("config");
if(!fn.Exists()) return *this;
m_bindings.clear();
JSONRoot root(fn);
{
JSONElement menus = root.toElement().namedObject("menus");
int arrSize = menus.arraySize();
for(int i = 0; i < arrSize; ++i) {
JSONElement item = menus.arrayItem(i);
MenuItemData binding;
binding.action = item.namedObject("description").toString();
binding.accel = item.namedObject("accelerator").toString();
binding.parentMenu = item.namedObject("parentMenu").toString();
binding.resourceID = item.namedObject("resourceID").toString();
m_bindings.insert(std::make_pair(binding.resourceID, binding));
}
}
#if 0
{
JSONElement globals = root.toElement().namedObject("globals");
int arrSize = globals.arraySize();
for(int i = 0; i < arrSize; ++i) {
JSONElement item = globals.arrayItem(i);
MenuItemData binding;
binding.action = item.namedObject("description").toString();
binding.accel = item.namedObject("accelerator").toString();
binding.parentMenu = item.namedObject("parentMenu").toString();
binding.resourceID = item.namedObject("actionId").toString();
m_globalBindings.insert(std::make_pair(binding.resourceID, binding));
}
}
#endif
return *this;
}
示例14: FromJSON
void DbExplorerSettings::FromJSON(const JSONElement& json)
{
m_recentFiles = json.namedObject("m_recentFiles").toArrayString();
m_sqlHistory = json.namedObject("m_sqlHistory").toArrayString();
// read the connections
JSONElement arrConnections = json.namedObject("connections");
for(int i=0; i<arrConnections.arraySize(); ++i) {
DbConnectionInfo ci;
ci.FromJSON( arrConnections.arrayItem(i) );
m_connections.push_back( ci );
}
}
示例15: LoadJSON
void ColoursAndFontsManager::LoadJSON(const wxFileName& path)
{
if(!path.FileExists()) return;
JSONRoot root(path);
JSONElement arr = root.toElement();
int arrSize = arr.arraySize();
CL_DEBUG("Loading JSON file: %s (contains %d lexers)", path.GetFullPath(), arrSize);
for(int i = 0; i < arrSize; ++i) {
JSONElement json = arr.arrayItem(i);
DoAddLexer(json);
}
CL_DEBUG("Loading JSON file...done");
}