int ScriptValue::itemCount() const { throw ScriptErrorConversion(typeName(), _TYPE_("collection")); }
StatusWith<ServerGlobalParams::FeatureCompatibility::Version> FeatureCompatibilityVersion::parse( const BSONObj& featureCompatibilityVersionDoc) { bool foundVersionField = false; ServerGlobalParams::FeatureCompatibility::Version version; for (auto&& elem : featureCompatibilityVersionDoc) { auto fieldName = elem.fieldNameStringData(); if (fieldName == "_id") { continue; } else if (fieldName == FeatureCompatibilityVersion::kVersionField) { foundVersionField = true; if (elem.type() != BSONType::String) { return Status( ErrorCodes::TypeMismatch, str::stream() << FeatureCompatibilityVersion::kVersionField << " must be of type String, but was of type " << typeName(elem.type()) << ". Contents of " << FeatureCompatibilityVersion::kParameterName << " document in " << FeatureCompatibilityVersion::kCollection << ": " << featureCompatibilityVersionDoc << ". See http://dochub.mongodb.org/core/3.4-feature-compatibility."); } if (elem.String() == FeatureCompatibilityVersion::kVersion34) { version = ServerGlobalParams::FeatureCompatibility::Version::k34; } else if (elem.String() == FeatureCompatibilityVersion::kVersion32) { version = ServerGlobalParams::FeatureCompatibility::Version::k32; } else { return Status( ErrorCodes::BadValue, str::stream() << "Invalid value for " << FeatureCompatibilityVersion::kVersionField << ", found " << elem.String() << ", expected '" << FeatureCompatibilityVersion::kVersion34 << "' or '" << FeatureCompatibilityVersion::kVersion32 << "'. Contents of " << FeatureCompatibilityVersion::kParameterName << " document in " << FeatureCompatibilityVersion::kCollection << ": " << featureCompatibilityVersionDoc << ". See http://dochub.mongodb.org/core/3.4-feature-compatibility."); } } else { return Status( ErrorCodes::BadValue, str::stream() << "Unrecognized field '" << elem.fieldName() << "''. Contents of " << FeatureCompatibilityVersion::kParameterName << " document in " << FeatureCompatibilityVersion::kCollection << ": " << featureCompatibilityVersionDoc << ". See http://dochub.mongodb.org/core/3.4-feature-compatibility."); } } if (!foundVersionField) { return Status(ErrorCodes::BadValue, str::stream() << "Missing required field '" << FeatureCompatibilityVersion::kVersionField << "''. Contents of " << FeatureCompatibilityVersion::kParameterName << " document in " << FeatureCompatibilityVersion::kCollection << ": " << featureCompatibilityVersionDoc << ". See http://dochub.mongodb.org/core/3.4-feature-compatibility."); } return version; }
QString ToolChain::displayName() const { if (d->m_displayName.isEmpty()) return typeName(); return d->m_displayName; }
QString Piece::typeName() const { return typeName(m_type); }
Status ReplSetHeartbeatResponseV1::initialize(const BSONObj& doc) { Status status = bsonCheckOnlyHasFields("ReplSetHeartbeatResponse", doc, kLegalHeartbeatFieldNames); if (!status.isOK()) return status; status = bsonExtractBooleanField(doc, kIsReplSetFieldName, &_isReplSet); if (!status.isOK()) return status; status = bsonExtractStringField(doc, kReplSetFieldName, &_setName); if (!status.isOK()) return status; long long stateInt; status = bsonExtractIntegerField(doc, kMemberStateFieldName, &stateInt); if (!status.isOK()) return status; if (stateInt < 0 || stateInt > MemberState::RS_MAX) { return Status(ErrorCodes::BadValue, str::stream() << "Value for \"" << kMemberStateFieldName << "\" in response to replSetHeartbeat is " "out of range; legal values are non-negative and no more than " << MemberState::RS_MAX); } _state = MemberState(static_cast<int>(stateInt)); // extracting the lastCommittedOp is a bit of a process BSONObj lastOpTime = doc[kLastOpTimeFieldName].Obj(); Timestamp ts; status = bsonExtractTimestampField(lastOpTime, kOpTimeFieldName, &ts); if (!status.isOK()) return status; long long term; status = bsonExtractIntegerField(lastOpTime, kTermFieldName, &term); if (!status.isOK()) return status; _lastOpTime = OpTime(lastOpTime[kOpTimeFieldName].timestamp(), lastOpTime[kTermFieldName].Long()); status = bsonExtractStringField(doc, kSyncSourceFieldName, &_syncingTo); if (!status.isOK()) return status; status = bsonExtractIntegerField(doc, kConfigVersionFieldName, &_configVersion); if (!status.isOK()) return status; status = bsonExtractIntegerField(doc, kPrimaryIdFieldName, &_primaryId); if (!status.isOK()) return status; status = bsonExtractIntegerField(doc, kTermFieldName, &_term); if (!status.isOK()) return status; const BSONElement hasDataElement = doc[kHasDataFieldName]; _hasDataSet = !hasDataElement.eoo(); _hasData = hasDataElement.trueValue(); const BSONElement rsConfigElement = doc[kConfigFieldName]; if (rsConfigElement.eoo()) { _configSet = false; _config = ReplicaSetConfig(); return Status::OK(); } else if (rsConfigElement.type() != Object) { return Status(ErrorCodes::TypeMismatch, str::stream() << "Expected \"" << kConfigFieldName << "\" in response to replSetHeartbeat to have type " "Object, but found " << typeName(rsConfigElement.type())); } _configSet = true; return _config.initialize(rsConfigElement.Obj()); }
void Opcode8039::_run() { auto& debug = Logger::debug("SCRIPT"); debug << "[8039] [*] op_add(aValue, bValue)" << std::endl; auto bValue = _script->dataStack()->pop(); auto aValue = _script->dataStack()->pop(); debug << " types: " << aValue.typeName() << " + " << bValue.typeName() << std::endl; switch (bValue.type()) { case StackValue::Type::INTEGER: // INTEGER { int arg2 = bValue.integerValue(); switch (aValue.type()) { case StackValue::Type::INTEGER: // INTEGER + INTEGER { _script->dataStack()->push(aValue.integerValue() + arg2); break; } case StackValue::Type::FLOAT: // FLOAT + INTEGER { _script->dataStack()->push(aValue.floatValue() + (float)arg2); break; } case StackValue::Type::STRING: // STRING + INTEGER { std::string arg1 = aValue.stringValue(); _script->dataStack()->push(arg1 + bValue.toString()); break; } default: { _error(std::string("op_add - invalid left argument type: ") + aValue.typeName()); } } break; } case StackValue::Type::STRING: { auto arg2 = bValue.stringValue(); switch (aValue.type()) { case StackValue::Type::STRING: // STRING + STRING { _script->dataStack()->push(aValue.stringValue() + arg2); break; } case StackValue::Type::FLOAT: // FLOAT + STRING { _error("op_add - FLOAT+STRING not allowed"); } case StackValue::Type::INTEGER: // INTEGER + STRING { _error("op_add - INTEGER+STRING not allowed"); } default: { _error(std::string("op_add - invalid left argument type: ") + aValue.typeName()); } } break; } case StackValue::Type::FLOAT: // FLOAT { auto arg2 = bValue.floatValue(); switch (aValue.type()) { case StackValue::Type::INTEGER: // INTEGER + FLOAT { _script->dataStack()->push((float)aValue.integerValue() + arg2); break; } case StackValue::Type::FLOAT: // FLOAT + FLOAT { _script->dataStack()->push(aValue.floatValue() + arg2); break; } case StackValue::Type::STRING: // STRING + FLOAT { auto arg1 = aValue.stringValue(); _script->dataStack()->push(arg1 + bValue.toString()); break; } default: { _error(std::string("op_add - invalid left argument type: ") + aValue.typeName()); } } break; } default: { _error(std::string("op_add - invalid right argument type: ") + bValue.typeName()); } } }
void testServiceRegistry::externalServiceTest() { art::AssertHandler ah; { std::unique_ptr<DummyService> dummyPtr(new DummyService); dummyPtr->value_ = 2; art::ServiceToken token(art::ServiceRegistry::createContaining(dummyPtr)); { art::ServiceRegistry::Operate operate(token); art::ServiceHandle<DummyService> dummy; CPPUNIT_ASSERT(dummy); CPPUNIT_ASSERT(dummy.isAvailable()); CPPUNIT_ASSERT(dummy->value_ == 2); } { std::vector<fhicl::ParameterSet> pss; fhicl::ParameterSet ps; std::string typeName("DummyService"); ps.addParameter("service_type", typeName); int value = 2; ps.addParameter("value", value); pss.push_back(ps); art::ServiceToken token(art::ServiceRegistry::createSet(pss)); art::ServiceToken token2(art::ServiceRegistry::createContaining(dummyPtr, token, art::serviceregistry::kOverlapIsError)); art::ServiceRegistry::Operate operate(token2); art::ServiceHandle<testserviceregistry::DummyService> dummy; CPPUNIT_ASSERT(dummy); CPPUNIT_ASSERT(dummy.isAvailable()); CPPUNIT_ASSERT(dummy->value() == 2); } } { std::unique_ptr<DummyService> dummyPtr(new DummyService); std::shared_ptr<art::serviceregistry::ServiceWrapper<DummyService> > wrapper(new art::serviceregistry::ServiceWrapper<DummyService>(dummyPtr)); art::ServiceToken token(art::ServiceRegistry::createContaining(wrapper)); wrapper->get().value_ = 2; { art::ServiceRegistry::Operate operate(token); art::ServiceHandle<DummyService> dummy; CPPUNIT_ASSERT(dummy); CPPUNIT_ASSERT(dummy.isAvailable()); CPPUNIT_ASSERT(dummy->value_ == 2); } { std::vector<fhicl::ParameterSet> pss; fhicl::ParameterSet ps; std::string typeName("DummyService"); ps.addParameter("service_type", typeName); int value = 2; ps.addParameter("value", value); pss.push_back(ps); art::ServiceToken token(art::ServiceRegistry::createSet(pss)); art::ServiceToken token2(art::ServiceRegistry::createContaining(dummyPtr, token, art::serviceregistry::kOverlapIsError)); art::ServiceRegistry::Operate operate(token2); art::ServiceHandle<testserviceregistry::DummyService> dummy; CPPUNIT_ASSERT(dummy); CPPUNIT_ASSERT(dummy.isAvailable()); CPPUNIT_ASSERT(dummy->value() == 2); } } }
Status ReplicaSetConfig::_parseSettingsSubdocument(const BSONObj& settings) { // // Parse heartbeatIntervalMillis // long long heartbeatIntervalMillis; Status hbIntervalStatus = bsonExtractIntegerFieldWithDefault(settings, kHeartbeatIntervalFieldName, durationCount<Milliseconds>(kDefaultHeartbeatInterval), &heartbeatIntervalMillis); if (!hbIntervalStatus.isOK()) { return hbIntervalStatus; } _heartbeatInterval = Milliseconds(heartbeatIntervalMillis); // Parse electionTimeoutMillis // BSONElement electionTimeoutMillisElement = settings[kElectionTimeoutFieldName]; if (electionTimeoutMillisElement.eoo()) { _electionTimeoutPeriod = Milliseconds(kDefaultElectionTimeoutPeriod); } else if (electionTimeoutMillisElement.isNumber()) { _electionTimeoutPeriod = Milliseconds(electionTimeoutMillisElement.numberInt()); } else { return Status(ErrorCodes::TypeMismatch, str::stream() << "Expected type of " << kSettingsFieldName << "." << kElectionTimeoutFieldName << " to be a number, but found a value of type " << typeName(electionTimeoutMillisElement.type())); } // // Parse heartbeatTimeoutSecs // BSONElement hbTimeoutSecsElement = settings[kHeartbeatTimeoutFieldName]; if (hbTimeoutSecsElement.eoo()) { _heartbeatTimeoutPeriod = Seconds(kDefaultHeartbeatTimeoutPeriod); } else if (hbTimeoutSecsElement.isNumber()) { _heartbeatTimeoutPeriod = Seconds(hbTimeoutSecsElement.numberInt()); } else { return Status(ErrorCodes::TypeMismatch, str::stream() << "Expected type of " << kSettingsFieldName << "." << kHeartbeatTimeoutFieldName << " to be a number, but found a value of type " << typeName(hbTimeoutSecsElement.type())); } // // Parse chainingAllowed // Status status = bsonExtractBooleanFieldWithDefault( settings, kChainingAllowedFieldName, true, &_chainingAllowed); if (!status.isOK()) return status; // // Parse getLastErrorDefaults // BSONElement gleDefaultsElement; status = bsonExtractTypedField( settings, kGetLastErrorDefaultsFieldName, Object, &gleDefaultsElement); if (status.isOK()) { status = _defaultWriteConcern.parse(gleDefaultsElement.Obj()); if (!status.isOK()) return status; } else if (status == ErrorCodes::NoSuchKey) { // Default write concern is w: 1. _defaultWriteConcern.reset(); _defaultWriteConcern.wNumNodes = 1; } else { return status; } // // Parse getLastErrorModes // BSONElement gleModesElement; status = bsonExtractTypedField(settings, kGetLastErrorModesFieldName, Object, &gleModesElement); BSONObj gleModes; if (status.isOK()) { gleModes = gleModesElement.Obj(); } else if (status != ErrorCodes::NoSuchKey) { return status; } for (BSONObj::iterator gleModeIter(gleModes); gleModeIter.more();) { const BSONElement modeElement = gleModeIter.next(); if (_customWriteConcernModes.find(modeElement.fieldNameStringData()) != _customWriteConcernModes.end()) { return Status(ErrorCodes::DuplicateKey, str::stream() << kSettingsFieldName << '.' << kGetLastErrorModesFieldName << " contains multiple fields named " << modeElement.fieldName()); } if (modeElement.type() != Object) { return Status(ErrorCodes::TypeMismatch, str::stream() << "Expected " << kSettingsFieldName << '.' << kGetLastErrorModesFieldName << '.' << modeElement.fieldName() << " to be an Object, not " << typeName(modeElement.type())); } ReplicaSetTagPattern pattern = _tagConfig.makePattern(); for (BSONObj::iterator constraintIter(modeElement.Obj()); constraintIter.more();) { const BSONElement constraintElement = constraintIter.next(); if (!constraintElement.isNumber()) { return Status(ErrorCodes::TypeMismatch, str::stream() << "Expected " << kSettingsFieldName << '.' << kGetLastErrorModesFieldName << '.' << modeElement.fieldName() << '.' << constraintElement.fieldName() << " to be a number, not " << typeName(constraintElement.type())); } const int minCount = constraintElement.numberInt(); if (minCount <= 0) { return Status(ErrorCodes::BadValue, str::stream() << "Value of " << kSettingsFieldName << '.' << kGetLastErrorModesFieldName << '.' << modeElement.fieldName() << '.' << constraintElement.fieldName() << " must be positive, but found " << minCount); } status = _tagConfig.addTagCountConstraintToPattern( &pattern, constraintElement.fieldNameStringData(), minCount); if (!status.isOK()) { return status; } } _customWriteConcernModes[modeElement.fieldNameStringData()] = pattern; } return Status::OK(); }
Status ReplicaSetConfig::initialize(const BSONObj& cfg) { _isInitialized = false; _members.clear(); Status status = bsonCheckOnlyHasFields("replica set configuration", cfg, kLegalConfigTopFieldNames); if (!status.isOK()) return status; // // Parse replSetName // status = bsonExtractStringField(cfg, kIdFieldName, &_replSetName); if (!status.isOK()) return status; // // Parse version // status = bsonExtractIntegerField(cfg, kVersionFieldName, &_version); if (!status.isOK()) return status; // // Parse members // BSONElement membersElement; status = bsonExtractTypedField(cfg, kMembersFieldName, Array, &membersElement); if (!status.isOK()) return status; for (BSONObj::iterator membersIterator(membersElement.Obj()); membersIterator.more();) { BSONElement memberElement = membersIterator.next(); if (memberElement.type() != Object) { return Status(ErrorCodes::TypeMismatch, str::stream() << "Expected type of " << kMembersFieldName << "." << memberElement.fieldName() << " to be Object, but found " << typeName(memberElement.type())); } _members.resize(_members.size() + 1); const auto& memberBSON = memberElement.Obj(); status = _members.back().initialize(memberBSON, &_tagConfig); if (!status.isOK()) return Status(ErrorCodes::InvalidReplicaSetConfig, str::stream() << status.toString() << " for member:" << memberBSON); } // // Parse configServer // status = bsonExtractBooleanFieldWithDefault(cfg, kConfigServerFieldName, false, &_configServer); if (!status.isOK()) { return status; } // // Parse protocol version // status = bsonExtractIntegerField(cfg, kProtocolVersionFieldName, &_protocolVersion); if (!status.isOK() && status != ErrorCodes::NoSuchKey) { return status; } // // Parse settings // BSONElement settingsElement; status = bsonExtractTypedField(cfg, kSettingsFieldName, Object, &settingsElement); BSONObj settings; if (status.isOK()) { settings = settingsElement.Obj(); } else if (status != ErrorCodes::NoSuchKey) { return status; } status = _parseSettingsSubdocument(settings); if (!status.isOK()) return status; _calculateMajorities(); _addInternalWriteConcernModes(); _isInitialized = true; return Status::OK(); }
Status ModifierInc::prepare(mutablebson::Element root, const StringData& matchedField, ExecInfo* execInfo) { _preparedState.reset(new PreparedState(root.getDocument())); // If we have a $-positional field, it is time to bind it to an actual field part. if (_posDollar) { if (matchedField.empty()) { return Status(ErrorCodes::BadValue, str::stream() << "The positional operator did not find the match " "needed from the query. Unexpanded update: " << _fieldRef.dottedField()); } _fieldRef.setPart(_posDollar, matchedField); } // Locate the field name in 'root'. Note that we may not have all the parts in the path // in the doc -- which is fine. Our goal now is merely to reason about whether this mod // apply is a noOp or whether is can be in place. The remaining path, if missing, will // be created during the apply. Status status = pathsupport::findLongestPrefix(_fieldRef, root, &_preparedState->idxFound, &_preparedState->elemFound); // FindLongestPrefix may say the path does not exist at all, which is fine here, or // that the path was not viable or otherwise wrong, in which case, the mod cannot // proceed. if (status.code() == ErrorCodes::NonExistentPath) { _preparedState->elemFound = root.getDocument().end(); } else if (!status.isOK()) { return status; } // We register interest in the field name. The driver needs this info to sort out if // there is any conflict among mods. execInfo->fieldRef[0] = &_fieldRef; // Capture the value we are going to write. At this point, there may not be a value // against which to operate, so the result will be simply _val. _preparedState->newValue = _val; // // in-place and no-op logic // // If the field path is not fully present, then this mod cannot be in place, nor is a // noOp. if (!_preparedState->elemFound.ok() || _preparedState->idxFound < (_fieldRef.numParts() - 1)) { // For multiplication, we treat ops against missing as yielding zero. We take // advantage here of the promotion rules for SafeNum; the expression below will // always yield a zero of the same type of operand that the user provided // (e.g. double). if (_mode == MODE_MUL) _preparedState->newValue *= SafeNum(static_cast<int>(0)); return Status::OK(); } // If the value being $inc'ed is the same as the one already in the doc, than this is a // noOp. if (!_preparedState->elemFound.isNumeric()) { mb::Element idElem = mb::findFirstChildNamed(root, "_id"); return Status( ErrorCodes::BadValue, str::stream() << "Cannot apply $inc to a value of non-numeric type. {" << idElem.toString() << "} has the field '" << _preparedState->elemFound.getFieldName() << "' of non-numeric type " << typeName(_preparedState->elemFound.getType())); } const SafeNum currentValue = _preparedState->elemFound.getValueSafeNum(); // Update newValue w.r.t to the current value of the found element. if (_mode == MODE_INC) _preparedState->newValue += currentValue; else _preparedState->newValue *= currentValue; // If the result of the addition is invalid, we must return an error. if (!_preparedState->newValue.isValid()) { mb::Element idElem = mb::findFirstChildNamed(root, "_id"); return Status(ErrorCodes::BadValue, str::stream() << "Failed to apply $inc operations to current value (" << currentValue.debugString() << ") for document {" << idElem.toString() << "}"); } // If the values are identical (same type, same value), then this is a no-op. if (_preparedState->newValue.isIdentical(currentValue)) { _preparedState->noOp = execInfo->noOp = true; return Status::OK(); } return Status::OK(); }
// read a file with queries // parse the queries // and output to file as well as stdout void analyze(Indexed* indexed, std::string queryFilename, std::string outputFilename){ std::string line; std::ifstream queryfile(queryFilename.c_str()); std::ofstream outputfile(outputFilename.c_str()); if (!outputfile.is_open()){ std::cout << "could not open output file\n"; return; }; const Rows* rows = indexed->rows; if (queryfile.is_open()){ // read all the lines while ( getline (queryfile, line) ) { Tokens t = tokenize(line); bool valid = true; if (t.size() < 3){ valid = false; }; int colNum1 = 0; int colType1 = 0; int colNum2 = 0; if (valid){ ColsByName::const_iterator colIt = rows->header.find(t[1]); if (colIt == rows->header.end()){ std::cout << "column: " << t[1] << " not found!\n"; valid = false; }else{ colNum2 = colIt->second.pos; if (!typeCanAggregate(colIt->second.type)){ std::cout << "can not perform: " << t[0] << " over " << t[1] << " of type " << typeName(colIt->second.type) << "\n"; valid = false; }; }; colIt = rows->header.find(t[2]); if (colIt == rows->header.end()){ std::cout << "column: " << t[2] << " not found!\n"; valid = false; }else{ colNum1 = colIt->second.pos; colType1 = colIt->second.type; }; }; if (valid){ // output to file and std out std::cout << t[0] << " " << t[1] << " GROUPED BY " << t[2] << "\n"; outputfile << t[0] << " " << t[1] << " GROUPED BY " << t[2] << "\n"; if (t[0] == "AVG"){ doAvg(indexed, colNum1, colNum2, colType1, outputfile); }else if (t[0] == "MIN"){ doMin(indexed, colNum1, colNum2, colType1, outputfile); }else if (t[0] == "MAX"){ doMax(indexed, colNum1, colNum2, colType1, outputfile); }else{ std::cout << "unknown aggregate function: " << t[0] << "\n"; }; // new line std::cout << "\n"; outputfile << "\n"; }; }; }; outputfile.close(); };
QByteArray DwarfDie::typeName() const { const auto n = name(); if (!n.isEmpty()) return n; const auto typeDie = attribute(DW_AT_type).value<DwarfDie*>(); QByteArray typeName; if (!typeDie) { switch (tag()) { case DW_TAG_class_type: return "<anon class>"; case DW_TAG_enumeration_type: return "<anon enum>"; case DW_TAG_structure_type: return "<anon struct>"; case DW_TAG_union_type: return "<anon union>"; case DW_TAG_namespace: return "(anonymous namespace)"; case DW_TAG_array_type: case DW_TAG_base_type: case DW_TAG_const_type: case DW_TAG_pointer_type: case DW_TAG_ptr_to_member_type: case DW_TAG_reference_type: case DW_TAG_restrict_type: case DW_TAG_rvalue_reference_type: case DW_TAG_subroutine_type: case DW_TAG_typedef: typeName = "void"; break; default: return {}; } } else { typeName = typeDie->typeName(); } // TODO: function pointers and pointer to members switch (tag()) { case DW_TAG_pointer_type: return typeName + '*'; case DW_TAG_reference_type: return typeName + '&'; case DW_TAG_rvalue_reference_type: return typeName + "&&"; case DW_TAG_const_type: return typeName + " const"; case DW_TAG_array_type: { const auto dims = arrayDimensions(this); QByteArray n = typeName; for (int d : dims) n += '[' + QByteArray::number(d) + ']'; return n; } case DW_TAG_restrict_type: return typeName + " restrcit"; case DW_TAG_volatile_type: return typeName + " volatile"; case DW_TAG_subroutine_type: return typeName + " (*)(" + argumentList(this).join(", ") + ')'; case DW_TAG_ptr_to_member_type: { const auto classDie = attribute(DW_AT_containing_type).value<DwarfDie*>(); QByteArray className; if (classDie) className = classDie->typeName(); return typeName + " (" + className + "::*)(" + argumentList(this).join(", ") + ')'; } } return typeName; }
void DataFile::upgrade() { projectVersion version = documentElement().attribute( "creatorversion" ). replace( "svn", "" ); if( version < "0.2.1-20070501" ) { QDomNodeList list = elementsByTagName( "arpandchords" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); if( el.hasAttribute( "arpdir" ) ) { int arpdir = el.attribute( "arpdir" ).toInt(); if( arpdir > 0 ) { el.setAttribute( "arpdir", arpdir - 1 ); } else { el.setAttribute( "arpdisabled", "1" ); } } } list = elementsByTagName( "sampletrack" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); if( el.attribute( "vol" ) != "" ) { el.setAttribute( "vol", el.attribute( "vol" ).toFloat() * 100.0f ); } else { QDomNode node = el.namedItem( "automation-pattern" ); if( !node.isElement() || !node.namedItem( "vol" ).isElement() ) { el.setAttribute( "vol", 100.0f ); } } } list = elementsByTagName( "ladspacontrols" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); QDomNode anode = el.namedItem( "automation-pattern" ); QDomNode node = anode.firstChild(); while( !node.isNull() ) { if( node.isElement() ) { QString name = node.nodeName(); if( name.endsWith( "link" ) ) { el.setAttribute( name, node.namedItem( "time" ) .toElement() .attribute( "value" ) ); QDomNode oldNode = node; node = node.nextSibling(); anode.removeChild( oldNode ); continue; } } node = node.nextSibling(); } } QDomNode node = m_head.firstChild(); while( !node.isNull() ) { if( node.isElement() ) { if( node.nodeName() == "bpm" ) { int value = node.toElement().attribute( "value" ).toInt(); if( value > 0 ) { m_head.setAttribute( "bpm", value ); QDomNode oldNode = node; node = node.nextSibling(); m_head.removeChild( oldNode ); continue; } } else if( node.nodeName() == "mastervol" ) { int value = node.toElement().attribute( "value" ).toInt(); if( value > 0 ) { m_head.setAttribute( "mastervol", value ); QDomNode oldNode = node; node = node.nextSibling(); m_head.removeChild( oldNode ); continue; } } else if( node.nodeName() == "masterpitch" ) { m_head.setAttribute( "masterpitch", -node.toElement().attribute( "value" ).toInt() ); QDomNode oldNode = node; node = node.nextSibling(); m_head.removeChild( oldNode ); continue; } } node = node.nextSibling(); } } if( version < "0.2.1-20070508" ) { QDomNodeList list = elementsByTagName( "arpandchords" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); if( el.hasAttribute( "chorddisabled" ) ) { el.setAttribute( "chord-enabled", !el.attribute( "chorddisabled" ) .toInt() ); el.setAttribute( "arp-enabled", !el.attribute( "arpdisabled" ) .toInt() ); } else if( !el.hasAttribute( "chord-enabled" ) ) { el.setAttribute( "chord-enabled", true ); el.setAttribute( "arp-enabled", el.attribute( "arpdir" ).toInt() != 0 ); } } while( !( list = elementsByTagName( "channeltrack" ) ).isEmpty() ) { QDomElement el = list.item( 0 ).toElement(); el.setTagName( "instrumenttrack" ); } list = elementsByTagName( "instrumenttrack" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); if( el.hasAttribute( "vol" ) ) { float value = el.attribute( "vol" ).toFloat(); value = roundf( value * 0.585786438f ); el.setAttribute( "vol", value ); } else { QDomNodeList vol_list = el.namedItem( "automation-pattern" ) .namedItem( "vol" ).toElement() .elementsByTagName( "time" ); for( int j = 0; !vol_list.item( j ).isNull(); ++j ) { QDomElement timeEl = list.item( j ) .toElement(); int value = timeEl.attribute( "value" ) .toInt(); value = (int)roundf( value * 0.585786438f ); timeEl.setAttribute( "value", value ); } } } } if( version < "0.3.0-rc2" ) { QDomNodeList list = elementsByTagName( "arpandchords" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); if( el.attribute( "arpdir" ).toInt() > 0 ) { el.setAttribute( "arpdir", el.attribute( "arpdir" ).toInt() - 1 ); } } } if( version < "0.3.0" ) { QDomNodeList list; while( !( list = elementsByTagName( "pluckedstringsynth" ) ).isEmpty() ) { QDomElement el = list.item( 0 ).toElement(); el.setTagName( "vibedstrings" ); el.setAttribute( "active0", 1 ); } while( !( list = elementsByTagName( "lb303" ) ).isEmpty() ) { QDomElement el = list.item( 0 ).toElement(); el.setTagName( "lb302" ); } while( !( list = elementsByTagName( "channelsettings" ) ). isEmpty() ) { QDomElement el = list.item( 0 ).toElement(); el.setTagName( "instrumenttracksettings" ); } } if( version < "0.4.0-20080104" ) { QDomNodeList list = elementsByTagName( "fx" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); if( el.hasAttribute( "fxdisabled" ) && el.attribute( "fxdisabled" ).toInt() == 0 ) { el.setAttribute( "enabled", 1 ); } } } if( version < "0.4.0-20080118" ) { QDomNodeList list; while( !( list = elementsByTagName( "fx" ) ).isEmpty() ) { QDomElement fxchain = list.item( 0 ).toElement(); fxchain.setTagName( "fxchain" ); QDomNode rack = list.item( 0 ).firstChild(); QDomNodeList effects = rack.childNodes(); // move items one level up while( effects.count() ) { fxchain.appendChild( effects.at( 0 ) ); } fxchain.setAttribute( "numofeffects", rack.toElement().attribute( "numofeffects" ) ); fxchain.removeChild( rack ); } } if( version < "0.4.0-20080129" ) { QDomNodeList list; while( !( list = elementsByTagName( "arpandchords" ) ).isEmpty() ) { QDomElement aac = list.item( 0 ).toElement(); aac.setTagName( "arpeggiator" ); QDomNode cloned = aac.cloneNode(); cloned.toElement().setTagName( "chordcreator" ); aac.parentNode().appendChild( cloned ); } } if( version < "0.4.0-20080409" ) { QStringList s; s << "note" << "pattern" << "bbtco" << "sampletco" << "time"; for( QStringList::iterator it = s.begin(); it < s.end(); ++it ) { QDomNodeList list = elementsByTagName( *it ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); el.setAttribute( "pos", el.attribute( "pos" ).toInt()*3 ); el.setAttribute( "len", el.attribute( "len" ).toInt()*3 ); } } QDomNodeList list = elementsByTagName( "timeline" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); el.setAttribute( "lp0pos", el.attribute( "lp0pos" ).toInt()*3 ); el.setAttribute( "lp1pos", el.attribute( "lp1pos" ).toInt()*3 ); } } if( version < "0.4.0-20080607" ) { QDomNodeList list; while( !( list = elementsByTagName( "midi" ) ).isEmpty() ) { QDomElement el = list.item( 0 ).toElement(); el.setTagName( "midiport" ); } } if( version < "0.4.0-20080622" ) { QDomNodeList list; while( !( list = elementsByTagName( "automation-pattern" ) ).isEmpty() ) { QDomElement el = list.item( 0 ).toElement(); el.setTagName( "automationpattern" ); } list = elementsByTagName( "bbtrack" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); QString s = el.attribute( "name" ); s.replace( QRegExp( "^Beat/Baseline " ), "Beat/Bassline " ); el.setAttribute( "name", s ); } } if( version < "0.4.0-beta1" ) { // convert binary effect-key-blobs to XML QDomNodeList list; list = elementsByTagName( "effect" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); QString k = el.attribute( "key" ); if( !k.isEmpty() ) { const QList<QVariant> l = base64::decode( k, QVariant::List ).toList(); if( !l.isEmpty() ) { QString name = l[0].toString(); QVariant u = l[1]; EffectKey::AttributeMap m; // VST-effect? if( u.type() == QVariant::String ) { m["file"] = u.toString(); } // LADSPA-effect? else if( u.type() == QVariant::StringList ) { const QStringList sl = u.toStringList(); m["plugin"] = sl.value( 0 ); m["file"] = sl.value( 1 ); } EffectKey key( NULL, name, m ); el.appendChild( key.saveXML( *this ) ); } } } } if( version < "0.4.0-rc2" ) { QDomNodeList list = elementsByTagName( "audiofileprocessor" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); QString s = el.attribute( "src" ); s.replace( "drumsynth/misc ", "drumsynth/misc_" ); s.replace( "drumsynth/r&b", "drumsynth/r_n_b" ); s.replace( "drumsynth/r_b", "drumsynth/r_n_b" ); el.setAttribute( "src", s ); } list = elementsByTagName( "lb302" ); for( int i = 0; !list.item( i ).isNull(); ++i ) { QDomElement el = list.item( i ).toElement(); int s = el.attribute( "shape" ).toInt(); if( s >= 1 ) { s--; } el.setAttribute( "shape", QString("%1").arg(s) ); } } // update document meta data documentElement().setAttribute( "version", LDF_VERSION_STRING ); documentElement().setAttribute( "type", typeName( type() ) ); documentElement().setAttribute( "creator", "LMMS" ); documentElement().setAttribute( "creatorversion", LMMS_VERSION ); if( type() == SongProject || type() == SongProjectTemplate ) { // Time-signature if ( !m_head.hasAttribute( "timesig_numerator" ) ) { m_head.setAttribute( "timesig_numerator", 4 ); m_head.setAttribute( "timesig_denominator", 4 ); } if( !m_head.hasAttribute( "mastervol" ) ) { m_head.setAttribute( "mastervol", 100 ); } } //printf("%s\n", toString( 2 ).toUtf8().constData()); }
ScriptValueP ScriptValue::getIndex(int index) const { return delay_error(ScriptErrorNoMember(typeName(), String()<<index)); }
void IRPrinter::visitConvert(Convert *e) { *out << "convert " << typeName(e->expr->type) << " to " << typeName(e->type) << ' '; visit(e->expr); }
StatusWith<ShardType> ShardType::fromBSON(const BSONObj& source) { ShardType shard; { std::string shardName; Status status = bsonExtractStringField(source, name.name(), &shardName); if (!status.isOK()) return status; shard._name = shardName; } { std::string shardHost; Status status = bsonExtractStringField(source, host.name(), &shardHost); if (!status.isOK()) return status; shard._host = shardHost; } { bool isShardDraining; Status status = bsonExtractBooleanField(source, draining.name(), &isShardDraining); if (status.isOK()) { shard._draining = isShardDraining; } else if (status == ErrorCodes::NoSuchKey) { // draining field can be mssing in which case it is presumed false } else { return status; } } { long long shardMaxSizeMB; // maxSizeMB == 0 means there's no limitation to space usage. Status status = bsonExtractIntegerField(source, maxSizeMB.name(), &shardMaxSizeMB); if (status.isOK()) { shard._maxSizeMB = shardMaxSizeMB; } else if (status == ErrorCodes::NoSuchKey) { // maxSizeMB field can be missing in which case it is presumed false } else { return status; } } if (source.hasField(tags.name())) { shard._tags = std::vector<std::string>(); BSONElement tagsElement; Status status = bsonExtractTypedField(source, tags.name(), Array, &tagsElement); if (!status.isOK()) return status; BSONObjIterator it(tagsElement.Obj()); while (it.more()) { BSONElement tagElement = it.next(); if (tagElement.type() != String) { return Status(ErrorCodes::TypeMismatch, str::stream() << "Elements in \"" << tags.name() << "\" array must be strings but found " << typeName(tagElement.type())); } shard._tags->push_back(tagElement.String()); } } { long long shardState; Status status = bsonExtractIntegerField(source, state.name(), &shardState); if (status.isOK()) { // Make sure the state field falls within the valid range of ShardState values. if (!(shardState >= static_cast<std::underlying_type<ShardState>::type>( ShardState::kNotShardAware) && shardState <= static_cast<std::underlying_type<ShardState>::type>( ShardState::kShardAware))) { return Status(ErrorCodes::BadValue, str::stream() << "Invalid shard state value: " << shardState); } else { shard._state = static_cast<ShardState>(shardState); } } else if (status == ErrorCodes::NoSuchKey) { // state field can be mssing in which case it is presumed kNotShardAware } else { return status; } } return shard; }
StatusWith<ParsedDistinct> ParsedDistinct::parse(OperationContext* opCtx, const NamespaceString& nss, const BSONObj& cmdObj, const ExtensionsCallback& extensionsCallback, bool isExplain, const CollatorInterface* defaultCollator) { IDLParserErrorContext ctx("distinct"); DistinctCommand parsedDistinct(nss); try { parsedDistinct = DistinctCommand::parse(ctx, cmdObj); } catch (...) { return exceptionToStatus(); } auto qr = stdx::make_unique<QueryRequest>(nss); if (parsedDistinct.getKey().find('\0') != std::string::npos) { return Status(ErrorCodes::Error(31032), "Key field cannot contain an embedded null byte"); } // Create a projection on the fields needed by the distinct command, so that the query planner // will produce a covered plan if possible. qr->setProj(getDistinctProjection(std::string(parsedDistinct.getKey()))); if (auto query = parsedDistinct.getQuery()) { qr->setFilter(query.get()); } if (auto collation = parsedDistinct.getCollation()) { qr->setCollation(collation.get()); } if (auto comment = parsedDistinct.getComment()) { qr->setComment(comment.get().toString()); } // The IDL parser above does not handle generic command arguments. Since the underlying query // request requires the following options, manually parse and verify them here. if (auto readConcernElt = cmdObj[repl::ReadConcernArgs::kReadConcernFieldName]) { if (readConcernElt.type() != BSONType::Object) { return Status(ErrorCodes::TypeMismatch, str::stream() << "\"" << repl::ReadConcernArgs::kReadConcernFieldName << "\" had the wrong type. Expected " << typeName(BSONType::Object) << ", found " << typeName(readConcernElt.type())); } qr->setReadConcern(readConcernElt.embeddedObject()); } if (auto queryOptionsElt = cmdObj[QueryRequest::kUnwrappedReadPrefField]) { if (queryOptionsElt.type() != BSONType::Object) { return Status(ErrorCodes::TypeMismatch, str::stream() << "\"" << QueryRequest::kUnwrappedReadPrefField << "\" had the wrong type. Expected " << typeName(BSONType::Object) << ", found " << typeName(queryOptionsElt.type())); } qr->setUnwrappedReadPref(queryOptionsElt.embeddedObject()); } if (auto maxTimeMSElt = cmdObj[QueryRequest::cmdOptionMaxTimeMS]) { auto maxTimeMS = QueryRequest::parseMaxTimeMS(maxTimeMSElt); if (!maxTimeMS.isOK()) { return maxTimeMS.getStatus(); } qr->setMaxTimeMS(static_cast<unsigned int>(maxTimeMS.getValue())); } qr->setExplain(isExplain); const boost::intrusive_ptr<ExpressionContext> expCtx; auto cq = CanonicalQuery::canonicalize(opCtx, std::move(qr), expCtx, extensionsCallback, MatchExpressionParser::kAllowAllSpecialFeatures); if (!cq.isOK()) { return cq.getStatus(); } if (cq.getValue()->getQueryRequest().getCollation().isEmpty() && defaultCollator) { cq.getValue()->setCollator(defaultCollator->clone()); } return ParsedDistinct(std::move(cq.getValue()), parsedDistinct.getKey().toString()); }
bool EnumTypeResolver::tryQualifiedEnumAssignment(const QmlIR::Object *obj, const QQmlPropertyCache *propertyCache, const QQmlPropertyData *prop, QmlIR::Binding *binding) { bool isIntProp = (prop->propType == QMetaType::Int) && !prop->isEnum(); if (!prop->isEnum() && !isIntProp) return true; if (!prop->isWritable() && !(binding->flags & QV4::CompiledData::Binding::InitializerForReadOnlyDeclaration)) { compiler->recordError(binding->location, tr("Invalid property assignment: \"%1\" is a read-only property").arg(compiler->stringAt(binding->propertyNameIndex))); return false; } Q_ASSERT(binding->type = QV4::CompiledData::Binding::Type_Script); const QString string = compiler->bindingAsString(obj, binding->value.compiledScriptIndex); if (!string.constData()->isUpper()) return true; int dot = string.indexOf(QLatin1Char('.')); if (dot == -1 || dot == string.length()-1) return true; if (string.indexOf(QLatin1Char('.'), dot+1) != -1) return true; QHashedStringRef typeName(string.constData(), dot); QString enumValue = string.mid(dot+1); if (isIntProp) { // Allow enum assignment to ints. bool ok; int enumval = evaluateEnum(typeName.toString(), enumValue.toUtf8(), &ok); if (ok) { binding->type = QV4::CompiledData::Binding::Type_Number; binding->value.d = (double)enumval; binding->flags |= QV4::CompiledData::Binding::IsResolvedEnum; } return true; } QQmlType *type = 0; imports->resolveType(typeName, &type, 0, 0, 0); if (!type && typeName != QLatin1String("Qt")) return true; if (type && type->isComposite()) //No enums on composite (or composite singleton) types return true; int value = 0; bool ok = false; QQmlCompiledData::TypeReference *tr = resolvedTypes->value(obj->inheritedTypeNameIndex); if (type && tr && tr->type == type) { QMetaProperty mprop = propertyCache->firstCppMetaObject()->property(prop->coreIndex); // When these two match, we can short cut the search if (mprop.isFlagType()) { value = mprop.enumerator().keysToValue(enumValue.toUtf8().constData(), &ok); } else { value = mprop.enumerator().keyToValue(enumValue.toUtf8().constData(), &ok); } } else { // Otherwise we have to search the whole type if (type) { value = type->enumValue(QHashedStringRef(enumValue), &ok); } else { QByteArray enumName = enumValue.toUtf8(); const QMetaObject *metaObject = StaticQtMetaObject::get(); for (int ii = metaObject->enumeratorCount() - 1; !ok && ii >= 0; --ii) { QMetaEnum e = metaObject->enumerator(ii); value = e.keyToValue(enumName.constData(), &ok); } } } if (!ok) return true; binding->type = QV4::CompiledData::Binding::Type_Number; binding->value.d = (double)value; binding->flags |= QV4::CompiledData::Binding::IsResolvedEnum; return true; }
QgsMemoryProvider::QgsMemoryProvider( const QString &uri, const ProviderOptions &options ) : QgsVectorDataProvider( uri, options ) { // Initialize the geometry with the uri to support old style uri's // (ie, just 'point', 'line', 'polygon') QUrl url = QUrl::fromEncoded( uri.toUtf8() ); QString geometry; if ( url.hasQueryItem( QStringLiteral( "geometry" ) ) ) { geometry = url.queryItemValue( QStringLiteral( "geometry" ) ); } else { geometry = url.path(); } if ( geometry.toLower() == QLatin1String( "none" ) ) { mWkbType = QgsWkbTypes::NoGeometry; } else { mWkbType = QgsWkbTypes::parseType( geometry ); } if ( url.hasQueryItem( QStringLiteral( "crs" ) ) ) { QString crsDef = url.queryItemValue( QStringLiteral( "crs" ) ); mCrs.createFromString( crsDef ); } mNextFeatureId = 1; setNativeTypes( QList< NativeType >() << QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), QStringLiteral( "integer" ), QVariant::Int, 0, 10 ) // Decimal number from OGR/Shapefile/dbf may come with length up to 32 and // precision up to length-2 = 30 (default, if width is not specified in dbf is length = 24 precision = 15) // We know that double (QVariant::Double) has only 15-16 significant numbers, // but setting that correct limits would disable the use of memory provider with // data from Shapefiles. In any case, the data are handled as doubles. // So the limits set here are not correct but enable use of data from Shapefiles. << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), QStringLiteral( "double" ), QVariant::Double, 0, 32, 0, 30 ) << QgsVectorDataProvider::NativeType( tr( "Text (string)" ), QStringLiteral( "string" ), QVariant::String, 0, 255 ) // date type << QgsVectorDataProvider::NativeType( tr( "Date" ), QStringLiteral( "date" ), QVariant::Date, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Time" ), QStringLiteral( "time" ), QVariant::Time, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Date & Time" ), QStringLiteral( "datetime" ), QVariant::DateTime, -1, -1, -1, -1 ) // integer types << QgsVectorDataProvider::NativeType( tr( "Whole number (smallint - 16bit)" ), QStringLiteral( "int2" ), QVariant::Int, -1, -1, 0, 0 ) << QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 32bit)" ), QStringLiteral( "int4" ), QVariant::Int, -1, -1, 0, 0 ) << QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 64bit)" ), QStringLiteral( "int8" ), QVariant::LongLong, -1, -1, 0, 0 ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), QStringLiteral( "numeric" ), QVariant::Double, 1, 20, 0, 20 ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), QStringLiteral( "decimal" ), QVariant::Double, 1, 20, 0, 20 ) // floating point << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), QStringLiteral( "real" ), QVariant::Double, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), QStringLiteral( "double precision" ), QVariant::Double, -1, -1, -1, -1 ) // string types << QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), QStringLiteral( "text" ), QVariant::String, -1, -1, -1, -1 ) ); if ( url.hasQueryItem( QStringLiteral( "field" ) ) ) { QList<QgsField> attributes; QRegExp reFieldDef( "\\:" "(int|integer|long|int8|real|double|string|date|time|datetime)" // type "(?:\\((\\-?\\d+)" // length "(?:\\,(\\d+))?" // precision "\\))?(\\[\\])?" // array "$", Qt::CaseInsensitive ); QStringList fields = url.allQueryItemValues( QStringLiteral( "field" ) ); for ( int i = 0; i < fields.size(); i++ ) { QString name = QUrl::fromPercentEncoding( fields.at( i ).toUtf8() ); QVariant::Type type = QVariant::String; QVariant::Type subType = QVariant::Invalid; QString typeName( QStringLiteral( "string" ) ); int length = 255; int precision = 0; int pos = reFieldDef.indexIn( name ); if ( pos >= 0 ) { name = name.mid( 0, pos ); typeName = reFieldDef.cap( 1 ).toLower(); if ( typeName == QLatin1String( "int" ) || typeName == QLatin1String( "integer" ) ) { type = QVariant::Int; typeName = QStringLiteral( "integer" ); length = -1; } else if ( typeName == QLatin1String( "int8" ) || typeName == QLatin1String( "long" ) ) { type = QVariant::LongLong; typeName = QStringLiteral( "int8" ); length = -1; } else if ( typeName == QLatin1String( "real" ) || typeName == QLatin1String( "double" ) ) { type = QVariant::Double; typeName = QStringLiteral( "double" ); length = 20; precision = 5; } else if ( typeName == QLatin1String( "date" ) ) { type = QVariant::Date; typeName = QStringLiteral( "date" ); length = -1; } else if ( typeName == QLatin1String( "time" ) ) { type = QVariant::Time; typeName = QStringLiteral( "time" ); length = -1; } else if ( typeName == QLatin1String( "datetime" ) ) { type = QVariant::DateTime; typeName = QStringLiteral( "datetime" ); length = -1; } if ( !reFieldDef.cap( 2 ).isEmpty() ) { length = reFieldDef.cap( 2 ).toInt(); } if ( !reFieldDef.cap( 3 ).isEmpty() ) { precision = reFieldDef.cap( 3 ).toInt(); } if ( !reFieldDef.cap( 4 ).isEmpty() ) { //array subType = type; type = ( subType == QVariant::String ? QVariant::StringList : QVariant::List ); } } if ( !name.isEmpty() ) attributes.append( QgsField( name, type, typeName, length, precision, QLatin1String( "" ), subType ) ); } addAttributes( attributes ); } if ( url.hasQueryItem( QStringLiteral( "index" ) ) && url.queryItemValue( QStringLiteral( "index" ) ) == QLatin1String( "yes" ) ) { createSpatialIndex(); } }
bool JsonValue::value(uint64_t& value) const { YSON_THROW("Unsupported function for values of type " + typeName()); }
GUCEF::GUI::CWidget* CFormBackendImp::CreateAndHookWrapperForWindow( CEGUI::Window* window ) {GUCEF_TRACE; GUCEF::GUI::CWidget* widgetWrapper = NULL; CString typeName( CString( window->getType().c_str() ).SubstrToChar( '/', false ) ); //if ( "Button" == typeName ) //{ // widgetWrapper = new CButtonImp(); // static_cast< CButtonImp* >( widgetWrapper )->Hook( static_cast< CEGUI::PushButton* >( window ) ); //} //else //if ( "Editbox" == typeName ) //{ // widgetWrapper = new CEditboxImp(); // static_cast< CEditboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Editbox* >( window ) ); //} //else //if ( "Listbox" == typeName ) //{ // widgetWrapper = new CListboxImp(); // static_cast< CListboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Listbox* >( window ) ); //} //else //if ( "StaticImage" == typeName ) //{ // CString widgetName( CString( window->getName().c_str() ).SubstrToChar( '/', false ) ); // // if ( widgetName == "RenderContext" ) // { // widgetWrapper = new CRenderContextImp(); // static_cast< CRenderContextImp* >( widgetWrapper )->Hook( window ); // } // else // { // widgetWrapper = new CImageFrameImp(); // static_cast< CImageFrameImp* >( widgetWrapper )->Hook( window ); // } //} //else //if ( "StaticText" == typeName ) //{ // widgetWrapper = new CLabelImp(); // static_cast< CLabelImp* >( widgetWrapper )->Hook( window ); //} //else //if ( "Checkbox" == typeName ) //{ // widgetWrapper = new CCheckboxImp(); // static_cast< CCheckboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Checkbox* >( window ) ); //} //else //if ( "Combobox" == typeName ) //{ // widgetWrapper = new CComboboxImp(); // static_cast< CComboboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Combobox* >( window ) ); //} //if ( "TabControl" == typeName ) //{ // widgetWrapper = new CTabControlImp(); // static_cast< CTabControlImp* >( widgetWrapper )->Hook( static_cast< CEGUI::TabControl* >( window ) ); //} //else //if ( "TabContentPane" == typeName ) //{ // widgetWrapper = new CTabContentPaneImp(); // static_cast< CTabContentPaneImp* >( widgetWrapper )->Hook( window ); //} //else if ( "FrameWindow" == typeName ) { widgetWrapper = new CWindowImp(); static_cast< CWindowImp* >( widgetWrapper )->Hook( static_cast< CEGUI::FrameWindow* >( window ) ); } //else //if ( "MultiColumnList" == typeName ) //{ // widgetWrapper = new CGridViewImp(); // static_cast< CGridViewImp* >( widgetWrapper )->Hook( static_cast< CEGUI::MultiColumnList* >( window ) ); //} //else //if ( "Spinner" == typeName ) //{ // widgetWrapper = new CSpinnerImp(); // static_cast< CSpinnerImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Spinner* >( window ) ); //} //else //if ( "DefaultWindow" == typeName ) //{ // widgetWrapper = new TBasicWidgetImp(); // static_cast< TBasicWidgetImp* >( widgetWrapper )->Hook( window ); //} GUCEF_DEBUG_LOG( 0, "Wrapped and hooked GUI widget for CEGUI widget of type " + typeName ); return widgetWrapper; }
bool JsonValue::value(long double& value) const { YSON_THROW("Unsupported function for values of type " + typeName()); }
QString Piece::name() const { QString res = colorName() + '_'; if (m_promoted) res += "p_"; return res + typeName(); }
bool JsonValue::value(std::vector<char>& value) const { YSON_THROW("Unsupported function for values of type " + typeName()); }
QgsMemoryProvider::QgsMemoryProvider( const QString& uri ) : QgsVectorDataProvider( uri ) , mSpatialIndex( nullptr ) { // Initialize the geometry with the uri to support old style uri's // (ie, just 'point', 'line', 'polygon') QUrl url = QUrl::fromEncoded( uri.toUtf8() ); QString geometry; if ( url.hasQueryItem( "geometry" ) ) { geometry = url.queryItemValue( "geometry" ); } else { geometry = url.path(); } geometry = geometry.toLower(); if ( geometry == "point" ) mWkbType = QGis::WKBPoint; else if ( geometry == "linestring" ) mWkbType = QGis::WKBLineString; else if ( geometry == "polygon" ) mWkbType = QGis::WKBPolygon; else if ( geometry == "multipoint" ) mWkbType = QGis::WKBMultiPoint; else if ( geometry == "multilinestring" ) mWkbType = QGis::WKBMultiLineString; else if ( geometry == "multipolygon" ) mWkbType = QGis::WKBMultiPolygon; else if ( geometry == "none" ) mWkbType = QGis::WKBNoGeometry; else mWkbType = QGis::WKBUnknown; if ( url.hasQueryItem( "crs" ) ) { QString crsDef = url.queryItemValue( "crs" ); mCrs.createFromString( crsDef ); } mNextFeatureId = 1; mNativeTypes << QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 0, 10 ) // Decimal number from OGR/Shapefile/dbf may come with length up to 32 and // precision up to length-2 = 30 (default, if width is not specified in dbf is length = 24 precision = 15) // We know that double (QVariant::Double) has only 15-16 significant numbers, // but setting that correct limits would disable the use of memory provider with // data from Shapefiles. In any case, the data are handled as doubles. // So the limits set here are not correct but enable use of data from Shapefiles. << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double", QVariant::Double, 0, 32, 0, 30 ) << QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 0, 255 ) // date type << QgsVectorDataProvider::NativeType( tr( "Date" ), "date", QVariant::Date, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Time" ), "time", QVariant::Time, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Date & Time" ), "datetime", QVariant::DateTime, -1, -1, -1, -1 ) // integer types << QgsVectorDataProvider::NativeType( tr( "Whole number (smallint - 16bit)" ), "int2", QVariant::Int, -1, -1, 0, 0 ) << QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 32bit)" ), "int4", QVariant::Int, -1, -1, 0, 0 ) << QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 64bit)" ), "int8", QVariant::LongLong, -1, -1, 0, 0 ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (numeric)" ), "numeric", QVariant::Double, 1, 20, 0, 20 ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (decimal)" ), "decimal", QVariant::Double, 1, 20, 0, 20 ) // floating point << QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "real", QVariant::Double, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double precision", QVariant::Double, -1, -1, -1, -1 ) // string types << QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), "text", QVariant::String, -1, -1, -1, -1 ) ; if ( url.hasQueryItem( "field" ) ) { QList<QgsField> attributes; QRegExp reFieldDef( "\\:" "(int|integer|long|int8|real|double|string|date|time|datetime)" // type "(?:\\((\\-?\\d+)" // length "(?:\\,(\\d+))?" // precision "\\))?" "$", Qt::CaseInsensitive ); QStringList fields = url.allQueryItemValues( "field" ); for ( int i = 0; i < fields.size(); i++ ) { QString name = fields.at( i ); QVariant::Type type = QVariant::String; QString typeName( "string" ); int length = 255; int precision = 0; int pos = reFieldDef.indexIn( name ); if ( pos >= 0 ) { name = name.mid( 0, pos ); typeName = reFieldDef.cap( 1 ).toLower(); if ( typeName == "int" || typeName == "integer" ) { type = QVariant::Int; typeName = "integer"; length = -1; } else if ( typeName == "int8" || typeName == "long" ) { type = QVariant::LongLong; typeName = "int8"; length = -1; } else if ( typeName == "real" || typeName == "double" ) { type = QVariant::Double; typeName = "double"; length = 20; precision = 5; } else if ( typeName == "date" ) { type = QVariant::Date; typeName = "date"; length = -1; } else if ( typeName == "time" ) { type = QVariant::Time; typeName = "time"; length = -1; } else if ( typeName == "datetime" ) { type = QVariant::DateTime; typeName = "datetime"; length = -1; } if ( reFieldDef.cap( 2 ) != "" ) { length = reFieldDef.cap( 2 ).toInt(); } if ( reFieldDef.cap( 3 ) != "" ) { precision = reFieldDef.cap( 3 ).toInt(); } } if ( name != "" ) attributes.append( QgsField( name, type, typeName, length, precision ) ); } addAttributes( attributes ); } if ( url.hasQueryItem( "index" ) && url.queryItemValue( "index" ) == "yes" ) { createSpatialIndex(); } }
const JsonValue& JsonValue::operator[](size_t index) const { YSON_THROW("Unsupported function for values of type " + typeName()); }
Status MemberConfig::initialize(const BSONObj& mcfg, ReplicaSetTagConfig* tagConfig) { Status status = bsonCheckOnlyHasFields( "replica set member configuration", mcfg, kLegalMemberConfigFieldNames); if (!status.isOK()) return status; // // Parse _id field. // BSONElement idElement = mcfg[kIdFieldName]; if (idElement.eoo()) { return Status(ErrorCodes::NoSuchKey, str::stream() << kIdFieldName << " field is missing"); } if (!idElement.isNumber()) { return Status(ErrorCodes::TypeMismatch, str::stream() << kIdFieldName << " field has non-numeric type " << typeName(idElement.type())); } _id = idElement.numberInt(); // // Parse h field. // std::string hostAndPortString; status = bsonExtractStringField(mcfg, kHostFieldName, &hostAndPortString); if (!status.isOK()) return status; boost::trim(hostAndPortString); status = _host.initialize(hostAndPortString); if (!status.isOK()) return status; if (!_host.hasPort()) { // make port explicit even if default. _host = HostAndPort(_host.host(), _host.port()); } // // Parse votes field. // BSONElement votesElement = mcfg[kVotesFieldName]; int votes; if (votesElement.eoo()) { votes = kVotesFieldDefault; } else if (votesElement.isNumber()) { votes = votesElement.numberInt(); } else { return Status(ErrorCodes::TypeMismatch, str::stream() << kVotesFieldName << " field value has non-numeric type " << typeName(votesElement.type())); } if (votes != 0 && votes != 1) { return Status(ErrorCodes::BadValue, str::stream() << kVotesFieldName << " field value is " << votesElement.numberInt() << " but must be 0 or 1"); } _isVoter = bool(votes); // // Parse priority field. // BSONElement priorityElement = mcfg[kPriorityFieldName]; if (priorityElement.eoo()) { _priority = kPriorityFieldDefault; } else if (priorityElement.isNumber()) { _priority = priorityElement.numberDouble(); } else { return Status(ErrorCodes::TypeMismatch, str::stream() << kPriorityFieldName << " field has non-numeric type " << typeName(priorityElement.type())); } // // Parse arbiterOnly field. // status = bsonExtractBooleanFieldWithDefault(mcfg, kArbiterOnlyFieldName, kArbiterOnlyFieldDefault, &_arbiterOnly); if (!status.isOK()) return status; // // Parse slaveDelay field. // BSONElement slaveDelayElement = mcfg[kSlaveDelayFieldName]; if (slaveDelayElement.eoo()) { _slaveDelay = kSlaveDelayFieldDefault; } else if (slaveDelayElement.isNumber()) { _slaveDelay = Seconds(slaveDelayElement.numberInt()); } else { return Status(ErrorCodes::TypeMismatch, str::stream() << kSlaveDelayFieldName << " field value has non-numeric type " << typeName(slaveDelayElement.type())); } // // Parse hidden field. // status = bsonExtractBooleanFieldWithDefault(mcfg, kHiddenFieldName, kHiddenFieldDefault, &_hidden); if (!status.isOK()) return status; // // Parse buildIndexes field. // status = bsonExtractBooleanFieldWithDefault(mcfg, kBuildIndexesFieldName, kBuildIndexesFieldDefault, &_buildIndexes); if (!status.isOK()) return status; // // Parse "tags" field. // _tags.clear(); BSONElement tagsElement; status = bsonExtractTypedField(mcfg, kTagsFieldName, Object, &tagsElement); if (status.isOK()) { for (BSONObj::iterator tagIter(tagsElement.Obj()); tagIter.more();) { const BSONElement& tag = tagIter.next(); if (tag.type() != String) { return Status(ErrorCodes::TypeMismatch, str::stream() << "tags." << tag.fieldName() << " field has non-string value of type " << typeName(tag.type())); } _tags.push_back(tagConfig->makeTag(tag.fieldNameStringData(), tag.valueStringData())); } } else if (ErrorCodes::NoSuchKey != status) { return status; } return Status::OK(); }
const JsonValue& JsonValue::operator[](const std::string& key) const { YSON_THROW("Unsupported function for values of type " + typeName()); }
void Opcode8032::_run() { auto num = _script->dataStack()->popInteger(); auto value = _script->dataStack()->values()->at(_script->DVARbase() + num); _script->dataStack()->push(value); Logger::debug("SCRIPT") << "[8032] [*] op_fetch " << "var" << std::hex << num << " type = " << value.typeName() << std::endl; }
ScriptValueP ScriptValue::makeIterator() const { return delay_error(ScriptErrorConversion(typeName(), _TYPE_("collection"))); }