void get_links(char ***lines, t_room **rlst) { char **links; t_room *tmp; int i; i = 0; while (lines && *lines && **lines && (strchr(**lines, '-'))) { i = 0; while (lines && ***lines == '#') (*lines)++; links = ft_strsplit(**lines, '-'); tmp = dictionary(links[0], &rlst); (tmp->links)[len(tmp->links)] = ft_strdup(links[1]); if (tmp && contains(tmp, links[1])) free((tmp->links)[len(tmp->links)]); tmp = dictionary(links[1], &rlst); (tmp->links)[len(tmp->links)] = ft_strdup(links[1]); if (tmp && contains(tmp, links[0])) free((tmp->links)[len(tmp->links)]); (*lines)++; free(links); } tmp->links[len(tmp->links)] = 0; }
void PppDownScriptWriter::fill() { dictionary()->SetValue(OBJECTNAME, QCoreApplication::instance()->objectName().toAscii().constData()); dictionary()->SetValue(GETIPSECINFOLIB, ConfWriter::fileName(ConfWriter::GETIPSECINFO).toAscii().constData()); const ConnectionSettings settings; const int iConnections = settings.connections(); for (int i = 0; i < iConnections; i++) { const QString strName(settings.connection(i)); if (!strName.isEmpty()) { const PppIpSettings ipSetting(settings.pppSettings(strName).ipSettings()); ctemplate::TemplateDictionary* const pConnection = dictionary()->AddSectionDictionary(CONN_SECTION); pConnection->SetValue(IPPARAM, (QCoreApplication::instance()->objectName() + "-" + strName).toAscii().constData()); pConnection->SetValue(GATEWAY, settings.ipsecSettings(strName).gateway().toAscii().constData()); if (ipSetting.useDefaultGateway()) pConnection->AddSectionDictionary(DEFAULT_GATEWAY_SECTION); } else addErrorMsg(QObject::tr("No such connection: '%1'.").arg(strName)); } }
Foam::foamChemistryReader<ThermoType>::foamChemistryReader ( const dictionary& thermoDict ) : chemistryReader<ThermoType>(), speciesThermo_ ( IFstream ( fileName(thermoDict.lookup("foamChemistryThermoFile")).expand() )() ), speciesTable_ ( dictionary ( IFstream ( fileName(thermoDict.lookup("foamChemistryFile")).expand() )() ).lookup("species") ), reactions_ ( dictionary ( IFstream ( fileName(thermoDict.lookup("foamChemistryFile")).expand() )() ).lookup("reactions"), typename Reaction<ThermoType>::iNew(speciesTable_, speciesThermo_) ) {}
void KSpellConfig::fillInDialog () { if ( nodialog ) return; kdDebug(750) << "KSpellConfig::fillinDialog" << endl; cb1->setChecked( noRootAffix() ); cb2->setChecked( runTogether() ); encodingcombo->setCurrentItem( encoding() ); clientcombo->setCurrentItem( client() ); // get list of available dictionaries if ( iclient == KS_CLIENT_ISPELL ) getAvailDictsIspell(); else if ( iclient == KS_CLIENT_HSPELL ) { langfnames.clear(); dictcombo->clear(); langfnames.append(""); // Default dictcombo->insertItem( i18n("Hebrew") ); } else if ( iclient == KS_CLIENT_ZEMBEREK ) { langfnames.clear(); dictcombo->clear(); langfnames.append(""); dictcombo->insertItem( i18n("Turkish") ); } else getAvailDictsAspell(); // select the used dictionary in the list int whichelement=-1; if ( dictFromList() ) whichelement = langfnames.findIndex(dictionary()); dictcombo->setMinimumWidth (dictcombo->sizeHint().width()); if (dictionary().isEmpty() || whichelement!=-1) { setDictFromList (true); if (whichelement!=-1) dictcombo->setCurrentItem(whichelement); } else // Current dictionary vanished, present the user with a default if possible. if ( !langfnames.empty() ) { setDictFromList( true ); dictcombo->setCurrentItem(0); } else setDictFromList( false ); sDictionary( dictFromList() ); sPathDictionary( !dictFromList() ); }
Foam::foamChemistryReader<ThermoType>::foamChemistryReader ( const fileName& reactionsFileName, const fileName& thermoFileName ) : chemistryReader<ThermoType>(), speciesThermo_(IFstream(thermoFileName)()), speciesTable_(dictionary(IFstream(reactionsFileName)()).lookup("species")), reactions_ ( dictionary(IFstream(reactionsFileName)()).lookup("reactions"), Reaction<ThermoType>::iNew(speciesTable_, speciesThermo_) ) {}
void NIVissimDistrictConnection::dict_BuildDistrictNodes(NBDistrictCont& dc, NBNodeCont& nc) { for (std::map<int, std::vector<int> >::iterator k = myDistrictsConnections.begin(); k != myDistrictsConnections.end(); k++) { // get the connections const std::vector<int>& connections = (*k).second; // retrieve the current district std::string dsid = toString<int>((*k).first); NBDistrict* district = new NBDistrict(dsid); dc.insert(district); // compute the middle of the district PositionVector pos; for (std::vector<int>::const_iterator j = connections.begin(); j != connections.end(); j++) { NIVissimDistrictConnection* c = dictionary(*j); pos.push_back(c->geomPosition()); } Position distCenter = pos.getPolygonCenter(); if (connections.size() == 1) { // !!! ok, ok, maybe not the best way just to add an offset distCenter.add(10, 10); } district->setCenter(distCenter); // build the node std::string id = "District" + district->getID(); NBNode* districtNode = new NBNode(id, district->getPosition(), district); if (!nc.insert(districtNode)) { throw 1; } } }
void bPdfIn::doc(const char* filename) { // place cursor in the end of file: file.open(filename, std::fstream::in | std::fstream::ate); if(!file) throw "Cannot open PDF file."; // Following little hack leads us directly to the end of "startxref" keyword. char chr = '\0'; do { file.seekg(-2, std::ios::cur); if(chr == 'f') break; } while(file.get(chr)); bPdf::getline(file); // go to the next line - with xref position std::string xrefPosStr; xrefPosStr = bPdf::getline(file); size_t xrefPos = std::atoi(xrefPosStr.c_str()); if( xrefPos == 0 ) throw "bPdfIn was unable to find xref position, probably not a Pdf file."; // Load the cross-reference table. Dictionary of xref stream will be received. dictionary lastTrailer = loadXref(xrefPos); // Load trailer and previous xref tables and trailers if file was updated. Tables are loaded // in reversed chronological order so most recent entry for each object will come first for // bPdf::getObjPos(). Old trailers are all discarded. while(true) { if(lastTrailer["/Type"] != "/XRef") { // loadXref() left cursor one line after the last entry of the table. We should go back // to extract trailer (when there is no EOL after "trailer" keyword). chr = ' '; do { if(chr == '\n' || chr == '\r') break; file.seekg(-2, std::ios::cur); } while(file.get(chr)); lastTrailer = bPdf::unrollDict( extractObject() ); } // if lastTrailer["/Type"] != "/XRef" if(trailer.empty()) trailer = lastTrailer; if(lastTrailer.count("/XRefStm") != 0) // hybrid-reference file loadXref((size_t) atoi(lastTrailer["/XRefStm"].c_str())); if(lastTrailer.count("/Prev") == 0) break; dictionary xrefDict = loadXref( (size_t)atoi(lastTrailer["/Prev"].c_str()) ); lastTrailer = xrefDict.empty() ? dictionary() : xrefDict; } if(xrefSections.size() == 0) throw "bPdfIn was unable to find any cross-reference tables in file!"; }
EncodedJSValue JSC_HOST_CALL JSKeyboardEventConstructor::constructJSKeyboardEvent(ExecState* exec) { JSKeyboardEventConstructor* jsConstructor = jsCast<JSKeyboardEventConstructor*>(exec->callee()); ScriptExecutionContext* executionContext = jsConstructor->scriptExecutionContext(); if (!executionContext) return throwVMError(exec, createReferenceError(exec, "Constructor associated execution context is unavailable")); AtomicString eventType = exec->argument(0).toString(exec)->value(exec); if (exec->hadException()) return JSValue::encode(jsUndefined()); KeyboardEventInit eventInit; JSValue initializerValue = exec->argument(1); if (!initializerValue.isUndefinedOrNull()) { // Given the above test, this will always yield an object. JSObject* initializerObject = initializerValue.toObject(exec); // Create the dictionary wrapper from the initializer object. JSDictionary dictionary(exec, initializerObject); // Attempt to fill in the EventInit. if (!fillKeyboardEventInit(eventInit, dictionary)) return JSValue::encode(jsUndefined()); } RefPtr<KeyboardEvent> event = KeyboardEvent::create(eventType, eventInit); return JSValue::encode(toJS(exec, jsConstructor->globalObject(), event.get())); }
int main(int argc, char **argv) { std::string source("/var/www/spellCorrect/data/big.txt"); std::string destion("/var/www/spellCorrect/data/dictionary.txt"); CreateDictionary dictionary(source, destion); return 0 ; }
static PassRefPtr<PositionOptions> createPositionOptions(ExecState* exec, JSValue value) { // Create default options. RefPtr<PositionOptions> options = PositionOptions::create(); // Argument is optional (hence undefined is allowed), and null is allowed. if (value.isUndefinedOrNull()) { // Use default options. return options.release(); } // Given the above test, this will always yield an object. JSObject* object = value.toObject(exec); // Create the dictionary wrapper from the initializer object. JSDictionary dictionary(exec, object); if (!dictionary.tryGetProperty("enableHighAccuracy", options.get(), setEnableHighAccuracy)) return 0; if (!dictionary.tryGetProperty("timeout", options.get(), setTimeout)) return 0; if (!dictionary.tryGetProperty("maximumAge", options.get(), setMaximumAge)) return 0; return options.release(); }
void apostropheTest() { SmartKey::SmartKeyDictionary dictionary(g_settings); dictionary.loadSkippedCharsFromFile("/var/tmp/key_skipped"); dictionary.loadEquivalencesFromFile("/var/tmp/key_equiv"); dictionary.loadTermsFromFile("/var/tmp/key_dict_us"); //dictionary.insert("talk", 413); /* dictionary.insert("y'all", 3); dictionary.insert("yskk", 4); dictionary.insert("y'akk", 6); dictionary.insert("y'dork", 5); dictionary.print(); */ printf("%s: number of nodes: %d\n", __FUNCTION__, dictionary.getNodeCount()); /* dictionary.insert("thats", 10); dictionary.insert("that's", 11); dictionary.insert("that''s", 12); */ ///test(dictionary, "thats", "that's"); test(dictionary, "yall", "y'all"); }
//Программа ConvertHtml int main(int argc, char* argv[]) { try { Check ch(argc, argv); //проверка введенных аргументов с консоли } catch (int e) { if (e==0) { cout << "Ошибка: в командной строке должно быть 2 или 3 аргумента, читайте документацию" << endl; return -1; } if (e==1) { cout << "Ошибка: первый и второй файл д.б. с расширением .txt" << endl; return -1; } if (e==2) { cout << "3-й аргумент д.б. числом" << endl; return -1; } } set<string> setDictionary; //множество для хранения словаря try { LoadDictionary dictionary(argv[1]); //создаем объект словарь, передавая ссылку по аргументу setDictionary = dictionary.getDictionary(); //загружаем словарь } catch (int e) { if (e==0) { cout << "Ошибка, файл больше 2 Mb"; return -1; } if (e==1) { cout << "Ошибка, в словаре больше 100 000 строк"; return -1; } } catch (...) { cout << "Что-то пошло не так" ; return -1; } try { ConvertToHtml convert(setDictionary, argv[2]); //создаем объект convert, передавая ссылку по аргументу convert.modifyText(); //изменям текст из файла convert.buildHtml(); //генерируем HTML файлы } catch (int e) { if (e==0) { cout << "Ошибка, файл больше 2 Mb"; return -1; } } catch (...) { cout << "Что-то пошло не так" ; return -1; } cout << "Файлы HTML успешно сгенерированы" << endl; return 0; }
dictionary load_dictionary (string from, string to) { string name= from * "-" * to; if (dictionary::instances -> contains (name)) return dictionary (name); dictionary dict= tm_new<dictionary_rep> (from, to); if (from != to) dict->load (name); return dict; }
void bigDictSmallSearchTest() { SmartKey::SmartKeyDictionary dictionary(g_settings); dictionary.loadSkippedCharsFromFile("/var/tmp/key_skipped"); dictionary.loadTermsFromFile("/var/tmp/key_dict_us"); dictionary.loadEquivalencesFromFile("/var/tmp/key_equiv"); test(dictionary, "ofrss", "ideas"); }
Foam::interpolation2DTable<Type>::interpolation2DTable(const fileName& fName) : List<Tuple2<scalar, List<Tuple2<scalar, Type> > > >(), boundsHandling_(interpolation2DTable::WARN), fileName_(fName), reader_(new openFoamTableReader<Type>(dictionary())) { readTable(); }
bool NIVissimVehicleType::dictionary(int id, const std::string& name, const std::string& category, const RGBColor& color) { NIVissimVehicleType* o = new NIVissimVehicleType(name, category, color); if (!dictionary(id, o)) { delete o; return false; } return true; }
void NIVissimDistrictConnection::dict_CheckEdgeEnds() { for (std::map<int, std::vector<int> >::iterator k = myDistrictsConnections.begin(); k != myDistrictsConnections.end(); k++) { const std::vector<int>& connections = (*k).second; for (std::vector<int>::const_iterator j = connections.begin(); j != connections.end(); j++) { NIVissimDistrictConnection* c = dictionary(*j); c->checkEdgeEnd(); } } }
LrDpleToDple* LrDpleToDple::clone() const { // Return a deep copy std::map<std::string, std::vector<Sparsity> > tmp; tmp["a"] = st_[LR_Dple_STRUCT_A]; tmp["v"] = st_[LR_Dple_STRUCT_V]; tmp["c"] = st_[LR_Dple_STRUCT_C]; tmp["h"] = st_[LR_Dple_STRUCT_H]; LrDpleToDple* node = new LrDpleToDple(tmp); node->setOption(dictionary()); return node; }
bool NIVissimVehTypeClass::dictionary(int id, const std::string& name, const RGBColor& color, std::vector<int>& types) { NIVissimVehTypeClass* o = new NIVissimVehTypeClass(id, name, color, types); if (!dictionary(id, o)) { delete o; return false; } return true; }
bool NIVissimTrafficDescription::dictionary(int id, const std::string& name, const NIVissimVehicleClassVector& vehicleTypes) { NIVissimTrafficDescription* o = new NIVissimTrafficDescription(id, name, vehicleTypes); if (!dictionary(id, o)) { delete o; return false; } return true; }
static void TestBitmapHeap(skiatest::Reporter* reporter) { // Create a bitmap shader. SkBitmap bm; bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); bm.allocPixels(); bm.eraseColor(SK_ColorRED); uint32_t* pixel = bm.getAddr32(1,0); *pixel = SK_ColorBLUE; SkShader* bitmapShader = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, SkShader::kRepeat_TileMode); SkAutoTUnref<SkShader> aur(bitmapShader); // Flatten, storing it in the bitmap heap. SkBitmapHeap heap(1, 1); SkChunkFlatController controller(1024); controller.setBitmapStorage(&heap); FlatDictionary dictionary(&controller); // Dictionary and heap start off empty. REPORTER_ASSERT(reporter, heap.count() == 0); REPORTER_ASSERT(reporter, dictionary.count() == 0); heap.deferAddingOwners(); int index = dictionary.find(*bitmapShader); heap.endAddingOwnersDeferral(true); // The dictionary and heap should now each have one entry. REPORTER_ASSERT(reporter, 1 == index); REPORTER_ASSERT(reporter, heap.count() == 1); REPORTER_ASSERT(reporter, dictionary.count() == 1); // The bitmap entry's refcount should be 1, then 0 after release. SkBitmapHeapEntry* entry = heap.getEntry(0); REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(entry) == 1); entry->releaseRef(); REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(entry) == 0); // Now clear out the heap, after which it should be empty. heap.freeMemoryIfPossible(~0U); REPORTER_ASSERT(reporter, heap.count() == 0); // Now attempt to flatten the shader again. heap.deferAddingOwners(); index = dictionary.find(*bitmapShader); heap.endAddingOwnersDeferral(false); // The dictionary should report the same index since the new entry is identical. // The bitmap heap should contain the bitmap, but with no references. REPORTER_ASSERT(reporter, 1 == index); REPORTER_ASSERT(reporter, heap.count() == 1); REPORTER_ASSERT(reporter, SkBitmapHeapTester::GetRefCount(heap.getEntry(0)) == 0); }
void PppUpScriptWriter::fill() { dictionary()->SetValue(OBJECTNAME, QCoreApplication::instance()->objectName().toAscii().constData()); dictionary()->SetValue(GETIPSECINFOLIB, ConfWriter::fileName(ConfWriter::GETIPSECINFO).toAscii().constData()); const ConnectionSettings settings; const int iConnections = settings.connections(); for (int i = 0; i < iConnections; i++) { ctemplate::TemplateDictionary* const pConnection = dictionary()->AddSectionDictionary(CONN_SECTION); const QString strName(settings.connection(i)); if (!strName.isEmpty()) { pConnection->SetValue(IPPARAM, (QCoreApplication::instance()->objectName() + "-" + strName).toAscii().constData()); pConnection->SetValue(GATEWAY, settings.ipsecSettings(strName).gateway().toAscii().constData()); const PppIpSettings ipSetting(settings.pppSettings(strName).ipSettings()); if (!ipSetting.useDefaultGateway()) { ctemplate::TemplateDictionary* const pDefaultRoute = pConnection->AddSectionDictionary(ROUTE_SECTION); pDefaultRoute->SetValue(IPADDRESS, "`echo \"${PPP_LOCAL}\" | cut -d'.' -f1`.0.0.0"); pDefaultRoute->SetValue(IPNETMASK, "255.0.0.0"); const int iRoutes = ipSetting.routes(); for (int j = 0; j < iRoutes; j++) { ctemplate::TemplateDictionary* const pRoute = pConnection->AddSectionDictionary(ROUTE_SECTION); pRoute->SetValue(IPADDRESS, ipSetting.routeAddress(j).toAscii().constData()); pRoute->SetValue(IPNETMASK, ipSetting.routeNetmask(j).toAscii().constData()); } } else pConnection->AddSectionDictionary(DEFAULT_GATEWAY_SECTION); } else addErrorMsg(QObject::tr("No such connection: '%1'.").arg(strName)); } }
bool NIVissimClosures::dictionary(const std::string& id, int from_node, int to_node, std::vector<int>& overEdges) { NIVissimClosures* o = new NIVissimClosures(id, from_node, to_node, overEdges); if (!dictionary(id, o)) { delete o; return false; } return true; }
bool NIVissimDisturbance::dictionary(const std::string& name, const NIVissimExtendedEdgePoint& edge, const NIVissimExtendedEdgePoint& by) { int nid = myRunningID++; NIVissimDisturbance* o = new NIVissimDisturbance(nid, name, edge, by); if (!dictionary(nid, o)) { delete o; } return true; }
v8::Handle<v8::Value> WebDocument::registerEmbedderCustomElement(const WebString& name, v8::Handle<v8::Value> options, WebExceptionCode& ec) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); Document* document = unwrap<Document>(); Dictionary dictionary(options, isolate); TrackExceptionState exceptionState; ScriptValue constructor = document->registerElement(ScriptState::current(isolate), name, dictionary, exceptionState, CustomElement::EmbedderNames); ec = exceptionState.code(); if (exceptionState.hadException()) return v8::Handle<v8::Value>(); return constructor.v8Value(); }
bool NIVissimSource::dictionary(const std::string& id, const std::string& name, const std::string& edgeid, SUMOReal q, bool exact, int vehicle_combination, SUMOReal beg, SUMOReal end) { NIVissimSource* o = new NIVissimSource(id, name, edgeid, q, exact, vehicle_combination, beg, end); if (!dictionary(id, o)) { delete o; return false; } return true; }
GslInternal* GslInternal::clone() const{ // Return a deep copy Function f = deepcopy(f_); Function q = deepcopy(q_); GslInternal* node = new GslInternal(f,q); node->setOption(dictionary()); node->jac_f_ = deepcopy(jac_f_); node->dt_f_ = deepcopy(dt_f_); if(!node->is_init) node->init(); return node; }
StateMachine::StateMachine( const dictionary &dict, const fvMesh &mesh ): driver_( CommonValueExpressionDriver::New( dict, mesh ) ), mesh_(mesh), names_( dict.lookup("states") ), machineName_( dict.lookup("machineName") ), initialState_( stateCode( word(dict.lookup("initialState")) ) ), state_(initialState_), lastStateChange_( mesh.time().value() ), stepsSinceChange_(0), changedTo_( names_.size(), 0 ) { driver_->createWriterAndRead( "StateMachine_"+machineName_+"_"+dict.name().name() ); List<dictionary> data( dict.lookup("transitions") ); transitions_.resize(data.size()); forAll(data,i) { transitions_.set( i, new StateTransition( *this, dictionary( dict, data[i] ) ) ); }
Foam::IOerror::operator Foam::dictionary() const { dictionary errDict(error::operator dictionary()); errDict.remove("type"); errDict.add("type", word("Foam::IOerror")); errDict.add("ioFileName", ioFileName()); errDict.add("ioStartLineNumber", ioStartLineNumber()); errDict.add("ioEndLineNumber", ioEndLineNumber()); return errDict; }
void ArgumentCoder<ResourceResponse>::encode(ArgumentEncoder* encoder, const ResourceResponse& resourceResponse) { #if USE(CFNETWORK) bool responseIsPresent = resourceResponse.cfURLResponse(); encoder->encode(responseIsPresent); if (!responseIsPresent) return; RetainPtr<CFDictionaryRef> dictionary(AdoptCF, wkCFURLResponseCreateSerializableRepresentation(resourceResponse.cfURLResponse(), CoreIPC::tokenNullTypeRef())); CoreIPC::encode(encoder, dictionary.get()); #endif }