/** Automatically detects a valid schema for this wrapper by checking all the schema names returned by the schemaCandidateNames() method. @note calling this method if there is already another detection running has no effect. */ PAction *PWrapper::detectSchema() { PActionGroup *actionGroup = new PActionGroup(this); if (d->m_detectSchemaIsRunning) { /* avoid multiple executions */ qDebug("Detection process already in execution"); //actionGroup->finish(PAction::StatusFailure, true); return actionGroup; } // get all the schema names QList<QString> candidates = schemaCandidateNames(); if (candidates.isEmpty()) { // no schemas qDebug("no schemas found"); //actionGroup->finish(PAction::StatusFailure, true); return actionGroup; } // add each action returned by setSchema(candidate) to the group actionGroup->setSingleStatusToStop(PAction::StatusSuccess, PAction::StatusSuccess); for (int i=0; i<candidates.length(); i++) { QString candidate = candidates.at(i); actionGroup->addAction(setSchema(candidate)); } d->m_detectSchemaIsRunning = true; connect(actionGroup, SIGNAL(finished(PAction *)), this, SLOT(finalizeDetect())); return actionGroup; }
void MainWindow::openSchema( const QString & schema ) { if( QFile::exists( schema ) ) { mFileName = schema; setSchema( Schema::createFromXmlSchema( schema, /*isfile=*/true, /*ignoreDocs*/false ) ); } }
Relation::Relation(Scheme* inputScheme) { tuples = new set<Tuple>(); Id = inputScheme->getSchemeID(); //set main ID to Scheme ID schema = setSchema(inputScheme->getIDList()); //set Schema to Scheme ID List }
void MainWindow::slotImportSchema() { QString schemaFile = QFileDialog::getOpenFileName( this, "Choose A Schema", QString::null, sFileDialogFilterString ); if( schemaFile.size() ) { if( mSchema ) { mSchema->mergeXmlSchema( schemaFile, /*isfile=*/true, /*ignoreDocs*/false ); } else openSchema( schemaFile ); setSchema( mSchema ); } }
Reader::Reader(const Options& options, const PointBuffer& buffer) : pdal::Reader(options) , m_buffer(buffer) { setNumPoints(buffer.getNumPoints()); setBounds(buffer.getSpatialBounds()); setSchema(buffer.getSchema()); setPointCountType(PointCount_Fixed); return; }
MainWindow::MainWindow( Schema * schema ) : QMainWindow( 0 ) , mSchema( 0 ) , mChanges( false ) { mUI.setupUi( this ); QAction * openSchema = new QAction( QIcon(::icon( "fileopen.png" )), "Open Schema", this ); QAction * importSchema = new QAction( "Import Schema", this ); QAction * saveSchema = new QAction( QIcon(::icon( "filesave.png" ) ), "Save Schema", this ); QAction * saveSchemaAs = new QAction( QIcon(::icon( "filesaveas.png" ) ), "Save Schema As", this ); QAction * outputSource = new QAction( QIcon(::icon( "exec.png" ) ), "Output Source", this ); QAction * createDatabase = new QAction( QIcon(::icon( "create_database.png" ) ), "Create Database", this ); QAction * diff = new QAction( QIcon(::icon( "diff.png" )), "Generate Diff with Schema...", this ); QToolBar * toolbar = addToolBar( "Main Toolbar" ); toolbar->addAction( openSchema ); toolbar->addAction( importSchema ); toolbar->addAction( saveSchema ); toolbar->addAction( saveSchemaAs ); toolbar->addAction( outputSource ); toolbar->addAction( createDatabase ); toolbar->addAction( diff ); connect( openSchema, SIGNAL( triggered() ), SLOT( slotOpenSchema() ) ); connect( importSchema, SIGNAL( triggered() ), SLOT( slotImportSchema() ) ); connect( saveSchema, SIGNAL( triggered() ), SLOT( slotSaveSchema() ) ); connect( saveSchemaAs, SIGNAL( triggered() ), SLOT( slotSaveSchemaAs() ) ); connect( outputSource, SIGNAL( triggered() ), SLOT( slotOutputSource() ) ); connect( createDatabase, SIGNAL( triggered() ), SLOT( slotCreateDatabase() ) ); connect( diff, SIGNAL( triggered() ), SLOT( slotGenerateDiff() ) ); connect( mUI.mTreeView, SIGNAL( customContextMenuRequested( const QPoint & ) ), SLOT( showContextMenu( const QPoint & ) ) ); mUI.mTreeView->setContextMenuPolicy( Qt::CustomContextMenu ); mUI.mTreeView->setRootIsDecorated( true ); mUI.mTreeView->setSortingEnabled( true ); mModel = new SuperModel(mUI.mTreeView); QStringList hl; hl << "Name" << "Type" << "Db Name" << "Display Name"; mModel->setHeaderLabels( hl ); mTreeBuilder = new SchemaTreeBuilder(mModel); mModel->setTreeBuilder( mTreeBuilder ); mUI.mTreeView->setModel(mModel); setSchema( 0 ); }
KexiRelationsTableFieldList::KexiRelationsTableFieldList( KexiDB::TableOrQuerySchema* tableOrQuerySchema, KexiRelationsScrollArea *scrollArea, QWidget *parent) : KexiFieldListView(parent, ShowAsterisk) , m_scrollArea(scrollArea) { setSchema(tableOrQuerySchema); setAcceptDrops(true); connect(this, SIGNAL(contentsMoving(int,int)), this, SLOT(slotContentsMoving(int,int))); horizontalScrollBar()->installEventFilter(this); verticalScrollBar()->installEventFilter(this); }
KexiRelationsTableFieldList::KexiRelationsTableFieldList( KexiDB::TableOrQuerySchema* tableOrQuerySchema, KexiRelationsScrollArea *scrollArea, QWidget *parent) : KexiFieldListView(parent, KexiFieldListView::ShowAsterisk) , m_scrollArea(scrollArea) { setSchema(tableOrQuerySchema); header()->hide(); connect(this, SIGNAL(dropped(QDropEvent *, Q3ListViewItem *)), this, SLOT(slotDropped(QDropEvent *))); connect(this, SIGNAL(contentsMoving(int, int)), this, SLOT(slotContentsMoving(int, int))); horizontalScrollBar()->installEventFilter(this); verticalScrollBar()->installEventFilter(this); }
// Called by constructor (with config = kapp->getConfig()) // and by session-management (with config = sessionconfig). // So it has to apply the settings when reading them. void TEDemo::readProperties(KConfig* config) { config->setGroup("options"); // bad! will no allow us to support multi windows // Global options /////////////////////// setMenuVisible(config->readBoolEntry("menubar visible",TRUE)); setFrameVisible(config->readBoolEntry("has frame",TRUE)); scrollbar_menu_activated(QMIN(config->readUnsignedNumEntry("scrollbar",SCRRIGHT),2)); // not necessary for SM (KTMainWindow does it after), but useful for default settings if (menubar->menuBarPos() != KMenuBar::Floating) { QString entry = config->readEntry("kmenubar"); if (!entry.isEmpty() && entry == "floating") { menubar->setMenuBarPos(KMenuBar::Floating); QString geo = config->readEntry("kmenubargeometry"); if (!geo.isEmpty()) menubar->setGeometry(KWM::setProperties(menubar->winId(), geo)); } else if (!entry.isEmpty() && entry == "top") menubar->setMenuBarPos(KMenuBar::Top); else if (!entry.isEmpty() && entry == "bottom") menubar->setMenuBarPos(KMenuBar::Bottom); } // (geometry stuff removed) done by KTMainWindow for SM, and not needed otherwise // Options that should be applied to all sessions ///////////// // (1) set menu items and TEDemo members setBsHack(config->readBoolEntry("BS hack",TRUE)); setFont(QMIN(config->readUnsignedNumEntry("font",3),7)); // sets n_font and menu item setSchema(config->readEntry("schema","")); // (2) apply to sessions (currently only the 1st one) TESession* s = no2session.find(1); if (s) { s->setFontNo(n_font); s->setSchemaNo(ColorSchema::find(s_schema)->numb); if (b_bshack) s->getEmulation()->setMode(MODE_BsHack); else s->getEmulation()->resetMode(MODE_BsHack); } else { fprintf(stderr,"session 1 not found\n"); } // oops // Default values for startup, changed by "save options". Not used by SM. defaultSize.setWidth ( config->readNumEntry("defaultwidth", 0) ); defaultSize.setHeight( config->readNumEntry("defaultheight", 0) ); }
/** Packs a message into a zeromq message */ static zmq::message_t pack(const Message &msg) { ::capnp::MallocMessageBuilder builder; auto sermsg = builder.initRoot<serialize::Message>(); sermsg.setEndpoint(msg.endpoint()); sermsg.setExpectsAnswer(msg.expectsAnswer()); sermsg.setId(msg.id()); sermsg.setOriginator(msg.originator()); sermsg.setSchema(msg.schema()); sermsg.setType(static_cast<int>(msg.type())); if (!msg.data().empty()) { auto payload_builder = sermsg.initPayload(msg.data().size()); memcpy(&payload_builder[0], msg.data().data(), msg.data().size()); } auto data = capnp::messageToFlatArray(builder); auto byte_size = data.size() * sizeof(capnp::word); zmq::message_t ret(byte_size); memcpy(ret.data(), data.begin(), byte_size); return ret; }
void TEDemo::activateSession(int sn) { TESession* s = no2session.find(sn); if (se) { se->setConnect(FALSE); int no = (int)session2no.find(se); m_sessions->setItemChecked(no,FALSE); } se = s; if (!s) { fprintf(stderr,"session not found\n"); return; } // oops m_sessions->setItemChecked(sn,TRUE); setSchema(s->schemaNo()); //FIXME: creates flicker? Do only if differs //Set Font. Now setConnect should do the appropriate action. //if the size has changed, a resize event (noticable to the application) //should happen. Else, we could even start the application s->setConnect(TRUE); // does a bulkShow (setImage) setFont(s->fontNo()); //FIXME: creates flicker? //FIXME: check here if we're still alife. // if not, quit, otherwise, // start propagating quit. title = s->Title(); // take title from current session setHeader(); }
errorCode decodeHeader(EXIStream* strm, boolean outOfBandOpts) { errorCode tmp_err_code = UNEXPECTED_ERROR; unsigned int bits_val = 0; boolean boolVal = FALSE; DEBUG_MSG(INFO, DEBUG_CONTENT_IO, (">Start EXI header decoding\n")); TRY(readBits(strm, 2, &bits_val)); if(bits_val == 2) // The header Distinguishing Bits i.e. no EXI Cookie { strm->header.has_cookie = 0; DEBUG_MSG(INFO, DEBUG_CONTENT_IO, (">No EXI cookie detected\n")); } else if(bits_val == 0)// ASCII code for $ = 00100100 (36) { TRY(readBits(strm, 6, &bits_val)); if(bits_val != 36) return INVALID_EXI_HEADER; TRY(readBits(strm, 8, &bits_val)); if(bits_val != 69) // ASCII code for E = 01000101 (69) return INVALID_EXI_HEADER; TRY(readBits(strm, 8, &bits_val)); if(bits_val != 88) // ASCII code for X = 01011000 (88) return INVALID_EXI_HEADER; TRY(readBits(strm, 8, &bits_val)); if(bits_val != 73) // ASCII code for I = 01001001 (73) return INVALID_EXI_HEADER; strm->header.has_cookie = 1; DEBUG_MSG(INFO, DEBUG_CONTENT_IO, (">EXI cookie detected\n")); TRY(readBits(strm, 2, &bits_val)); if(bits_val != 2) // The header Distinguishing Bits are required return INVALID_EXI_HEADER; } else { return INVALID_EXI_HEADER; } // Read the Presence Bit for EXI Options TRY(readNextBit(strm, &boolVal)); if(boolVal == TRUE) // There are EXI options { strm->header.has_options = TRUE; // validation checks. If the options are included then // they cannot be set by an out-of-band mechanism. // If out-of-band options are set - // rise a warning and overwrite them. // Only the options from the header will be used if(outOfBandOpts == TRUE) { DEBUG_MSG(WARNING, DEBUG_CONTENT_IO, (">Ignored out-of-band set EXI options\n")); makeDefaultOpts(&strm->header.opts); } } else // Out-of-band set EXI options { DEBUG_MSG(INFO, DEBUG_CONTENT_IO, (">No EXI options field in the header\n")); strm->header.has_options = FALSE; if(outOfBandOpts == FALSE) { DEBUG_MSG(ERROR, DEBUG_CONTENT_IO, (">No EXI options in the header and no out-of-band options specified. \n")); return HEADER_OPTIONS_MISMATCH; } } // Read the Version type TRY(readNextBit(strm, &boolVal)); strm->header.is_preview_version = boolVal; strm->header.version_number = 1; do { TRY(readBits(strm, 4, &bits_val)); strm->header.version_number += bits_val; if(bits_val < 15) break; } while(1); DEBUG_MSG(INFO, DEBUG_CONTENT_IO, (">EXI version: %d\n", strm->header.version_number)); if(strm->header.has_options == 1) { Parser optionsParser; struct ops_AppData appD; TRY(initParser(&optionsParser, strm->buffer, &appD)); optionsParser.strm.context.bitPointer = strm->context.bitPointer; optionsParser.strm.context.bufferIndx = strm->context.bufferIndx; optionsParser.strm.gStack = NULL; makeDefaultOpts(&optionsParser.strm.header.opts); SET_STRICT(optionsParser.strm.header.opts.enumOpt); optionsParser.handler.fatalError = ops_fatalError; optionsParser.handler.error = ops_fatalError; optionsParser.handler.startDocument = ops_startDocument; optionsParser.handler.endDocument = ops_endDocument; optionsParser.handler.startElement = ops_startElement; optionsParser.handler.attribute = ops_attribute; optionsParser.handler.stringData = ops_stringData; optionsParser.handler.endElement = ops_endElement; optionsParser.handler.intData = ops_intData; optionsParser.handler.booleanData = ops_boolData; appD.o_strm = &optionsParser.strm; appD.parsed_ops = &strm->header.opts; appD.prevElementLnID = 0; appD.prevElementUriID = 0; appD.permanentAllocList = &strm->memList; TRY_CATCH(setSchema(&optionsParser, (EXIPSchema*) &ops_schema), destroyParser(&optionsParser)); TRY_CATCH(createValueTable(&optionsParser.strm.valueTable), destroyParser(&optionsParser)); while(tmp_err_code == ERR_OK) { tmp_err_code = parseNext(&optionsParser); } destroyParser(&optionsParser); if(tmp_err_code != PARSING_COMPLETE) return tmp_err_code; strm->buffer.bufContent = optionsParser.strm.buffer.bufContent; strm->context.bitPointer = optionsParser.strm.context.bitPointer; strm->context.bufferIndx = optionsParser.strm.context.bufferIndx; if(WITH_COMPRESSION(strm->header.opts.enumOpt) || GET_ALIGNMENT(strm->header.opts.enumOpt) != BIT_PACKED) { // Padding bits if(strm->context.bitPointer != 0) { strm->context.bitPointer = 0; strm->context.bufferIndx += 1; } } } return checkOptionValues(&strm->header.opts); }
static error_code parseIOMsg(char* buf, unsigned int buf_size, BoolValue *val) { Parser lkabParser; BinaryBuffer buffer; errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; struct appDataLKAB parsingData; EXIPSchema lkab_schema; const char *schemafname = "SchemaStrict/lkab-devices-xsd.exi"; buffer.buf = buf; buffer.bufLen = buf_size; buffer.bufContent = buf_size; // Parsing steps: // I.A: First, read in the schema parseSchema(schemafname, &lkab_schema); // I: First, define an external stream for the input to the parser if any buffer.ioStrm.stream = NULL; // II: Second, initialize the parser object tmp_err_code = initParser(&lkabParser, buffer, &parsingData); if(tmp_err_code != EXIP_OK) return tmp_err_code; // III: Initialize the parsing data and hook the callback handlers to the parser object parsingData.currElementNumber = 0; parsingData.val.quality = Good; parsingData.val.val = 0; parsingData.val.ts.year = 0; parsingData.val.ts.month = 0; parsingData.val.ts.mday = 0; parsingData.val.ts.hour = 0; parsingData.val.ts.min = 0; parsingData.val.ts.sec = 0; parsingData.val.ts.msec = 0; lkabParser.handler.fatalError = lkab_fatalError; lkabParser.handler.error = lkab_fatalError; lkabParser.handler.startElement = lkab_startElement_io; lkabParser.handler.stringData = lkab_stringData_io; lkabParser.handler.endElement = lkab_endElement; lkabParser.handler.booleanData = lkab_booleanData_io; lkabParser.handler.dateTimeData = lkab_dateTimeData; // IV: Parse the header of the stream tmp_err_code = parseHeader(&lkabParser, FALSE); tmp_err_code = setSchema(&lkabParser, &lkab_schema); // V: Parse the body of the EXI stream while(tmp_err_code == EXIP_OK) { tmp_err_code = parseNext(&lkabParser); } // VI: Free the memory allocated by the parser object destroyParser(&lkabParser); val->ts = parsingData.val.ts; val->val = parsingData.val.val; val->quality = parsingData.val.quality; if(tmp_err_code == EXIP_PARSING_COMPLETE) return EXIP_OK; else return tmp_err_code; }
errorCode decode(EXIPSchema* schemaPtr, unsigned char outFlag, FILE *infile, size_t (*inputStream)(void* buf, size_t size, void* stream)) { Parser testParser; char buf[INPUT_BUFFER_SIZE]; BinaryBuffer buffer; errorCode tmp_err_code = UNEXPECTED_ERROR; struct appData parsingData; buffer.buf = buf; buffer.bufLen = INPUT_BUFFER_SIZE; buffer.bufContent = 0; // Parsing steps: // I: First, define an external stream for the input to the parser if any, otherwise set to NULL buffer.ioStrm.readWriteToStream = inputStream; buffer.ioStrm.stream = infile; // II: Second, initialize the parser object TRY(initParser(&testParser, buffer, &parsingData)); // III: Initialize the parsing data and hook the callback handlers to the parser object. // If out-of-band options are defined use testParser.strm.header.opts to set them parsingData.expectAttributeData = 0; parsingData.stack = NULL; parsingData.unclosedElement = 0; parsingData.prefixesCount = 0; parsingData.outputFormat = outFlag; testParser.handler.fatalError = sample_fatalError; testParser.handler.error = sample_fatalError; testParser.handler.startDocument = sample_startDocument; testParser.handler.endDocument = sample_endDocument; testParser.handler.startElement = sample_startElement; testParser.handler.attribute = sample_attribute; testParser.handler.stringData = sample_stringData; testParser.handler.endElement = sample_endElement; testParser.handler.decimalData = sample_decimalData; testParser.handler.intData = sample_intData; testParser.handler.floatData = sample_floatData; testParser.handler.booleanData = sample_booleanData; testParser.handler.dateTimeData = sample_dateTimeData; testParser.handler.binaryData = sample_binaryData; // IV: Parse the header of the stream TRY(parseHeader(&testParser, FALSE)); // IV.1: Set the schema to be used for parsing. // The schemaID mode and schemaID field can be read at // parser.strm.header.opts.schemaIDMode and // parser.strm.header.opts.schemaID respectively // If schemaless mode, use setSchema(&parser, NULL); TRY(setSchema(&testParser, schemaPtr)); // V: Parse the body of the EXI stream while(tmp_err_code == ERR_OK) { tmp_err_code = parseNext(&testParser); } // VI: Free the memory allocated by the parser destroyParser(&testParser); if(tmp_err_code == PARSING_COMPLETE) return ERR_OK; else return tmp_err_code; }
void SessionDefaults::setSessionDefaultAttributeValue (SessionDefaultMap sda, char * attrValue, Lng32 attrValueLen) { Lng32 defaultValueAsLong = -1; NABoolean defaultValueAsBoolean = FALSE; if (attrValue) { if (sda.attributeType == SessionDefaults::SDT_BINARY_SIGNED) { ex_expr::exp_return_type rc = convDoIt(attrValue, attrValueLen, REC_BYTE_F_ASCII, 0, 0, (char*)&defaultValueAsLong, sizeof(Lng32), REC_BIN32_SIGNED, 0, 0, NULL, 0); if (rc != ex_expr::EXPR_OK) { return; // error } } else if (sda.attributeType == SessionDefaults::SDT_BOOLEAN) { if ((strcmp(attrValue, "ON") == 0) || (strcmp(attrValue, "TRUE") == 0)) defaultValueAsBoolean = TRUE; } } switch (sda.attribute) { case AQR_ENTRIES: { aqrInfo()->setAQREntriesFromInputStr(attrValue, attrValueLen); } break; case AUTO_QUERY_RETRY_WARNINGS: { if (defaultValueAsBoolean) setAQRWarnings(1); else setAQRWarnings(0); } break; case DBTR_PROCESS: { setDbtrProcess(defaultValueAsBoolean); } break; case MXCMP_PRIORITY: { setMxcmpPriority(defaultValueAsLong); } break; case MXCMP_PRIORITY_DELTA: { setMxcmpPriorityDelta(defaultValueAsLong); } break; case ESP_PRIORITY: { setEspPriority(defaultValueAsLong); } break; case ESP_PRIORITY_DELTA: { setEspPriorityDelta(defaultValueAsLong); } break; case ESP_FIXUP_PRIORITY: { setEspFixupPriority(defaultValueAsLong); } break; case ESP_FIXUP_PRIORITY_DELTA: { setEspFixupPriorityDelta(defaultValueAsLong); } break; case ESP_ASSIGN_DEPTH: { setEspAssignDepth(defaultValueAsLong); } break; case ESP_ASSIGN_TIME_WINDOW: { setEspAssignTimeWindow(defaultValueAsLong); } break; case ESP_STOP_IDLE_TIMEOUT: { setEspStopIdleTimeout(defaultValueAsLong); } break; case ESP_IDLE_TIMEOUT: { setEspIdleTimeout(defaultValueAsLong); } break; case COMPILER_IDLE_TIMEOUT: { setCompilerIdleTimeout(defaultValueAsLong); } break; case ESP_INACTIVE_TIMEOUT: { setEspInactiveTimeout(defaultValueAsLong); } break; case ESP_RELEASE_WORK_TIMEOUT: { setEspReleaseWorkTimeout(defaultValueAsLong); } break; case MAX_POLLING_INTERVAL: { setMaxPollingInterval(defaultValueAsLong); } break; case PERSISTENT_OPENS: { setPersistentOpens(defaultValueAsLong); } break; case ESP_CLOSE_ERROR_LOGGING: { setEspCloseErrorLogging(defaultValueAsBoolean); } break; case CATALOG: { setCatalog(attrValue, attrValueLen); }; break; case SCHEMA: { setSchema(attrValue, attrValueLen); }; break; case USE_LIBHDFS: { setUseLibHdfs(defaultValueAsBoolean); } break; case USER_EXPERIENCE_LEVEL: { setUEL(attrValue, attrValueLen); }; break; case RTS_TIMEOUT: { setRtsTimeout(defaultValueAsLong); } break; case ALTPRI_MASTER: { setAltpriMaster(defaultValueAsBoolean); } break; case ALTPRI_MASTER_SEQ_EXE: { setAltpriMasterSeqExe(defaultValueAsBoolean); } break; case ALTPRI_FIRST_FETCH: { setAltpriFirstFetch(defaultValueAsBoolean); } break; case ALTPRI_ESP: { setAltpriEsp(defaultValueAsBoolean); } break; case INTERNAL_FORMAT_IO: { setInternalFormatIO(defaultValueAsBoolean); } break; case ISO_MAPPING: { if (attrValueLen != strlen(SQLCHARSETSTRING_ISO88591) || strcmp(attrValue, SQLCHARSETSTRING_ISO88591) != 0) { // Ignore the specified ISO_MAPPING setting } setIsoMappingName(SQLCHARSETSTRING_ISO88591, strlen(SQLCHARSETSTRING_ISO88591)); } break; case PARENT_QID: setParentQid(attrValue, attrValueLen); break; case PARENT_QID_SYSTEM: setParentQidSystem(attrValue, attrValueLen); break; case WMS_PROCESS: setWmsProcess(defaultValueAsBoolean); break; case ESP_FREEMEM_TIMEOUT: { setEspFreeMemTimeout(defaultValueAsLong); } break; case STATISTICS_VIEW_TYPE: setStatisticsViewType(defaultValueAsLong); break; case RECLAIM_MEMORY_AFTER: setReclaimTotalMemorySize(defaultValueAsLong); break; case RECLAIM_FREE_MEMORY_RATIO: setReclaimFreeMemoryRatio(defaultValueAsLong); break; case RECLAIM_FREE_PFS_RATIO: setReclaimFreePFSRatio(defaultValueAsLong); break; case CANCEL_ESCALATION_INTERVAL: { setCancelEscalationInterval(defaultValueAsLong); } break; case CANCEL_ESCALATION_MXOSRVR_INTERVAL: { setCancelEscalationMxosrvrInterval(defaultValueAsLong); } break; case CANCEL_ESCALATION_SAVEABEND: { setCancelEscalationSaveabend(defaultValueAsBoolean); } break; case CANCEL_LOGGING: { setCancelLogging(defaultValueAsBoolean); } break; case CANCEL_QUERY_ALLOWED: { setCancelQueryAllowed(defaultValueAsBoolean); } break; case CANCEL_UNIQUE_QUERY: { setCancelUniqueQuery(defaultValueAsBoolean); } break; case SUSPEND_LOGGING: { setSuspendLogging(defaultValueAsBoolean); } break; case CALL_EMBEDDED_ARKCMP: { setCallEmbeddedArkcmp(defaultValueAsBoolean); } break; default: { } break; }; }
END_TEST /* Verifies a single global element also used as a reference. */ START_TEST (test_acceptance_for_A_01_exip1) { EXIPSchema schema; FILE *infile; Parser testParser; char buf[INPUT_BUFFER_SIZE]; const char *schemafname = "testStates/acceptance-xsd.exi"; const char *exifname = "testStates/acceptance_a_01a.exi"; char exipath[MAX_PATH_LEN + strlen(exifname)]; struct appData parsingData; errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; BinaryBuffer buffer; buffer.buf = buf; buffer.bufContent = 0; buffer.bufLen = INPUT_BUFFER_SIZE; // Parsing steps: // I.A: First, read in the schema parseSchema(schemafname, &schema); // I.B: Define an external stream for the input to the parser if any size_t pathlen = strlen(dataDir); memcpy(exipath, dataDir, pathlen); exipath[pathlen] = '/'; memcpy(&exipath[pathlen+1], exifname, strlen(exifname)+1); infile = fopen(exipath, "rb" ); if(!infile) fail("Unable to open file %s", exipath); buffer.ioStrm.readWriteToStream = readFileInputStream; buffer.ioStrm.stream = infile; // II: Second, initialize the parser object tmp_err_code = initParser(&testParser, buffer, &parsingData); fail_unless (tmp_err_code == EXIP_OK, "initParser returns an error code %d", tmp_err_code); // III: Initialize the parsing data and hook the callback handlers to the parser object parsingData.eventCount = 0; parsingData.expectAttributeData = 0; if (EXIP_OK != initAllocList(&parsingData.allocList)) fail("Memory allocation error!"); testParser.handler.fatalError = sample_fatalError; testParser.handler.error = sample_fatalError; testParser.handler.startDocument = sample_startDocument; testParser.handler.endDocument = sample_endDocument; testParser.handler.startElement = sample_startElement; testParser.handler.attribute = sample_attribute; testParser.handler.stringData = sample_stringData; testParser.handler.endElement = sample_endElement; testParser.handler.decimalData = sample_decimalData; testParser.handler.intData = sample_intData; testParser.handler.floatData = sample_floatData; // IV: Parse the header of the stream tmp_err_code = parseHeader(&testParser, FALSE); fail_unless (tmp_err_code == EXIP_OK, "parsing the header returns an error code %d", tmp_err_code); tmp_err_code = setSchema(&testParser, &schema); fail_unless (tmp_err_code == EXIP_OK, "setSchema() returns an error code %d", tmp_err_code); // V: Parse the body of the EXI stream while(tmp_err_code == EXIP_OK) { switch (parsingData.eventCount) { case 0: fail_unless(stringEqualToAscii(parsingData.eventCode, "SD")); break; case 1: fail_unless(stringEqualToAscii(parsingData.eventCode, "SE")); fail_unless(stringEqualToAscii(parsingData.uri, "urn:foo")); fail_unless(stringEqualToAscii(parsingData.localName, "AB")); break; case 2: fail_unless(stringEqualToAscii(parsingData.eventCode, "CH")); break; case 3: fail_unless(stringEqualToAscii(parsingData.eventCode, "EE")); break; case 4: fail_unless(stringEqualToAscii(parsingData.eventCode, "ED")); break; default: // Unexpected event count caught below. break; } tmp_err_code = parseNext(&testParser); parsingData.eventCount++; } fail_unless(stringEqualToAscii(parsingData.eventCode, "ED")); fail_unless(parsingData.eventCount == 4, "Unexpected event count: %u", parsingData.eventCount); // VI: Free the memory allocated by the parser object freeAllocList(&parsingData.allocList); destroyParser(&testParser); fclose(infile); fail_unless (tmp_err_code == EXIP_PARSING_COMPLETE, "Error during parsing of the EXI body %d", tmp_err_code); }
static error_code parseDevDescMsg(char* buf, unsigned int buf_size, DevDescribtion* devDesc) { Parser lkabParser; BinaryBuffer buffer; errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; struct appDataLKAB parsingData; EXIPSchema lkab_schema; const char *schemafname = "SchemaStrict/lkab-devices-xsd.exi"; buffer.buf = buf; buffer.bufLen = buf_size; buffer.bufContent = buf_size; // Parsing steps: // I.A: First, read in the schema parseSchema(schemafname, &lkab_schema); // I: First, define an external stream for the input to the parser if any buffer.ioStrm.stream = NULL; // II: Second, initialize the parser object tmp_err_code = initParser(&lkabParser, buffer, &parsingData); if(tmp_err_code != EXIP_OK) return tmp_err_code; // III: Initialize the parsing data and hook the callback handlers to the parser object parsingData.currElementNumber = 0; parsingData.devDesc.id[0] = '\0'; parsingData.devDesc.location[0] = '\0'; parsingData.devDesc.name[0] = '\0'; parsingData.devDesc.type[0] = '\0'; parsingData.devDesc.processValue.description[0] = '\0'; parsingData.devDesc.processValue.name[0] = '\0'; parsingData.devDesc.processValue.isReadOnly = 0; parsingData.devDesc.processValue.type = Bool; lkabParser.handler.fatalError = lkab_fatalError; lkabParser.handler.error = lkab_fatalError; lkabParser.handler.startElement = lkab_startElement_desc; lkabParser.handler.stringData = lkab_stringData_desc; lkabParser.handler.endElement = lkab_endElement; lkabParser.handler.booleanData = lkab_booleanData_desc; // IV: Parse the header of the stream tmp_err_code = parseHeader(&lkabParser, FALSE); tmp_err_code = setSchema(&lkabParser, &lkab_schema); // V: Parse the body of the EXI stream while(tmp_err_code == EXIP_OK) { tmp_err_code = parseNext(&lkabParser); } // VI: Free the memory allocated by the parser object destroyParser(&lkabParser); strcpy(devDesc->id, parsingData.devDesc.id); strcpy(devDesc->location, parsingData.devDesc.location); strcpy(devDesc->name, parsingData.devDesc.name); strcpy(devDesc->type, parsingData.devDesc.type); strcpy(devDesc->processValue.description, parsingData.devDesc.processValue.description); strcpy(devDesc->processValue.name, parsingData.devDesc.processValue.name); devDesc->processValue.isReadOnly = parsingData.devDesc.processValue.isReadOnly; devDesc->processValue.type = parsingData.devDesc.processValue.type; if(tmp_err_code == EXIP_PARSING_COMPLETE) return EXIP_OK; else return tmp_err_code; }
END_TEST START_TEST (test_noLearning02) { EXIStream testStrm; Parser testParser; String uri; String ln; QName qname= {&uri, &ln}; String chVal; char buf[OUTPUT_BUFFER_SIZE]; errorCode tmp_err_code = EXIP_UNEXPECTED_ERROR; BinaryBuffer buffer; EXITypeClass valueType; buffer.buf = buf; buffer.bufContent = 0; buffer.bufLen = OUTPUT_BUFFER_SIZE; buffer.ioStrm.readWriteToStream = NULL; buffer.ioStrm.stream = NULL; // Serialization steps: // I: First initialize the header of the stream serialize.initHeader(&testStrm); // II: Set any options in the header, if different from the defaults testStrm.header.has_options = TRUE; testStrm.header.opts.schemaIDMode = SCHEMA_ID_EMPTY; // III: Define an external stream for the output if any // IV: Initialize the stream tmp_err_code = serialize.initStream(&testStrm, buffer, NULL); fail_unless (tmp_err_code == EXIP_OK, "initStream returns an error code %d", tmp_err_code); // V: Start building the stream step by step: header, document, element etc... tmp_err_code = serialize.exiHeader(&testStrm); fail_unless (tmp_err_code == EXIP_OK, "serialize.exiHeader returns an error code %d", tmp_err_code); tmp_err_code = serialize.startDocument(&testStrm); fail_unless (tmp_err_code == EXIP_OK, "serialize.startDocument returns an error code %d", tmp_err_code); getEmptyString(&uri); tmp_err_code += asciiToString("root", &ln, &testStrm.memList, FALSE); tmp_err_code += serialize.startElement(&testStrm, qname, &valueType); fail_unless (tmp_err_code == EXIP_OK, "serialize.startElement returns an error code %d", tmp_err_code); tmp_err_code += asciiToString("a", &ln, &testStrm.memList, FALSE); tmp_err_code += serialize.startElement(&testStrm, qname, &valueType); fail_unless (tmp_err_code == EXIP_OK, "serialize.startElement returns an error code %d", tmp_err_code); tmp_err_code += asciiToString("bla", &chVal, &testStrm.memList, FALSE); tmp_err_code += serialize.stringData(&testStrm, chVal); fail_unless (tmp_err_code == EXIP_OK, "serialize.stringData returns an error code %d", tmp_err_code); tmp_err_code += serialize.endElement(&testStrm); tmp_err_code += asciiToString("b", &ln, &testStrm.memList, FALSE); tmp_err_code += serialize.startElement(&testStrm, qname, &valueType); fail_unless (tmp_err_code == EXIP_OK, "serialize.startElement returns an error code %d", tmp_err_code); tmp_err_code += asciiToString("23", &chVal, &testStrm.memList, FALSE); tmp_err_code += serialize.stringData(&testStrm, chVal); fail_unless (tmp_err_code == EXIP_OK, "serialize.stringData returns an error code %d", tmp_err_code); tmp_err_code += serialize.endElement(&testStrm); tmp_err_code += asciiToString("a", &ln, &testStrm.memList, FALSE); tmp_err_code += serialize.startElement(&testStrm, qname, &valueType); fail_unless (tmp_err_code == EXIP_OK, "serialize.startElement returns an error code %d", tmp_err_code); tmp_err_code += asciiToString("bla", &chVal, &testStrm.memList, FALSE); tmp_err_code += serialize.stringData(&testStrm, chVal); fail_unless (tmp_err_code == EXIP_OK, "serialize.stringData returns an error code %d", tmp_err_code); tmp_err_code += serialize.endElement(&testStrm); tmp_err_code += asciiToString("c", &ln, &testStrm.memList, FALSE); tmp_err_code += serialize.startElement(&testStrm, qname, &valueType); fail_unless (tmp_err_code == EXIP_OK, "serialize.startElement returns an error code %d", tmp_err_code); tmp_err_code += asciiToString("b", &ln, &testStrm.memList, FALSE); tmp_err_code += serialize.startElement(&testStrm, qname, &valueType); fail_unless (tmp_err_code == EXIP_OK, "serialize.startElement returns an error code %d", tmp_err_code); tmp_err_code += asciiToString("http://www.w3.org/2001/XMLSchema-instance", &uri, &testStrm.memList, FALSE); tmp_err_code += asciiToString("type", &ln, &testStrm.memList, FALSE); tmp_err_code += serialize.attribute(&testStrm, qname, TRUE, &valueType); fail_unless (tmp_err_code == EXIP_OK, "serialize.attribute returns an error code %d", tmp_err_code); tmp_err_code += asciiToString("http://www.w3.org/2001/XMLSchema", &uri, &testStrm.memList, FALSE); tmp_err_code += asciiToString("integer", &ln, &testStrm.memList, FALSE); tmp_err_code += serialize.qnameData(&testStrm, qname); fail_unless (tmp_err_code == EXIP_OK, "serialize.qnameData returns an error code %d", tmp_err_code); tmp_err_code += serialize.intData(&testStrm, 66); fail_unless (tmp_err_code == EXIP_OK, "serialize.stringData returns an error code %d", tmp_err_code); tmp_err_code += serialize.endElement(&testStrm); tmp_err_code += serialize.endElement(&testStrm); tmp_err_code += serialize.endElement(&testStrm); tmp_err_code += serialize.endDocument(&testStrm); if(tmp_err_code != EXIP_OK) fail_unless (tmp_err_code == EXIP_OK, "serialization ended with error code %d", tmp_err_code); // V: Free the memory allocated by the EXI stream object tmp_err_code = serialize.closeEXIStream(&testStrm); fail_unless (tmp_err_code == EXIP_OK, "serialize.closeEXIStream ended with error code %d", tmp_err_code); buffer.bufContent = OUTPUT_BUFFER_SIZE; // Parsing steps: // I: First, define an external stream for the input to the parser if any // II: Second, initialize the parser object tmp_err_code = initParser(&testParser, buffer, NULL); fail_unless (tmp_err_code == EXIP_OK, "initParser returns an error code %d", tmp_err_code); // III: Initialize the parsing data and hook the callback handlers to the parser object // IV: Parse the header of the stream tmp_err_code = parseHeader(&testParser, TRUE); fail_unless (tmp_err_code == EXIP_OK, "parsing the header returns an error code %d", tmp_err_code); tmp_err_code = setSchema(&testParser, NULL); fail_unless (tmp_err_code == EXIP_OK, "setSchema() returns an error code %d", tmp_err_code); // V: Parse the body of the EXI stream while(tmp_err_code == EXIP_OK) { tmp_err_code = parseNext(&testParser); } // VI: Free the memory allocated by the parser object destroyParser(&testParser); fail_unless (tmp_err_code == EXIP_PARSING_COMPLETE, "Error during parsing of the EXI body %d", tmp_err_code); }
BaseParser :: BaseParser(SGMLScanner * aScanner, TSchemaPtr aSchema) { mScanner = aScanner; setSchema(aSchema); }
/*============================================================================== Конструктор по умолчанию. tableName - имя таблицы, для которой создается модель записи ==============================================================================*/ Model::Model(QString tableName, QObject *parent) : QObject(parent), schema(tableName) { setSchema(tableName); }
void TEDemo::setSchema(int numb) { ColorSchema* s = ColorSchema::find(numb); if (s) setSchema(s); }
static void *XoReadExiCommon(struct ioStream *ioStr, char *roottype,int flags,int *err) { Parser testParser; struct appData parsingData; char buf[INPUT_BUFFER_SIZE]; BinaryBuffer buffer; errorCode tmp_err_code = UNEXPECTED_ERROR; memset (&parsingData,0,sizeof(parsingData)); parsingData.ctxt.roottype = roottype; parsingData.ctxt.flags = flags; parsingData.ctxt.ns.flags = flags; parsingData.parser = &testParser; _XoAllocCtxt(&parsingData.ctxt); buffer.buf = buf; buffer.bufLen = INPUT_BUFFER_SIZE; buffer.bufContent = 0; // Parsing steps: // I: First, define an external stream for the input to the parser if any buffer.ioStrm = *ioStr; // II: Second, initialize the parser object #if EXIP_VERSION==276 tmp_err_code = initParser(&testParser, buffer, g_schemaPtr, &parsingData); #endif #if EXIP_VERSION>=289 tmp_err_code = initParser(&testParser, buffer, &parsingData); #endif if(tmp_err_code != ERR_OK) { _XoFreeCtxt(&parsingData.ctxt); return NULL; } // III: Initialize the parsing data and hook the callback handlers to the parser object parsingData.expectAttributeData = 0; parsingData.stack = NULL; parsingData.unclosedElement = 0; parsingData.prefixesCount = 0; testParser.handler.fatalError = sample_fatalError; testParser.handler.error = sample_fatalError; testParser.handler.startDocument = sample_startDocument; testParser.handler.endDocument = sample_endDocument; testParser.handler.startElement = sample_startElement; testParser.handler.attribute = sample_attribute; testParser.handler.stringData = sample_stringData; testParser.handler.endElement = sample_endElement; testParser.handler.decimalData = sample_decimalData; testParser.handler.intData = sample_intData; testParser.handler.floatData = sample_floatData; testParser.handler.booleanData = sample_booleanData; testParser.handler.dateTimeData = sample_dateTimeData; testParser.handler.binaryData = sample_binaryData; testParser.handler.qnameData = sample_qnameData; #if EXIP_VERSION==276 testParser.handler.retrieveSchema = sample_retrieveSchema; #endif // IV: Parse the header of the stream tmp_err_code = parseHeader(&testParser, FALSE); #if EXIP_VERSION>=289 // IV.1: Set the schema to be used for parsing. // The schemaID mode and schemaID field can be read at // parser.strm.header.opts.schemaIDMode and // parser.strm.header.opts.schemaID respectively // If schemaless mode, use setSchema(&parser, NULL); EXIPSchema *schemaPtr = sample_retrieveSchema(&parsingData); setSchema(&testParser, schemaPtr); #endif //_lookupSchema(); // V: Parse the body of the EXI stream while(tmp_err_code == ERR_OK) { tmp_err_code = parseNext(&testParser); PRINT ("parseNext ret=%d\n", tmp_err_code); } // PCA parsingData.xo_obj = parsingData.ctxt.obj[0]; // VI: Free the memory allocated by the parser and schema object destroyParser(&testParser); _XoFreeCtxt(&parsingData.ctxt); PRINT ("End parsing xo_obj=%p\n", parsingData.xo_obj); return parsingData.xo_obj; }
void TEDemo::setSchema(const char* path) { ColorSchema* s = ColorSchema::find(path); if (s) setSchema(s); }
void GadgetTreeReader::iterate(gadget::Node* parent, libember::glow::GlowElementCollection* collection) { if (collection != nullptr) { auto const last = std::end(*collection); for(auto it = std::begin(*collection); it != last; ++it) { auto& child = *it; auto const type = ber::Type::fromTag(child.typeTag()); if (type.isApplicationDefined()) { if (type.value() == GlowType::Node) { auto& glownode = *dynamic_cast<GlowNode*>(&child); auto node = gadget::NodeFactory::createNode(parent, glownode.identifier()); node->setDescription(glownode.description()); node->setSchema(glownode.schemaIdentifiers()); iterate(node, glownode.children()); } else if (type.value() == GlowType::Parameter) { auto& glowparam = dynamic_cast<GlowParameter&>(child); auto identifier = glowparam.identifier(); auto paramtype = glowparam.effectiveType(); switch(paramtype.value()) { case libember::glow::ParameterType::Boolean: transform(gadget::ParameterFactory::create(parent, identifier, false), &glowparam); break; case libember::glow::ParameterType::Enum: transform(gadget::ParameterFactory::create(parent, identifier), &glowparam); break; case libember::glow::ParameterType::Integer: transform(gadget::ParameterFactory::create(parent, identifier, 0, 1000, 0), &glowparam); break; case libember::glow::ParameterType::Octets: break; case libember::glow::ParameterType::Real: transform(gadget::ParameterFactory::create(parent, identifier, 0.0, 1000.0, 0.0), &glowparam); break; case libember::glow::ParameterType::String: transform(gadget::ParameterFactory::create(parent, identifier, std::string("text")), &glowparam); break; case libember::glow::ParameterType::Trigger: break; default: volatile int x = paramtype.value(); break; } } } } } }