int Cmp( const Row & r1, const Row & r2, const FieldList & fl ) { if ( r1.Size() <= r2.Size() ) { for ( unsigned int i = 0; i < r1.Size() ; i++ ) { if ( fl.Size() == 0 || fl.Contains( i ) ) { if ( r1.At( i ) < r2.At(i) ) { return -1; } else if ( r1.At( i ) > r2.At(i) ) { return 1; } } } return r1.Size() < r2.Size() ? -1 : 0; } else { for ( unsigned int i = 0; i < r2.Size() ; i++ ) { if ( fl.Size() == 0 || fl.Contains( i ) ) { if ( r1.At( i ) < r2.At(i) ) { return -1; } else if ( r1.At( i ) > r2.At(i) ) { return 1; } } } return 1; } }
virtual bool get_field(doid_t do_id, const Field* field, vector<uint8_t> &value) { // Get class from the objects table const Class* dcc = get_class(do_id); if(!dcc) { return false; // Object does not exist } bool stored = is_storable(dcc->get_id()); if(!stored) { return false; // Class has no database fields } FieldList fields; fields.push_back(field); FieldValues values; get_fields_from_table(do_id, dcc, fields, values); auto val_it = values.find(field); if(val_it == values.end()) { return false; } value = val_it->second; return true; }
FieldList Database::tableFields(const QString & table, const QString & schema) { FieldList fields; QString sql(QString("PRAGMA \"%1\".TABLE_INFO(\"%2\");").arg(schema).arg(table)); QSqlQuery query(sql, QSqlDatabase::database(SESSION_NAME)); if (query.lastError().isValid()) { //exception(tr("Error while getting the fileds of %1: %2.").arg(table).arg(query.lastError().text())); return fields; } while (query.next()) { DatabaseTableField field; field.cid = query.value(0).toInt(); field.name = query.value(1).toString(); field.type = query.value(2).toString(); if (field.type.isNull() || field.type.isEmpty()) field.type = "NULL"; field.notnull = query.value(3).toBool(); field.defval = query.value(4).toString(); field.pk = query.value(5).toBool(); field.comment = ""; fields.append(field); } return fields; }
void Architecture::replaceRegSets(FieldList& fl) { for (size_t i = 0; i < fl.size(); ++i) { auto name = currentArch->regSymbolMap.find(fl.getField(i)); if (name != currentArch->regSymbolMap.end()) { fl.setField(i, name->second); } } }
int main( int argc, char* argv[] ) { try { Map configMap; createProgrammaticConfig( configMap ); OmmProvider provider( OmmNiProviderConfig().config( configMap ).username( "user" ) ); UInt64 ibmHandle = 5; UInt64 triHandle = 6; RefreshMsg refresh; UpdateMsg update; FieldList fieldList; provider.submit( refresh.serviceName( "NI_PUB" ).name( "IBM.N" ) .state( OmmState::OpenEnum, OmmState::OkEnum, OmmState::NoneEnum, "UnSolicited Refresh Completed" ) .payload( fieldList .addReal( 22, 14400, OmmReal::ExponentNeg2Enum ) .addReal( 25, 14700, OmmReal::ExponentNeg2Enum ) .addReal( 30, 9, OmmReal::Exponent0Enum ) .addReal( 31, 19, OmmReal::Exponent0Enum ) .complete() ) .complete(), ibmHandle ); provider.submit( refresh.clear().serviceName( "NI_PUB" ).name( "TRI.N" ) .state( OmmState::OpenEnum, OmmState::OkEnum, OmmState::NoneEnum, "UnSolicited Refresh Completed" ) .payload( fieldList.clear() .addReal( 22, 4100, OmmReal::ExponentNeg2Enum ) .addReal( 25, 4200, OmmReal::ExponentNeg2Enum ) .addReal( 30, 20, OmmReal::Exponent0Enum ) .addReal( 31, 40, OmmReal::Exponent0Enum ) .complete() ) .complete(), triHandle ); sleep( 1000 ); for ( Int32 i = 0; i < 60; i++ ) { provider.submit( update.clear().serviceName( "NI_PUB" ).name( "IBM.N" ) .payload( fieldList.clear() .addReal( 22, 14400 + i, OmmReal::ExponentNeg2Enum ) .addReal( 30, 10 + i, OmmReal::Exponent0Enum ) .complete() ), ibmHandle ); provider.submit( update.clear().serviceName( "NI_PUB" ).name( "TRI.N" ) .payload( fieldList.clear() .addReal( 22, 4100 + i, OmmReal::ExponentNeg2Enum ) .addReal( 30, 21 + i, OmmReal::Exponent0Enum ) .complete() ), triHandle ); sleep( 1000 ); } } catch ( const OmmException& excp ) { cout << excp << endl; } return 0; }
void del_fields_in_table(doid_t id, const Class* dcc, const FieldList &fields) { string name; for(auto it = fields.begin(); it != fields.end(); ++it) { const Field* field = *it; if(field->has_keyword("db")) { m_sql << "UPDATE fields_" << dcc->get_name() << " SET " << field->get_name() << "=NULL WHERE object_id=" << id << ";"; } } }
virtual void del_field(doid_t do_id, const Field* field) { const Class *dcc = get_class(do_id); bool storable = is_storable(dcc->get_id()); if(storable) { FieldList fields; fields.push_back(field); del_fields_in_table(do_id, dcc, fields); } }
FieldList operator&(const FieldList & one, const FieldList & two) { if( one.size() == two.size() ) { bool same = true; foreach( Field * f, one ) if( !two.contains(f) ) { same = false; break; } if( same ) return one; }
static void SumRow( vector <double> & sums, const CSVRow & row, const FieldList & fl ) { for ( unsigned int i = 0; i < fl.size(); i++ ) { unsigned int fi = fl.at(i); if ( fi >= row.size() ) { CSVTHROW( "Invalid field index" ); } sums.at(i) += ALib::ToReal( row.at(fi) ); } }
FieldList* FieldList::subList(const QValueList<uint>& list) { Field *f; FieldList *fl = new FieldList(false); foreach(QValueList<uint>::ConstIterator, it, list) { f = field(*it); if (!f) { KexiDBWarn << QString("FieldList::subList() could not find field at position %1").arg(*it) << endl; delete fl; return 0; } fl->addField(f); }
// Optmized to not copy(because of implicit sharing) if one already contains all of two FieldList operator|(const FieldList & one, const FieldList & two) { bool firstComplete = two.size() <= one.size(); FieldList ret; foreach( Field * f, two ) if( !one.contains(f) ) { if( firstComplete ) { firstComplete = false; ret = one; } ret += f; } return firstComplete ? one : ret; }
bool KexiDB::SybaseConnection::drv_beforeUpdate(const QString& table, FieldList& fields) { if (fields.autoIncrementFields()->isEmpty()) return true; // explicit update of IDENTITY fields has taken place. return drv_executeSQL(QString("SET IDENTITY_UPDATE %1 ON").arg(escapeIdentifier(table))); }
void AppClient::decode( const FieldList& fl ) { while ( fl.forth() ) { const FieldEntry& fe = fl.getEntry(); cout << "Name: " << fe.getName() << " Value: "; if ( fe.getCode() == Data::BlankEnum ) cout << " blank" << endl; else switch ( fe.getLoadType() ) { case DataType::RealEnum : cout << fe.getReal().getAsDouble() << endl; break; case DataType::DateEnum : cout << (UInt64)fe.getDate().getDay() << " / " << (UInt64)fe.getDate().getMonth() << " / " << (UInt64)fe.getDate().getYear() << endl; break; case DataType::TimeEnum : cout << (UInt64)fe.getTime().getHour() << ":" << (UInt64)fe.getTime().getMinute() << ":" << (UInt64)fe.getTime().getSecond() << ":" << (UInt64)fe.getTime().getMillisecond() << endl; break; case DataType::IntEnum : cout << fe.getInt() << endl; break; case DataType::UIntEnum : cout << fe.getUInt() << endl; break; case DataType::AsciiEnum : cout << fe.getAscii() << endl; break; case DataType::ErrorEnum : cout << "( " << fe.getError().getErrorCodeAsString() << " )" <<endl; break; case DataType::EnumEnum : cout << fe.getEnum() << endl; break; case DataType::RmtesEnum: cout << fe.getRmtes().toString() << endl; break; default : cout << endl; break; } } }
TEST(TestDatabaseUtils, GetSelectFields) { Fields fields; FieldList fieldlist; EXPECT_FALSE(DatabaseUtils::GetSelectFields(fields, MediaTypeAlbum, fieldlist)); fields.insert(FieldId); fields.insert(FieldGenre); fields.insert(FieldAlbum); fields.insert(FieldArtist); fields.insert(FieldTitle); EXPECT_FALSE(DatabaseUtils::GetSelectFields(fields, MediaTypeNone, fieldlist)); EXPECT_TRUE(DatabaseUtils::GetSelectFields(fields, MediaTypeAlbum, fieldlist)); EXPECT_FALSE(fieldlist.empty()); }
bool KexiDB::SybaseConnection::drv_beforeInsert(const QString& table, FieldList& fields) { if (fields.autoIncrementFields()->isEmpty()) return true; // explicit insertion into IDENTITY fields !! return drv_executeSQL(QString("SET IDENTITY_INSERT %1 ON").arg(escapeIdentifier(table))); }
bool SortUtils::SortFromDataset(const SortDescription &sortDescription, const MediaType &mediaType, const std::unique_ptr<dbiplus::Dataset> &dataset, DatabaseResults &results) { FieldList fields; if (!DatabaseUtils::GetSelectFields(SortUtils::GetFieldsForSorting(sortDescription.sortBy), mediaType, fields)) fields.clear(); if (!DatabaseUtils::GetDatabaseResults(mediaType, fields, dataset, results)) return false; SortDescription sorting = sortDescription; if (sortDescription.sortBy == SortByNone) { sorting.limitStart = 0; sorting.limitEnd = -1; } Sort(sorting, results); return true; }
bool KexiDB::SybaseConnection::drv_afterUpdate(const QString& table, FieldList& fields) { // should we instead just set a flag when an identity_update has taken place and only check for that // flag here ? if (fields.autoIncrementFields()->isEmpty()) return true; // explicit insertion into IDENTITY fields has taken place. Turn off IDENTITY_INSERT return drv_executeSQL(QString("SET IDENTITY_UPDATE %1 OFF").arg(escapeIdentifier(table))); }
bool DatabaseUtils::GetSelectFields(const Fields &fields, const MediaType &mediaType, FieldList &selectFields) { if (mediaType == MediaTypeNone || fields.empty()) return false; Fields sortFields = fields; // add necessary fields to create the label if (mediaType == MediaTypeSong || mediaType == MediaTypeVideo || mediaType == MediaTypeVideoCollection || mediaType == MediaTypeMusicVideo || mediaType == MediaTypeMovie || mediaType == MediaTypeTvShow || mediaType == MediaTypeEpisode) sortFields.insert(FieldTitle); if (mediaType == MediaTypeEpisode) { sortFields.insert(FieldSeason); sortFields.insert(FieldEpisodeNumber); } else if (mediaType == MediaTypeAlbum) sortFields.insert(FieldAlbum); else if (mediaType == MediaTypeSong) sortFields.insert(FieldTrackNumber); else if (mediaType == MediaTypeArtist) sortFields.insert(FieldArtist); selectFields.clear(); for (Fields::const_iterator it = sortFields.begin(); it != sortFields.end(); ++it) { // ignore FieldLabel because it needs special handling (see further up) if (*it == FieldLabel) continue; if (GetField(*it, mediaType, DatabaseQueryPartSelect).empty()) { CLog::Log(LOGDEBUG, "DatabaseUtils::GetSortFieldList: unknown field %d", *it); continue; } selectFields.push_back(*it); } return !selectFields.empty(); }
FieldList ValidateCommand :: ReadFields( const string & line, unsigned int & pos ) const { SkipSpaces( line, pos ); FieldList fl; if ( pos < line.size() && line[pos] == '*' ) { pos++; return fl; } string sf; while( pos < line.size() && ! isspace( line[pos] ) ) { sf += line[pos++]; } pos++; vector <string> tmp; ALib::Split( sf, ',', tmp ); for ( unsigned int i = 0; i < tmp.size(); i++ ) { if ( ALib::IsInteger( tmp[i] ) ) { int n = ALib::ToInteger( tmp[i] ); if ( n > 0 ) { fl.push_back ( n - 1 ); continue; } } CSVTHROW( "Invalid field list: " << sf ); } if ( fl.size() == 0 ) { CSVTHROW( "Need at least one field in rule: " << line ); } return fl; }
void get_fields_from_table(doid_t id, const Class* dcc, const FieldList &fields, FieldValues &values) { string value; indicator ind; for(auto it = fields.begin(); it != fields.end(); ++it) { const Field* field = *it; if(field->has_keyword("db")) { m_sql << "SELECT " << field->get_name() << " FROM fields_" << dcc->get_name() << " WHERE object_id=" << id << ";", into(value, ind); if(ind == i_ok) { bool parse_err; string packed_data = parse_value(field->get_type(), value, parse_err); if(parse_err) { m_log->error() << "Failed parsing value for field '" << field->get_name() << "' of object " << id << "' from database.\n"; continue; } values[field] = vector<uint8_t>(packed_data.begin(), packed_data.end()); } } } }
void be_structure::put_core_fields ( ostream & os, be_Tab & tab, const DDS_StdString & sptr, FieldList & coreFields, unsigned long uid ) { DDS::Boolean wroteOne = FALSE; DDS_StdString uids = BE_Globals::ulong_to_string(uid); DDS_StdString _in_ = (DDS_StdString)"_in_" + uids; FieldList::iterator it; // first, let's declare the core args for putting for (it = coreFields.begin(); it != coreFields.end(); it++) { (*it)->declare_for_struct_put (os, tab, sptr, uid); } // // now, let's initilize our put args // os << tab << "DDS::Codec::Param " << _in_ << "[" << coreFields.size() << "] =" << nl; os << tab << "{" << nl; tab.indent (); for (it = coreFields.begin(); it != coreFields.end(); it++) { if (wroteOne) { os << "," << nl; } (*it)->make_put_param (os, tab, sptr, uid); wroteOne = TRUE; } tab.outdent (); os << nl << tab << "};" << nl; // and finally, let's put 'em os << tab << "os.put (" << _in_ << ", " << coreFields.size () << XBE_Ev::arg (XBE_ENV_VARN) << ");" << nl; }
void be_exception::getter ( ostream & os, be_Tab & tab, const DDS_StdString & sptr, unsigned long uid ) { DDS_StdString uids = BE_Globals::ulong_to_string(uid); if (m_marshalInCore) { get_core_fields(os, tab, sptr, m_fields, uid); } else { FieldList coreFields; FieldList::iterator it; for (it = m_fields.begin(); it != m_fields.end(); it++) { if ((*it)->is_core_marshaled()) { coreFields.push_back(*it); } else { if (coreFields.size()) { get_core_fields(os, tab, sptr, coreFields, uid++); coreFields.erase(); } (*it)->get_for_struct(os, tab, sptr, uid++); } } if (coreFields.size()) { get_core_fields(os, tab, sptr, coreFields, uid++); coreFields.erase(); } } }
bool DatabaseUtils::GetDatabaseResults(const MediaType &mediaType, const FieldList &fields, const std::unique_ptr<dbiplus::Dataset> &dataset, DatabaseResults &results) { if (dataset->num_rows() == 0) return true; const dbiplus::result_set &resultSet = dataset->get_result_set(); unsigned int offset = results.size(); if (fields.empty()) { DatabaseResult result; for (unsigned int index = 0; index < resultSet.records.size(); index++) { result[FieldRow] = index + offset; results.push_back(result); } return true; } if (resultSet.record_header.size() < fields.size()) return false; std::vector<int> fieldIndexLookup; fieldIndexLookup.reserve(fields.size()); for (FieldList::const_iterator it = fields.begin(); it != fields.end(); ++it) fieldIndexLookup.push_back(GetFieldIndex(*it, mediaType)); results.reserve(resultSet.records.size() + offset); for (unsigned int index = 0; index < resultSet.records.size(); index++) { DatabaseResult result; result[FieldRow] = index + offset; unsigned int lookupIndex = 0; for (FieldList::const_iterator it = fields.begin(); it != fields.end(); ++it) { int fieldIndex = fieldIndexLookup[lookupIndex++]; if (fieldIndex < 0) return false; std::pair<Field, CVariant> value; value.first = *it; if (!GetFieldValue(resultSet.records[index]->at(fieldIndex), value.second)) CLog::Log(LOGWARNING, "GetDatabaseResults: unable to retrieve value of field %s", resultSet.record_header[fieldIndex].name.c_str()); if (value.first == FieldYear && (mediaType == MediaTypeTvShow || mediaType == MediaTypeEpisode)) { CDateTime dateTime; dateTime.SetFromDBDate(value.second.asString()); if (dateTime.IsValid()) { value.second.clear(); value.second = dateTime.GetYear(); } } result.insert(value); } result[FieldMediaType] = mediaType; if (mediaType == MediaTypeMovie || mediaType == MediaTypeVideoCollection || mediaType == MediaTypeTvShow || mediaType == MediaTypeMusicVideo) result[FieldLabel] = result.at(FieldTitle).asString(); else if (mediaType == MediaTypeEpisode) { std::ostringstream label; label << (int)(result.at(FieldSeason).asInteger() * 100 + result.at(FieldEpisodeNumber).asInteger()); label << ". "; label << result.at(FieldTitle).asString(); result[FieldLabel] = label.str(); } else if (mediaType == MediaTypeAlbum) result[FieldLabel] = result.at(FieldAlbum).asString(); else if (mediaType == MediaTypeSong) { std::ostringstream label; label << (int)result.at(FieldTrackNumber).asInteger(); label << ". "; label << result.at(FieldTitle).asString(); result[FieldLabel] = label.str(); } else if (mediaType == MediaTypeArtist) result[FieldLabel] = result.at(FieldArtist).asString(); results.push_back(result); } return true; }
Tellico::Data::FieldList BibtexCollection::defaultFields() { FieldList list; FieldPtr field; /******************* General ****************************/ field = createDefaultField(TitleField); field->setProperty(QLatin1String("bibtex"), QLatin1String("title")); list.append(field); QStringList types; types << QLatin1String("article") << QLatin1String("book") << QLatin1String("booklet") << QLatin1String("inbook") << QLatin1String("incollection") << QLatin1String("inproceedings") << QLatin1String("manual") << QLatin1String("mastersthesis") << QLatin1String("misc") << QLatin1String("phdthesis") << QLatin1String("proceedings") << QLatin1String("techreport") << QLatin1String("unpublished") << QLatin1String("periodical") << QLatin1String("conference"); field = new Field(QLatin1String("entry-type"), i18n("Entry Type"), types); field->setProperty(QLatin1String("bibtex"), QLatin1String("entry-type")); field->setCategory(i18n(bibtex_general)); field->setFlags(Field::AllowGrouped | Field::NoDelete); field->setDescription(i18n("These entry types are specific to bibtex. See the bibtex documentation.")); list.append(field); field = new Field(QLatin1String("author"), i18n("Author")); field->setProperty(QLatin1String("bibtex"), QLatin1String("author")); field->setCategory(i18n(bibtex_general)); field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); field->setFormatType(FieldFormat::FormatName); list.append(field); field = new Field(QLatin1String("bibtex-key"), i18n("Bibtex Key")); field->setProperty(QLatin1String("bibtex"), QLatin1String("key")); field->setCategory(i18n("General")); field->setFlags(Field::NoDelete); list.append(field); field = new Field(QLatin1String("booktitle"), i18n("Book Title")); field->setProperty(QLatin1String("bibtex"), QLatin1String("booktitle")); field->setCategory(i18n(bibtex_general)); field->setFormatType(FieldFormat::FormatTitle); list.append(field); field = new Field(QLatin1String("editor"), i18n("Editor")); field->setProperty(QLatin1String("bibtex"), QLatin1String("editor")); field->setCategory(i18n(bibtex_general)); field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); field->setFormatType(FieldFormat::FormatName); list.append(field); field = new Field(QLatin1String("organization"), i18n("Organization")); field->setProperty(QLatin1String("bibtex"), QLatin1String("organization")); field->setCategory(i18n(bibtex_general)); field->setFlags(Field::AllowCompletion | Field::AllowGrouped); field->setFormatType(FieldFormat::FormatPlain); list.append(field); // field = new Field(QLatin1String("institution"), i18n("Institution")); // field->setProperty(QLatin1String("bibtex"), QLatin1String("institution")); // field->setCategory(i18n(bibtex_general)); // field->setFlags(Field::AllowDelete); // field->setFormatType(FieldFormat::FormatTitle); // list.append(field); /******************* Publishing ****************************/ field = new Field(QLatin1String("publisher"), i18n("Publisher")); field->setProperty(QLatin1String("bibtex"), QLatin1String("publisher")); field->setCategory(i18n(bibtex_publishing)); field->setFlags(Field::AllowCompletion | Field::AllowGrouped); field->setFormatType(FieldFormat::FormatPlain); list.append(field); field = new Field(QLatin1String("address"), i18n("Address")); field->setProperty(QLatin1String("bibtex"), QLatin1String("address")); field->setCategory(i18n(bibtex_publishing)); field->setFlags(Field::AllowCompletion | Field::AllowGrouped); list.append(field); field = new Field(QLatin1String("edition"), i18n("Edition")); field->setProperty(QLatin1String("bibtex"), QLatin1String("edition")); field->setCategory(i18n(bibtex_publishing)); field->setFlags(Field::AllowCompletion); list.append(field); // don't make it a number, it could have latex processing commands in it field = new Field(QLatin1String("pages"), i18n("Pages")); field->setProperty(QLatin1String("bibtex"), QLatin1String("pages")); field->setCategory(i18n(bibtex_publishing)); list.append(field); field = new Field(QLatin1String("year"), i18n("Year"), Field::Number); field->setProperty(QLatin1String("bibtex"), QLatin1String("year")); field->setCategory(i18n(bibtex_publishing)); field->setFlags(Field::AllowGrouped); list.append(field); field = new Field(QLatin1String("isbn"), i18n("ISBN#")); field->setProperty(QLatin1String("bibtex"), QLatin1String("isbn")); field->setCategory(i18n(bibtex_publishing)); field->setDescription(i18n("International Standard Book Number")); list.append(field); field = new Field(QLatin1String("journal"), i18n("Journal")); field->setProperty(QLatin1String("bibtex"), QLatin1String("journal")); field->setCategory(i18n(bibtex_publishing)); field->setFlags(Field::AllowCompletion | Field::AllowGrouped); field->setFormatType(FieldFormat::FormatPlain); list.append(field); field = new Field(QLatin1String("doi"), i18n("DOI")); field->setProperty(QLatin1String("bibtex"), QLatin1String("doi")); field->setCategory(i18n(bibtex_publishing)); field->setDescription(i18n("Digital Object Identifier")); list.append(field); // could make this a string list, but since bibtex import could have funky values // keep it an editbox field = new Field(QLatin1String("month"), i18n("Month")); field->setProperty(QLatin1String("bibtex"), QLatin1String("month")); field->setCategory(i18n(bibtex_publishing)); field->setFlags(Field::AllowCompletion); list.append(field); field = new Field(QLatin1String("number"), i18n("Number"), Field::Number); field->setProperty(QLatin1String("bibtex"), QLatin1String("number")); field->setCategory(i18n(bibtex_publishing)); list.append(field); field = new Field(QLatin1String("howpublished"), i18n("How Published")); field->setProperty(QLatin1String("bibtex"), QLatin1String("howpublished")); field->setCategory(i18n(bibtex_publishing)); list.append(field); // field = new Field(QLatin1String("school"), i18n("School")); // field->setProperty(QLatin1String("bibtex"), QLatin1String("school")); // field->setCategory(i18n(bibtex_publishing)); // field->setFlags(Field::AllowCompletion | Field::AllowGrouped); // list.append(field); /******************* Classification ****************************/ field = new Field(QLatin1String("chapter"), i18n("Chapter"), Field::Number); field->setProperty(QLatin1String("bibtex"), QLatin1String("chapter")); field->setCategory(i18n(bibtex_misc)); list.append(field); field = new Field(QLatin1String("series"), i18n("Series")); field->setProperty(QLatin1String("bibtex"), QLatin1String("series")); field->setCategory(i18n(bibtex_misc)); field->setFlags(Field::AllowCompletion | Field::AllowGrouped); field->setFormatType(FieldFormat::FormatTitle); list.append(field); field = new Field(QLatin1String("volume"), i18nc("A number field in a bibliography", "Volume"), Field::Number); field->setProperty(QLatin1String("bibtex"), QLatin1String("volume")); field->setCategory(i18n(bibtex_misc)); list.append(field); field = new Field(QLatin1String("crossref"), i18n("Cross-Reference")); field->setProperty(QLatin1String("bibtex"), QLatin1String("crossref")); field->setCategory(i18n(bibtex_misc)); list.append(field); // field = new Field(QLatin1String("annote"), i18n("Annotation")); // field->setProperty(QLatin1String("bibtex"), QLatin1String("annote")); // field->setCategory(i18n(bibtex_misc)); // list.append(field); field = new Field(QLatin1String("keyword"), i18n("Keywords")); field->setProperty(QLatin1String("bibtex"), QLatin1String("keywords")); field->setCategory(i18n(bibtex_misc)); field->setFlags(Field::AllowCompletion | Field::AllowMultiple | Field::AllowGrouped); list.append(field); field = new Field(QLatin1String("url"), i18n("URL"), Field::URL); field->setProperty(QLatin1String("bibtex"), QLatin1String("url")); field->setCategory(i18n(bibtex_misc)); list.append(field); field = new Field(QLatin1String("abstract"), i18n("Abstract"), Field::Para); field->setProperty(QLatin1String("bibtex"), QLatin1String("abstract")); list.append(field); field = new Field(QLatin1String("note"), i18n("Notes"), Field::Para); field->setProperty(QLatin1String("bibtex"), QLatin1String("note")); list.append(field); field = createDefaultField(IDField); field->setCategory(i18n(bibtex_misc)); list.append(field); field = createDefaultField(CreatedDateField); field->setCategory(i18n(bibtex_misc)); list.append(field); field = createDefaultField(ModifiedDateField); field->setCategory(i18n(bibtex_misc)); list.append(field); return list; }
QDebug operator<<(QDebug dbg, const FieldList& fieldlist) { return dbg << fieldlist.toString(); }
int main( int argc, char* argv[] ) { try { int iargs = 1; while ( iargs < argc ) { if ( ( strcmp("-dumpDictionary", argv[iargs] ) == 0) ) { dumpDictionary = true; } //APIQA else if ((strcmp("-filter", argv[iargs]) == 0)) { if (++iargs == argc) break; EmaString value(argv[iargs]); if (value.caseInsensitiveCompare("INFO")) { filter = DICTIONARY_INFO; } else if (value.caseInsensitiveCompare("MINIMAL")) { filter = DICTIONARY_MINIMAL; } else if (value.caseInsensitiveCompare("NORMAL")) { filter = DICTIONARY_NORMAL; } else if (value.caseInsensitiveCompare("VERBOSE")) { filter = DICTIONARY_VERBOSE; } } //END APIQA ++iargs; } OmmProvider provider( OmmNiProviderConfig().username( "user" ) ); UInt64 triHandle = 5; UpdateMsg update; FieldList fieldList; AppClient client; // Open Dictionary streams UInt64 fldHandle = provider.registerClient(ReqMsg().name("RWFFld").filter(filter).serviceName("NI_PUB").domainType(MMT_DICTIONARY), client); UInt64 enumHandle = provider.registerClient(ReqMsg().name("RWFEnum").filter(filter).serviceName("NI_PUB").domainType(MMT_DICTIONARY), client); provider.submit( RefreshMsg().serviceName( "NI_PUB" ).name( "TRI.N" ) .state( OmmState::OpenEnum, OmmState::OkEnum, OmmState::NoneEnum, "UnSolicited Refresh Completed" ) .payload( fieldList.clear() .addReal( 22, 4100, OmmReal::ExponentNeg2Enum ) .addReal( 25, 4200, OmmReal::ExponentNeg2Enum ) .addReal( 30, 20, OmmReal::Exponent0Enum ) .addReal( 31, 40, OmmReal::Exponent0Enum ) .complete() ) .complete(), triHandle ); sleep( 1000 ); for ( Int32 i = 0; i < 10; i++ ) { provider.submit( update.clear().serviceName( "NI_PUB" ).name( "TRI.N" ) .payload( fieldList.clear() .addReal( 22, 4100 + i, OmmReal::ExponentNeg2Enum ) .addReal( 30, 21 + i, OmmReal::Exponent0Enum ) .complete() ), triHandle ); sleep( 1000 ); //APIQA if ( i == 6 ) { cout <<"Reissue Dictionary handles with filter unchange " << endl; provider.reissue( ReqMsg().name("RWFFld").filter(filter).serviceName("NI_PUB").domainType(MMT_DICTIONARY).interestAfterRefresh(true), fldHandle); provider.reissue( ReqMsg().name("RWFEnum").filter(filter).serviceName("NI_PUB").domainType(MMT_DICTIONARY).interestAfterRefresh(true), enumHandle); } if ( i == 8 ) { cout <<"Reissue Dictionary handles with filter unchange " << endl; filter = DICTIONARY_NORMAL; provider.reissue( ReqMsg().name("RWFFld").filter(filter).serviceName("NI_PUB").domainType(MMT_DICTIONARY).interestAfterRefresh(true), fldHandle); provider.reissue( ReqMsg().name("RWFEnum").filter(filter).serviceName("NI_PUB").domainType(MMT_DICTIONARY).interestAfterRefresh(true), enumHandle); } if ( i == 9 ) { cout <<"Update Source Directory with delete service from DIRECTORY " << endl; provider.submit(UpdateMsg().domainType(MMT_DIRECTORY) .payload(Map() .addKeyUInt(1, MapEntry::DeleteEnum, FilterList() .complete()).complete()), 0); } } sleep( 1000 ); //END APIQA } catch ( const OmmException& excp ) { cout << excp << endl; } return 0; }
void AppClient::decode( const FieldList& fl ) { while ( fl.forth() ) cout << "Fid: " << fl.getEntry().getFieldId() << " Name: " << fl.getEntry().getName() << " value: " << fl.getEntry().getLoad().toString() << endl; }
void AppClient::decode( const FieldList& fl ) { try { while ( fl.forth() ) { const FieldEntry& fe = fl.getEntry(); if ( fe.getCode() == Data::NoCodeEnum ) switch ( fe.getLoadType() ) { case DataType::RealEnum : { const OmmReal& re = fe.getReal(); } break; case DataType::DateEnum : { const OmmDate& date = fe.getDate(); } break; case DataType::TimeEnum : { const OmmTime& time = fe.getTime(); } break; case DataType::DateTimeEnum : { const OmmDateTime& dateTime = fe.getDateTime(); } break; case DataType::IntEnum : { Int64 value = fe.getInt(); } break; case DataType::UIntEnum : { UInt64 value = fe.getUInt(); } break; case DataType::AsciiEnum : { const EmaString& asciiString = fe.getAscii(); } break; case DataType::RmtesEnum : { const RmtesBuffer& rmtesBuffer = fe.getRmtes(); } break; case DataType::Utf8Enum : { const EmaBuffer& utf8Buffer = fe.getUtf8(); } break; case DataType::EnumEnum : { UInt16 value = fe.getEnum(); } break; case DataType::ErrorEnum : { const OmmError& error = fe.getError(); } break; default : break; } } }catch ( const OmmException& excp ) { cout << excp << endl; } }
void AppClient::decode( const FieldList& fl ) { while ( fl.forth( "BID" ) ) // look for a fid with matching name cout << "Fid: " << fl.getEntry().getFieldId() << " Name: " << fl.getEntry().getName() << " value: " << fl.getEntry().getLoad().toString() << endl; }
Tellico::Data::FieldList WineCollection::defaultFields() { FieldList list; FieldPtr field; field = createDefaultField(TitleField); field->setProperty(QLatin1String("template"), QLatin1String("%{vintage} %{producer:1} %{varietal:1}")); field->setFlags(Field::NoDelete | Field::Derived); field->setFormatType(FieldFormat::FormatNone); list.append(field); field = new Field(QLatin1String("producer"), i18nc("Wine Producer", "Producer")); field->setCategory(i18n(wine_general)); field->setFlags(Field::AllowCompletion | Field::AllowGrouped); field->setFormatType(FieldFormat::FormatPlain); list.append(field); field = new Field(QLatin1String("appellation"), i18n("Appellation")); field->setCategory(i18n(wine_general)); field->setFlags(Field::AllowCompletion | Field::AllowGrouped); field->setFormatType(FieldFormat::FormatPlain); list.append(field); field = new Field(QLatin1String("varietal"), i18n("Varietal")); field->setCategory(i18n(wine_general)); field->setFlags(Field::AllowCompletion | Field::AllowGrouped); field->setFormatType(FieldFormat::FormatPlain); list.append(field); field = new Field(QLatin1String("vintage"), i18n("Vintage"), Field::Number); field->setCategory(i18n(wine_general)); field->setFlags(Field::AllowGrouped); list.append(field); QStringList type; type << i18n("Red Wine") << i18n("White Wine") << i18n("Sparkling Wine"); field = new Field(QLatin1String("type"), i18n("Type"), type); field->setCategory(i18n(wine_general)); field->setFlags(Field::AllowGrouped); list.append(field); field = new Field(QLatin1String("country"), i18n("Country")); field->setCategory(i18n(wine_general)); field->setFlags(Field::AllowCompletion | Field::AllowGrouped); field->setFormatType(FieldFormat::FormatPlain); list.append(field); field = new Field(QLatin1String("pur_date"), i18n("Purchase Date")); field->setCategory(i18n(wine_personal)); field->setFormatType(FieldFormat::FormatDate); list.append(field); field = new Field(QLatin1String("pur_price"), i18n("Purchase Price")); field->setCategory(i18n(wine_personal)); list.append(field); field = new Field(QLatin1String("location"), i18n("Location")); field->setCategory(i18n(wine_personal)); field->setFlags(Field::AllowCompletion | Field::AllowGrouped); list.append(field); field = new Field(QLatin1String("quantity"), i18n("Quantity"), Field::Number); field->setCategory(i18n(wine_personal)); list.append(field); field = new Field(QLatin1String("drink-by"), i18n("Drink By"), Field::Number); field->setCategory(i18n(wine_personal)); field->setFlags(Field::AllowGrouped); list.append(field); field = new Field(QLatin1String("rating"), i18n("Rating"), Field::Rating); field->setCategory(i18n(wine_personal)); field->setFlags(Field::AllowGrouped); list.append(field); field = new Field(QLatin1String("gift"), i18n("Gift"), Field::Bool); field->setCategory(i18n(wine_personal)); list.append(field); field = new Field(QLatin1String("label"), i18n("Label Image"), Field::Image); list.append(field); field = new Field(QLatin1String("description"), i18n("Description"), Field::Para); list.append(field); field = new Field(QLatin1String("comments"), i18n("Comments"), Field::Para); list.append(field); list.append(createDefaultField(IDField)); list.append(createDefaultField(CreatedDateField)); list.append(createDefaultField(ModifiedDateField)); return list; }