bool RegExpFilterFieldsParameterMapper::getValueWithSlotname(const char *key, String const &strSlotname, Context & ctx, ValueType & value, ROAnything script) { StartTrace1(RegExpFilterFieldsParameterMapper.getValueWithSlotname, "key [" << NotNull(key) << "] slotname [" << strSlotname << "]"); String strNewKey = key; if (Lookup(_CombineKeyName, 1L) != 0) { strNewKey.Append(getDelim()).Append(strSlotname); } Anything slotnameBuffer = strSlotname, combinedKeyBuffer = strNewKey; Context::PushPopEntry<Anything> aSlotnameEntry(ctx, "CurrentSlotname", slotnameBuffer, _CurrentSlotname); Context::PushPopEntry<Anything> aCombinedEntry(ctx, "CombinedKey", combinedKeyBuffer, _CombinedKeyName); return doGetValue(strNewKey, value, ctx, script); }
void AP_UnixDialog_Lists::loadXPDataIntoLocal(void) { // // This function reads the various memeber variables and loads them into // into the dialog variables. // // // Block all signals while setting these things // XAP_GtkSignalBlocker b1( G_OBJECT(m_oAlignList_adj), m_iAlignListSpinID); XAP_GtkSignalBlocker b2( G_OBJECT(m_oIndentAlign_adj), m_iIndentAlignSpinID); XAP_GtkSignalBlocker b3( G_OBJECT(m_wDecimalEntry), m_iDecimalEntryID); XAP_GtkSignalBlocker b4( G_OBJECT(m_wDelimEntry), m_iDelimEntryID ); // // HACK to effectively block an update during this method // m_bDontUpdate = true; UT_DEBUGMSG(("loadXP newListType = %d \n",getNewListType())); gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_wAlignListSpin),getfAlign()); float indent = getfAlign() + getfIndent(); gtk_spin_button_set_value(GTK_SPIN_BUTTON( m_wIndentAlignSpin),indent); if( (getfIndent() + getfAlign()) < 0.0) { setfIndent( - getfAlign()); gtk_spin_button_set_value(GTK_SPIN_BUTTON( m_wIndentAlignSpin), 0.0); } // // Code to work out which is active Font // if(getFont() == "NULL") { gtk_combo_box_set_active(m_wFontOptions, 0 ); } else { size_t i = 0; for(std::vector<std::string>::const_iterator iter = m_glFonts.begin(); iter != m_glFonts.end(); ++iter, ++i) { if(*iter == getFont()) break; } if(i < m_glFonts.size()) { gtk_combo_box_set_active(m_wFontOptions, i + 1 ); } else { gtk_combo_box_set_active(m_wFontOptions, 0 ); } } gtk_spin_button_set_value(GTK_SPIN_BUTTON(m_wStartSpin),static_cast<float>(getiStartValue())); gtk_entry_set_text( GTK_ENTRY(m_wDecimalEntry), getDecimal().c_str()); gtk_entry_set_text( GTK_ENTRY(m_wDelimEntry), getDelim().c_str()); // // Now set the list type and style FL_ListType save = getNewListType(); if(getNewListType() == NOT_A_LIST) { styleChanged(0); setNewListType(save); gtk_combo_box_set_active(m_wListTypeBox, 0); gtk_combo_box_set_active(m_wListStyleBox, 0); } else if(IS_BULLETED_LIST_TYPE(getNewListType()) ) { styleChanged(1); setNewListType(save); gtk_combo_box_set_active(m_wListTypeBox, 1); gtk_combo_box_set_active(m_wListStyleBox, (gint) (getNewListType() - BULLETED_LIST)); } else { styleChanged(2); setNewListType(save); gtk_combo_box_set_active(m_wListTypeBox, 2); if(getNewListType() < OTHER_NUMBERED_LISTS) { gtk_combo_box_set_active(m_wListStyleBox, getNewListType()); } else { gint iMenu = static_cast<gint>(getNewListType()) - OTHER_NUMBERED_LISTS + BULLETED_LIST -1 ; gtk_combo_box_set_active(m_wListStyleBox,iMenu); } } // // HACK to allow an update during this method // m_bDontUpdate = false; }
void detectData(const string& dataFile, Asset*& calls, Asset*& puts, const string& writeTo, long lastDate, double lastByte){ //function used to detect data if data contains the cp_flag //function returns number of bytes extracted. ifstream inFile(dataFile.c_str()); // object for handling file input string row; stringstream srow; getline(inFile,row); srow.str(row); //replace old row with new row; //used to find out what column I am in, and thus what deque to extract the data to. Columns columnHeaders; //instantiate an object of Columns class. //find out if we are using a european or american style csv file. Following conditions char delimiter = getDelim(row, dataFile); columnHeaders.setColNbr(srow, delimiter); //set column numbers columnHeaders.checkValid(dataFile); //check if data is valid according to column numbers int cpColNbr = columnHeaders.getCpColNbr(); string callOrPutRow; //used to determine what type of option is contained in row int i = 0; //used for collOrPutRow if ((calls == NULL)){ // we initialize here the proper options objects to contain our data. This is done only at the beginning of a file. vector<Asset**>dummyAssets; dummyAssets.push_back(&calls); dummyAssets.push_back(&puts);//just a dummy assets used for initiateAsset. columnHeaders.initiateAsset(dummyAssets, dataFile); //find what the Assets object will point to depending on the rows identity. //uses pointer to pointer, so that the copy made automatically is not a copy of our pointer to initialize, but a copy to //the pointer to those addresses. calls->setExFromByte((double)inFile.tellg()); //skip first line for rest of code as I am starting at beginning of file. //!!!!information has to be set in both objects. puts->setExFromByte((double)inFile.tellg()); calls->setWriteTo(writeTo); //setting folder to write to, using data passed as argument to detectData. puts->setWriteTo(writeTo); } //we first detect what type of options object we are dealing with //and save all the data to two single deques of row objects in order to sort columns in parallel. bool optionsOrNot = calls->getIsOption(); //////////////////////////////////////////////////////////////////// //if Options data was entered, find out what kind of options it was. //////////////////////////////////////////////////////////////////// if (optionsOrNot == true) { //Skip to wanted position, after first line if new file, and as of last accessed byte //if return file. inFile.seekg(calls->getExFromByte(), ios_base::beg); double before = time(0); while ((inFile.eof() != 1)){ //while I am in the file getline(inFile, row); //get next line. srow.clear(); //clear eofbit set from last line. srow.str(row); //replace old row with new row. for(i = 0; i < cpColNbr; ++i) getline(srow, callOrPutRow, delimiter); srow.seekg(0); //reset row for srow if(callOrPutRow.find("C") != string::npos){ //we have a call calls->extractRow(srow, delimiter); //row is extracted and put in temporary values //line is now completely extracted. Now dealing with file size and multiple files part if(calls->fileSizeManagement(lastDate, lastByte, inFile) == true){ //file read status set only for calls. puts->setExToDate(calls->getExToDate()); puts->setExFromByte(calls->getExFromByte()); break; //break only if member function returned to break, otherwise, do nothing. } calls->writeCurrValues(); } else{ puts->extractRow(srow, delimiter); //row is extracted and put in temporary values //line is now completely extracted. Now dealing with file size and multiple files part if(puts->fileSizeManagement(lastDate, lastByte, inFile) == true){ //file read status set only for calls. calls->setExToDate(puts->getExToDate()); calls->setExFromByte(puts->getExFromByte()); break; //break only if member function returned to break, otherwise, do nothing. } puts->writeCurrValues(); } //Done with dealing with filesize and multiple files part. } cout << "It took " << time(0) - before << " seconds to extract " << endl; before = time(0); calls->addExRows(); puts->addExRows(); before = time(0); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Program will quickly sort the data. This is currently done whether data needs sorting or not. //So that all the times where data is already sorted, there is no need to even go through the deque of objects. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// calls->sortData(); puts->sortData(); cout << "It took " << time(0) - before << " seconds to sort " << endl; before = time(0); //just setting the strikeDivisor here, should run just fine. if(calls->getStrikeDivisor() == 0) calls->setStrikeDivisor(); if(puts->getStrikeDivisor() == 0) puts->setStrikeDivisor(); calls->setIsCall(true); //or 1 puts->setIsCall(false); //or 0 calls->setDataFile(dataFile); //setting path to file data will be extracted form. puts->setDataFile(dataFile); //has to be done after setIsCall is done. } else{ //This is not an *Options object. Undefined for now. } }
void detectData(const string& dataFile, Asset*& pAsset, const string& writeTo, long lastDate, double lastByte){ //function used to detect data if data contains the cp_flag //function returns number of bytes extracted. ifstream inFile(dataFile.c_str()); // object for handling file input string row; stringstream srow; getline(inFile,row); srow.str(row); //replace old row with new row; //used to find out what column I am in, and thus what deque to extract the data to. Columns columnHeaders; //instantiate an objects of Columns class. //find out if we are using a european or american style csv file. Following conditions char delimiter = getDelim(row, dataFile); columnHeaders.setColNbr(srow, delimiter); //set column numbers //columnHeaders.checkValid(dataFile); //check if data is valid according to column numbers if ((pAsset == NULL)){ // we initialize here the proper options objects to contain our data. This is done only at the beginning of a file. vector<Asset**>dummyAssets; dummyAssets.push_back(&pAsset);//just a dummy assets used for initiateAsset. columnHeaders.initiateAsset(dummyAssets, dataFile); //find what the Asset object will point to depending on the rows identity. pAsset->setExFromByte((double)inFile.tellg()); //skip first line for rest of code as I am starting at beginning of file. //!!!!information is arbitrarily set in the pAsset object pAsset->setWriteTo(writeTo); //setting folder to write to, using data passed as argument to detectData. } //we first detect what type of options object we are dealing with //and save all the data to two single deques of row objects in order to sort columns in parallel. bool optionsOrNot = pAsset->getIsOption(); //////////////////////////////////////////////////////////////////// //if Options data was entered, find out what kind of options it was. //////////////////////////////////////////////////////////////////// if (optionsOrNot == true) { //Skip to wanted position, after first line if new file, and as of last accessed byte //if return file. inFile.seekg(pAsset->getExFromByte(), ios_base::beg); while ((inFile.eof() != 1)){ //while I am in the file getline(inFile, row); //get next line. srow.clear(); //clear eofbit set from last line. srow.str(row); //replace old row with new row. pAsset->extractRow(srow, delimiter); //row is extracted and put in temporary //values of of calls object (arbitrarily), could as well be puts. if(pAsset->fileSizeManagement(lastDate, lastByte, inFile)) //Now dealing with file size and multiple files part break; //only break if returned to. pAsset->writeCurrValues(); } //end of while(inFile.eof() != 1) loop. pAsset->addExRows(); //Now that deques are filled, sort them as wanted. pAsset->sortData(); if(pAsset->getStrikeDivisor() == 0) pAsset->setStrikeDivisor(); pAsset->setCallStatus(); } else{ //This is not an *Options object. //Skip to wanted position, after first line if new file, and as of last accessed byte //if return file. inFile.seekg(pAsset->getExFromByte(), ios_base::beg); while ((inFile.eof() != 1)){ //while I am in the file getline(inFile, row); //get next line. srow.clear(); //clear eofbit set from last line. srow.str(row); //replace old row with new row. pAsset->extractRow(srow, delimiter); //row is extracted and put in temporary //values of object ////////////////////////////////////////////////////////////////////////////////////// //line is now completely extracted. Now dealing with file size and multiple files part ////////////////////////////////////////////////////////////////////////////////////// if(pAsset->fileSizeManagement(lastDate, lastByte, inFile)) break; //only break if returned to pAsset->writeCurrValues(); //push_back all deques containing our data in the structure of our objects } //end of while(inFile.eof() != 1) loop. } pAsset->addExRows(); pAsset->setDataFile(dataFile); //setting path to file data will be extracted form. //extraction is finished }
bool HTTPHeaderFieldParameterMapper::DoGetStream(const char *key, std::ostream &os, Context &ctx, ROAnything info) { StartTrace1(HTTPHeaderFieldParameterMapper.DoGetStream, "Key:<" << NotNull(key) << ">"); Anything fieldValues; //! break potential loop here when our own DoGetAny is calling us ParameterMapper::DoGetAny(key, fieldValues, ctx, SelectScript(key, fConfig, ctx)); String potentiallyCombinedKey = key; TraceAny(fieldValues, "field values available for full key [" << potentiallyCombinedKey << "]"); String headerFieldName = potentiallyCombinedKey.SubString(potentiallyCombinedKey.StrRChr(getDelim()) + 1).ToUpper(); Trace("field name only [" << headerFieldName << "]"); if (!fieldValues.IsNull()) { coast::http::putHeaderFieldToStream(os, ctx, headerFieldName, fieldValues); } return true; }