void Parser::parse_property( std::string const& tag ) { std::vector<Property> propertys; std::string::size_type pos = tag.find( ' ' ); if( pos == std::string::npos ) { on_start( tag, propertys ); return; } std::string tag_name = tag.substr( 0, pos ); std::string::size_type p1 = tag.find( '=', pos + 1 ); while( p1 != std::string::npos && pos != std::string::npos ) { std::string name = property_name( tag, pos, p1 ); std::string::size_type p2 = tag.find( '\x22', p1 );//find " if( p2 != std::string::npos ) { std::string::size_type p3 = tag.find( '\x22', p2 + 1 ); if( p3 != std::string::npos ) { std::string value( tag.substr( p2 + 1, p3 - p2 - 1 ) ); propertys.push_back( Property( name, value ) ); pos = tag.find( ' ', p3 ); } else pos = tag.find( ' ', p2 ); } else if( ( p2 = tag.find( '\x27', p1 ) ) != std::string::npos )//find ' { std::string::size_type p3 = tag.find( '\x27', p2 + 1 ); if( p3 != std::string::npos ) { std::string value( tag.substr( p2 + 1, p3 - p2 - 1 ) ); propertys.push_back( Property( name, value ) ); pos = tag.find( ' ', p3 ); } else pos = tag.find( ' ', p2 ); } else { pos = tag.find( ' ', p1 ); } p1 = tag.find( '=', pos + 1 ); } on_start( tag_name, propertys ); }
int TAO_Constraint_Evaluator:: visit_exist (TAO_Unary_Constraint* unary_exist) { TAO_Property_Constraint* operand = (TAO_Property_Constraint*) unary_exist->operand (); CORBA::String_var property_name ((const char*) operand->name ()); // Determine if a property is defined on this offer. CORBA::Boolean result = (CORBA::Boolean) (this->props_.find (property_name) == 0); this->queue_.enqueue_head (TAO_Literal_Constraint (result)); return 0; }
v8::Handle<v8::Value> GetPropertyDescriptionByClass(const v8::Arguments& args) { v8::HandleScope scope; if (args.Length() != 2) { ThrowException(v8::Exception::TypeError(v8::String::New("Wrong number of arguments"))); return scope.Close(v8::Undefined()); } if (!args[0]->IsString() || !args[1]->IsString()) { ThrowException(v8::Exception::TypeError(v8::String::New("Wrong arguments"))); return scope.Close(v8::Undefined()); } v8::String::AsciiValue class_name(args[0]->ToString()); v8::String::AsciiValue property_name(args[1]->ToString()); v8::Handle<v8::String> res = v8::String::New(switcher_container[0]->get_property_description_by_class(std::string(*class_name), std::string(*property_name)).c_str()); return scope.Close(res); }
v8::Handle<v8::Value> UnsubscribeToProperty(const v8::Arguments& args) { v8::HandleScope scope; if (args.Length() != 2) { ThrowException(v8::Exception::TypeError(v8::String::New("Wrong number of arguments"))); return scope.Close(v8::Undefined()); } if (!args[0]->IsString() || !args[1]->IsString()) { ThrowException(v8::Exception::TypeError(v8::String::New("Wrong arguments"))); return scope.Close(v8::Undefined()); } v8::String::AsciiValue element_name(args[0]->ToString()); v8::String::AsciiValue property_name(args[1]->ToString()); v8::Handle<v8::Boolean> res = v8::Boolean::New(switcher_container[0]->unsubscribe_property (std::string ("prop_sub"), std::string(*element_name), std::string(*property_name))); return scope.Close(res); }
QString Qtilities::Core::ObserverDotWriter::generateDotScript() const { if (!d->observer) return QString(); // Create the dot string: QString dotString; dotString.append(QString("digraph \"%1\" {\n").arg(d->observer->observerName())); // Add graph attributes: for (int i = 0; i < d->graph_attributes.count(); i++) { dotString.append(" "); dotString.append(d->graph_attributes.keys().at(i)); dotString.append(" = \""); dotString.append(d->graph_attributes.values().at(i)); dotString.append("\";\n"); } // Then do the relationships between items: ObserverRelationalTable table(d->observer); for (int i = 0; i < table.count(); i++) { RelationalTableEntry* entry = table.entryAt(i); // Label this entry: QString entry_label = QString(" %1 [label=\"%2\"").arg(entry->visitorID()).arg(entry->name()); // Add properties to it (node attributes): if (entry->object()) { QList<QByteArray> property_names = entry->object()->dynamicPropertyNames(); for (int p = 0; p < property_names.count(); p++) { QString property_name(property_names.at(p).data()); if (property_name.startsWith("qti.dot.node")) { // This is a dot node attribute property: QByteArray ba = property_name.remove(0,13).toAscii(); const char* char_name = ba.data(); // Get the shared property: SharedProperty shared_property = ObjectManager::getSharedProperty(entry->object(),property_names.at(p).data()); if (shared_property.isValid()) { entry_label.append(" " + QString(char_name) + "=" + shared_property.value().toString()); } } } } entry_label.append("];\n"); dotString.append(entry_label); // Now fill in the relationship data: for (int c = 0; c < entry->children().count(); c++) { QString relationship_string = QString(" %1").arg(entry->visitorID()); relationship_string.append(" -> "); RelationalTableEntry* child_entry = table.entryWithVisitorID(entry->children().at(c)); relationship_string.append(QString("%1").arg(child_entry->visitorID())); dotString.append(relationship_string); QMap<QString,QString> edge_attributes; // Get edge attributes for this relationship: QList<QByteArray> property_names = child_entry->object()->dynamicPropertyNames(); for (int p = 0; p < property_names.count(); p++) { QString property_name(property_names.at(p).data()); if (property_name.startsWith("qti.dot.edge")) { // This is a dot note attribute property: QByteArray ba = property_name.remove(0,13).toAscii(); const char* char_name = ba.data(); // Get the shared property: MultiContextProperty multi_context_property = ObjectManager::getMultiContextProperty(child_entry->object(),property_names.at(p).data()); if (multi_context_property.isValid()) { // Now check if this multi_context_property has a value for our context: if (multi_context_property.hasContext(entry->sessionID())) { edge_attributes[QString(char_name)] = multi_context_property.value(entry->sessionID()).toString(); } } } } // Now add all found attributes for this edge: for (int e = 0; e < edge_attributes.count(); e++) { if (e == 0) dotString.append(" ["); dotString.append(edge_attributes.keys().at(e) + "=" + edge_attributes.values().at(e)); if (edge_attributes.count() > 1 && e != edge_attributes.count()-1) dotString.append(","); if (e == edge_attributes.count()-1) dotString.append("]"); } // Finally add the new end line character and the new line: dotString.append(";\n"); } } // Append the closing } character: dotString.append("}"); LOG_INFO(dotString); return dotString; }
int ScriptWrapper::ConvertResultToJsonValue(BrowserManager *manager, Json::Value *value) { int status_code = SUCCESS; if (this->ResultIsString()) { std::string string_value; string_value = CW2A(this->result_.bstrVal, CP_UTF8); *value = string_value; } else if (this->ResultIsInteger()) { *value = this->result_.lVal; } else if (this->ResultIsDouble()) { *value = this->result_.dblVal; } else if (this->ResultIsBoolean()) { *value = this->result_.boolVal == VARIANT_TRUE; } else if (this->ResultIsEmpty()) { *value = Json::Value::null; } else if (this->ResultIsIDispatch()) { if (this->ResultIsArray() || this->ResultIsElementCollection()) { Json::Value result_array(Json::arrayValue); long length = 0; status_code = this->GetArrayLength(&length); for (long i = 0; i < length; ++i) { Json::Value array_item_result; int array_item_status = this->GetArrayItem(manager, i, &array_item_result); result_array[i] = array_item_result; } *value = result_array; } else if (this->ResultIsObject()) { Json::Value result_object; std::wstring property_name_list(L""); status_code = this->GetPropertyNameList(&property_name_list); std::vector<std::wstring> property_names; size_t end_position(0); size_t start_position(0); while (true) { std::wstring property_name(L""); end_position = property_name_list.find_first_of(L",", start_position); if(end_position == std::wstring::npos) { property_names.push_back(property_name_list.substr(start_position, property_name_list.size() - start_position)); break; } else { property_names.push_back(property_name_list.substr(start_position, end_position - start_position)); start_position = end_position + 1; } } for (size_t i = 0; i < property_names.size(); ++i) { Json::Value property_value_result; int property_value_status = this->GetPropertyValue(manager, property_names[i], &property_value_result); std::string name(CW2A(property_names[i].c_str(), CP_UTF8)); result_object[name] = property_value_result; } *value = result_object; } else { IHTMLElement *node = (IHTMLElement*) this->result_.pdispVal; std::tr1::shared_ptr<ElementWrapper> element_wrapper; manager->AddManagedElement(node, &element_wrapper); *value = element_wrapper->ConvertToJson(); } } else { status_code = EUNKNOWNSCRIPTRESULT; } return status_code; }