StaticTopo::StaticTopo(Beetle &beetle, std::string staticMappingsFile) : beetle(beetle) { if (!file_exists(staticMappingsFile)) { throw std::invalid_argument("static mappings file does not exist - " + staticMappingsFile); } std::cout << "static topology file: " << staticMappingsFile << std::endl; std::ifstream ifs(staticMappingsFile); std::string line; while (std::getline(ifs, line)) { std::string mapping = line; if (mapping.find('#') != mapping.npos) { mapping = mapping.substr(0, mapping.find('#')); } trim(mapping); if (mapping == "") { continue; } // heavy handed way boost::char_separator<char> sep { "\t" }; boost::tokenizer<boost::char_separator<char>> tokenizer { mapping, sep }; std::string from; std::string to; int i = 0; for (const auto &t : tokenizer) { switch (i) { case 0: from = trimmed(t); break; case 1: to = trimmed(t); break; default: throw ParseExecption("extraneous token - " + t); } i++; } if (i < 2) { throw ParseExecption("could not parse - " + line); } if (from == to) { throw ParseExecption("cannot map device to itself! - " + line); } staticMappings[from].insert(to); } for (auto &kv : staticMappings) { for (auto &to : kv.second) { std::cout << " " << kv.first << " -> " << to << std::endl; } } }
int SynonymsDict::import(const char* filename) { std::istream *is; //std::map<std::string, size_t> rKeys; //std::map<std::string, size_t> lKeys; is = new std::ifstream(filename); if (! *is) return -1; std::string line; std::string lKey,rKey; size_t offset = 1; char txtHead[3] = {239,187,191}; //load while (std::getline(*is, line)) { //for each line. if(line.size()<4) continue; if(line[0]=='/' && line[1]=='/') continue; int pos = line.find("=>"); if(pos == -1) continue; //=>not found. size_t lKey_offset = 0; if(memcmp(line.c_str(),txtHead,sizeof(char)*3) == 0) lKey = trimmed(line.substr(3,pos-3)," \t" ); else lKey = trimmed(line.substr(0,pos)," \t" ); rKey = trimmed(line.substr(pos+2)," \t" ); if(lKey.size() == 0 || rKey.size() == 0) continue; //all key loaded. //check rKey std::map<std::string ,size_t>::iterator it = rKeys.find(rKey); if(it == rKeys.end()) { lKey_offset = offset; rKeys.insert(std::map<std::string, size_t>::value_type(rKey, offset)); offset += rKey.size() + 1; //0 term }else{ lKey_offset = it->second; } //check lKey it = lKeys.find(lKey); if(it == lKeys.end()) { lKeys.insert(std::map<std::string, size_t>::value_type(lKey, lKey_offset)); }else{ //dup left Keys! skip. } } //end while //done m_string_pool_size = offset; delete is; return 0; }
string StringManager::getProperty(string toFilter, string property){ string value = "NOT FOUND"; std::istringstream stream(toFilter); std::string line; while (std::getline(stream, line)) { if(getSubString(line,":", true).compare(property) == 0){ return trimmed(value = getSubString(line, ":", false)); } } return trimmed(value); }
bool nuiNativeResourceVolume::GetPathInfo(const nglPath& rPath, nglPathInfo& rInfo) { nglString tmp = rPath.GetVolumeLessPath(); nglPath path(tmp); tmp.TrimLeft(L'/'); nglPath trimmed(tmp); if (!path.GetPathName().Compare(_T("/"))) { // we act like this is a folder rInfo.Exists = true; ///< Node existence. All other fields are invalid if set to false. rInfo.IsLeaf = false; ///< Leaf (file or assimilable) or non-leaf (folder) rInfo.CanRead = true; ///< True if the file (leaf) can be read or the folder (non-leaf) can be traversed and its content listed rInfo.CanWrite = false; ///< True if the file (leaf) can be written to or a new node can be created in this folder (non-leaf) rInfo.LastAccess = 0; ///< nglTime stamp of last access (read or exec) rInfo.LastMod = 0; ///< nglTime stamp of last modification (write) rInfo.Size = 0; ///< If the node is a leaf, size in bytes. If non-leaf, always zero. rInfo.Visible = true; ///< Always visible... return true; } std::map<nglPath, std::set<nglString> >::const_iterator it = mItems.find(trimmed); if (it != mItems.end()) { // This is a folder rInfo.Exists = true; ///< Node existence. All other fields are invalid if set to false. rInfo.IsLeaf = false; ///< Leaf (file or assimilable) or non-leaf (folder) rInfo.CanRead = true; ///< True if the file (leaf) can be read or the folder (non-leaf) can be traversed and its content listed rInfo.CanWrite = false; ///< True if the file (leaf) can be written to or a new node can be created in this folder (non-leaf) rInfo.LastAccess = 0; ///< nglTime stamp of last access (read or exec) rInfo.LastMod = 0; ///< nglTime stamp of last modification (write) rInfo.Size = 0; ///< If the node is a leaf, size in bytes. If non-leaf, always zero. rInfo.Visible = true; ///< Always visible... return true; } nuiNativeResource* pRes = new nuiNativeResource(path); if (pRes && pRes->IsValid()) { // This is a file rInfo.Exists = true; ///< Node existence. All other fields are invalid if set to false. rInfo.IsLeaf = true; ///< Leaf (file or assimilable) or non-leaf (folder) rInfo.CanRead = true; ///< True if the file (leaf) can be read or the folder (non-leaf) can be traversed and its content listed rInfo.CanWrite = false; ///< True if the file (leaf) can be written to or a new node can be created in this folder (non-leaf) rInfo.LastAccess = 0; ///< nglTime stamp of last access (read or exec) rInfo.LastMod = 0; ///< nglTime stamp of last modification (write) rInfo.Size = pRes->Available(); ///< If the node is a leaf, size in bytes. If non-leaf, always zero. rInfo.Visible = true; ///< Always visible... delete pRes; return true; } delete pRes; return false; }
void AvatarBookmarks::addBookmark() { ModalDialogListener* dlg = OffscreenUi::getTextAsync(OffscreenUi::ICON_PLACEMARK, "Bookmark Avatar", "Name", QString()); connect(dlg, &ModalDialogListener::response, this, [=] (QVariant response) { disconnect(dlg, &ModalDialogListener::response, this, nullptr); auto bookmarkName = response.toString(); bookmarkName = bookmarkName.trimmed().replace(QRegExp("(\r\n|[\r\n\t\v ])+"), " "); if (bookmarkName.length() == 0) { return; } auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar(); const QString& avatarUrl = myAvatar->getSkeletonModelURL().toString(); const QVariant& avatarScale = myAvatar->getAvatarScale(); // If Avatar attachments ever change, this is where to update them, when saving remember to also append to AVATAR_BOOKMARK_VERSION QVariantMap bookmark; bookmark.insert(ENTRY_VERSION, AVATAR_BOOKMARK_VERSION); bookmark.insert(ENTRY_AVATAR_URL, avatarUrl); bookmark.insert(ENTRY_AVATAR_SCALE, avatarScale); bookmark.insert(ENTRY_AVATAR_ATTACHMENTS, myAvatar->getAttachmentsVariant()); bookmark.insert(ENTRY_AVATAR_ENTITIES, myAvatar->getAvatarEntitiesVariant()); Bookmarks::addBookmarkToFile(bookmarkName, bookmark); }); }
void Bookmarks::bookmarkLocation() { bool ok = false; auto bookmarkName = OffscreenUi::getText(OffscreenUi::ICON_PLACEMARK, "Bookmark Location", "Name", QString(), &ok); if (!ok) { return; } bookmarkName = bookmarkName.trimmed().replace(QRegExp("(\r\n|[\r\n\t\v ])+"), " "); if (bookmarkName.length() == 0) { return; } auto addressManager = DependencyManager::get<AddressManager>(); QString bookmarkAddress = addressManager->currentAddress().toString(); Menu* menubar = Menu::getInstance(); if (contains(bookmarkName)) { auto offscreenUi = DependencyManager::get<OffscreenUi>(); auto duplicateBookmarkMessage = offscreenUi->createMessageBox(OffscreenUi::ICON_WARNING, "Duplicate Bookmark", "The bookmark name you entered already exists in your list.", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); duplicateBookmarkMessage->setProperty("informativeText", "Would you like to overwrite it?"); auto result = offscreenUi->waitForMessageBoxResult(duplicateBookmarkMessage); if (result != QMessageBox::Yes) { return; } removeLocationFromMenu(menubar, bookmarkName); } addLocationToMenu(menubar, bookmarkName, bookmarkAddress); insert(bookmarkName, bookmarkAddress); // Overwrites any item with the same bookmarkName. enableMenuItems(true); }
QList<HtmlToken> HtmlFilter::tokenize(const QString &text) const { QString out = prepare(text); QList<HtmlToken> tokens; tokenize(out, tokens); out.clear(); if (m_optimize) optimize(tokens); for (int i = tokens.size() - 1; i >= 0; --i) { const HtmlToken &token = tokens.at(i); if ((token.type == HtmlToken::EndTag || token.type == HtmlToken::StartTag) && token.tag == LS("span")) { tokens.removeAt(i); } } if (m_sizeLimit > 0) { for (int i = 0; i < tokens.size(); ++i) { m_size += tokens.at(i).text.size(); if (m_size > m_sizeLimit) { truncate(tokens, i); break; } } } trimmed(tokens); return tokens; }
void MSMessageEmitter::setWriteEvents(std::string& events) { std::string tmp; StringTokenizer st(events, ";"); while (st.hasNext()) { tmp = trimmed(st.next()); if (tmp == "lanechange") { #ifdef _DEBUG std::cout << "set event '" + tmp + "' to true" << std::endl; #endif MSMessageEmitter::writeLCEvent = true; } else if (tmp == "break") { #ifdef _DEBUG std::cout << "set event '" + tmp + "' to true" << std::endl; #endif MSMessageEmitter::writeBEvent = true; } else if (tmp == "heartbeat") { #ifdef _DEBUG std::cout << "set event '" + tmp + "' to true" << std::endl; #endif MSMessageEmitter::writeHBEvent = true; } else { std::cout << "unknown event '" + tmp + "', skipping" << std::endl; } } }
HCWR::HCWR(string input, int maxIterations, int maxRestarts) { this->maxIterations = maxIterations; this->maxRestarts = maxRestarts; this->input = input; // Open the input file //ifstream inputFile (input.c_str()); //istream inputFile = cin; //if ( ! inputFile.is_open()) //{ // exit(1); //} // Parse it string line; string number; vector< vector<int> > distances; // Stores distances matrix //while (getline(inputFile, line)) while (getline(cin, line)) { if (trimmed(line, " \t") == "") { continue; } stringstream linestream(line); vector<int> row; while (linestream >> number) { row.push_back(atoi(number.c_str())); } distances.push_back(row); row.clear(); } // We can now initialize our RTTP instance this->rttp = new RTTP(distances.size(), (2 * (distances.size() - 1) + OFF_DAYS), MAX_CONSECUTIVE_OFF_DAYS, MAX_CONSECUTIVE_GAMES, MAX_CONSECUTIVE_AWAY_GAMES); // Set costs for (size_t i = 0; i < distances.size(); i++) { for (size_t j = 0; j < distances.size(); j++) { int test = distances[i][j]; this->rttp->setIndividualCost(i, j, test); } distances[i].clear(); } // Done distances.clear(); this->continue_iterating = true; }
void Bookmarks::deleteBookmark() { QStringList bookmarkList; QList<QAction*> menuItems = _bookmarksMenu->actions(); for (int i = 0; i < menuItems.count(); ++i) { bookmarkList.append(menuItems[i]->text()); } bool ok = false; auto bookmarkName = OffscreenUi::getItem(OffscreenUi::ICON_PLACEMARK, "Delete Bookmark", "Select the bookmark to delete", bookmarkList, 0, false, &ok); if (!ok) { return; } bookmarkName = bookmarkName.trimmed(); if (bookmarkName.length() == 0) { return; } removeBookmarkFromMenu(Menu::getInstance(), bookmarkName); remove(bookmarkName); if (_bookmarksMenu->actions().count() == 0) { enableMenuItems(false); } }
void DatapickerImagePrivate::updateFileName() { WAIT_CURSOR; q->isLoaded = false; const QString& address = fileName.trimmed(); if ( !address.isEmpty() ) { if (uploadImage(address)) { q->initSceneParameters(); fileName = address; } } else { //hide segments if they are visible q->m_segments->setSegmentsVisible(false); } QList<DatapickerPoint*> childPoints = q->parentAspect()->children<DatapickerPoint>(AbstractAspect::Recursive | AbstractAspect::IncludeHidden); if (childPoints.count()) { foreach(DatapickerPoint* point, childPoints) point->remove(); } emit q->requestUpdate(); emit q->requestUpdateActions(); RESET_CURSOR; }
void MetaSema::actOnShellCommand(llvm::StringRef commandLine) const { llvm::StringRef trimmed(commandLine.trim(" \t\n\v\f\r ")); if (!trimmed.empty()) { int ret = std::system(trimmed.str().c_str()); (void) ret; // Silence warning unused return result of system. } }
QUrl PodcastService::fixUrl(const QString &url) { QString trimmed(url.trimmed()); // Thanks gpodder! static QMap<QString, QString> prefixMap; if (prefixMap.isEmpty()) { prefixMap.insert(QLatin1String("fb:"), QLatin1String("http://feeds.feedburner.com/%1")); prefixMap.insert(QLatin1String("yt:"), QLatin1String("http://www.youtube.com/rss/user/%1/videos.rss")); prefixMap.insert(QLatin1String("sc:"), QLatin1String("http://soundcloud.com/%1")); prefixMap.insert(QLatin1String("fm4od:"), QLatin1String("http://onapp1.orf.at/webcam/fm4/fod/%1.xspf")); prefixMap.insert(QLatin1String("ytpl:"), QLatin1String("http://gdata.youtube.com/feeds/api/playlists/%1")); } QMap<QString, QString>::ConstIterator it(prefixMap.constBegin()); QMap<QString, QString>::ConstIterator end(prefixMap.constEnd()); for (; it!=end; ++it) { if (trimmed.startsWith(it.key())) { trimmed=it.value().arg(trimmed.mid(it.key().length())); } } if (!trimmed.contains(QLatin1String("://"))) { trimmed.prepend(QLatin1String("http://")); } return fixUrl(QUrl(trimmed)); }
void GrassField::cleanup(){ u32 trimmed(0), nullptrs(0); auto trim = [&trimmed, &nullptrs](){ for(i32 i=noOfpatchData-1; i>=0; i--){ if(patchDataOwner[i] == nullptr){ noOfpatchData--; trimmed++; nullptrs++; // log("trimmed:", i); } else return; } }; auto overwritePatchData = [](i32 from, i32 to){ patchData[to] = patchData[from]; std::swap(patchDataOwner[to], patchDataOwner[from]); for(auto &p : patchDataOwner[to]->fieldIds) if(p == from){ p = to; return; } }; trim(); for(i32 i=0; i<noOfpatchData; i++){ if(patchDataOwner[i] == nullptr){ overwritePatchData(noOfpatchData-1, i); trim(); } } patchData.resize(noOfpatchData); patchDataOwner.resize(noOfpatchData); }
void populate_tree(xmlNode *cur_node, xml_node &node) { for (; cur_node; cur_node = cur_node->next ) { switch (cur_node->type) { case XML_ELEMENT_NODE: { xml_node &new_node = node.add_child((const char *)cur_node->name, cur_node->line, false); append_attributes(cur_node->properties, new_node); populate_tree(cur_node->children, new_node); } break; case XML_TEXT_NODE: { std::string trimmed((const char*)cur_node->content); mapnik::util::trim(trimmed); if (trimmed.empty()) break; //Don't add empty text nodes node.add_child(trimmed, cur_node->line, true); } break; case XML_COMMENT_NODE: break; default: break; } } }
void BIconButton::TrimIcon(bool keepAspect) { if (fNormalBitmap == NULL) return; uint8* bits = (uint8*)fNormalBitmap->Bits(); uint32 bpr = fNormalBitmap->BytesPerRow(); uint32 width = fNormalBitmap->Bounds().IntegerWidth() + 1; uint32 height = fNormalBitmap->Bounds().IntegerHeight() + 1; BRect trimmed(INT32_MAX, INT32_MAX, INT32_MIN, INT32_MIN); for (uint32 y = 0; y < height; y++) { uint8* b = bits + 3; bool rowHasAlpha = false; for (uint32 x = 0; x < width; x++) { if (*b) { rowHasAlpha = true; if (x < trimmed.left) trimmed.left = x; if (x > trimmed.right) trimmed.right = x; } b += 4; } if (rowHasAlpha) { if (y < trimmed.top) trimmed.top = y; if (y > trimmed.bottom) trimmed.bottom = y; } bits += bpr; } if (!trimmed.IsValid()) return; if (keepAspect) { float minInset = trimmed.left; minInset = min_c(minInset, trimmed.top); minInset = min_c(minInset, fNormalBitmap->Bounds().right - trimmed.right); minInset = min_c(minInset, fNormalBitmap->Bounds().bottom - trimmed.bottom); trimmed = fNormalBitmap->Bounds().InsetByCopy(minInset, minInset); } trimmed = trimmed & fNormalBitmap->Bounds(); BBitmap trimmedBitmap(trimmed.OffsetToCopy(B_ORIGIN), B_BITMAP_NO_SERVER_LINK, B_RGBA32); bits = (uint8*)fNormalBitmap->Bits(); bits += 4 * (int32)trimmed.left + bpr * (int32)trimmed.top; uint8* dst = (uint8*)trimmedBitmap.Bits(); uint32 trimmedWidth = trimmedBitmap.Bounds().IntegerWidth() + 1; uint32 trimmedHeight = trimmedBitmap.Bounds().IntegerHeight() + 1; uint32 trimmedBPR = trimmedBitmap.BytesPerRow(); for (uint32 y = 0; y < trimmedHeight; y++) { memcpy(dst, bits, trimmedWidth * 4); dst += trimmedBPR; bits += bpr; } SetIcon(&trimmedBitmap); }
QString LookupWidget::getInitialWord() { const auto args = KCmdLineArgs::parsedArgs(); const auto retval = (args->count()) ? args->arg(0) : KApplication::clipboard()->text(QClipboard::Selection); return retval.trimmed(); }
void InputDialog::on_ok_button_clicked() { std::string trimmed( myEntry.get_text().raw() ); boost::trim(trimmed); myEntry.set_text( trimmed.c_str() ); if ( !trimmed.empty() ) response(Gtk::RESPONSE_OK); else response(Gtk::RESPONSE_CANCEL); }
void QualityTrimTask::runStep(){ int ncount = 0; int ycount = 0; QScopedPointer<IOAdapter> io (IOAdapterUtils::open(settings.outDir + settings.outName, stateInfo, IOAdapterMode_Append)); int quality = settings.customParameters.value(QUALITY_ID, 20).toInt(); int minLen = settings.customParameters.value(LEN_ID, 0).toInt(); bool bothEnds = settings.customParameters.value(BOTH_ID, false).toInt(); FASTQIterator iter(settings.inputUrl); while(iter.hasNext()){ if(stateInfo.isCoR()){ return; } DNASequence dna = iter.next(); QString comment = DNAInfo::getFastqComment(dna.info); int seqLen = dna.length(); if(seqLen > dna.quality.qualCodes.length()){ ncount++; continue; }else{ int endPosition = seqLen-1; for (; endPosition>=0; endPosition--){ if(dna.quality.getValue(endPosition) >= quality){ break; } } int beginPosition = 0; if (bothEnds) { for (; beginPosition<=endPosition; beginPosition++) { if (dna.quality.getValue(beginPosition) >= quality) { break; } } } if(endPosition>=beginPosition && endPosition-beginPosition+1 >= minLen){ DNASequence trimmed(dna.getName(), dna.seq.left(endPosition+1).mid(beginPosition), dna.alphabet); trimmed.quality = dna.quality; trimmed.quality.qualCodes = trimmed.quality.qualCodes.left(endPosition+1).mid(beginPosition); FastqFormat::writeEntry(trimmed.getName(), trimmed, io.data(), "Writing error", stateInfo, false); ycount++; }else{ ncount++; continue; } } } algoLog.info(QString("Discarded by trimmer %1").arg(ncount)); algoLog.info(QString("Accepted by trimmer %1").arg(ycount)); algoLog.info(QString("Total by trimmer %1").arg(ncount + ycount)); }
string StringManager::getSubString(string toFilter,string filter, bool beforeTheFilter){ string filtered = toFilter; std::size_t found = toFilter.find(filter); if(found != std::string::npos){ if(beforeTheFilter){ filtered = toFilter.substr(0,found); }else{ filtered = toFilter.substr(found + 1, toFilter.size()); } } return trimmed(filtered); }
void queryParser(char *query) { char **SymTab = (char **)malloc(sizeof(char)*15); int i=0,k=0,token_count=0; struct root *Root = (struct root *)malloc(sizeof(struct root *)); for(i=0;i<15;i++) SymTab[i] = (char *)malloc(sizeof(char)*20); token_count = tokenizer(trimmed(query),SymTab); //Normal query parsing struct root *Data = (struct root *)malloc(sizeof(struct root *)); Data = getData(Root); }
// lookup a color and return it's hex value color_t CGUIColorManager::GetColor(const CStdString &color) const { // look in our color map CStdString trimmed(color); trimmed.TrimLeft("= "); icColor it = m_colors.find(trimmed); if (it != m_colors.end()) return (*it).second; // try converting hex directly color_t value = 0; sscanf(trimmed.c_str(), "%x", &value); return value; }
void comment_formatter::format_doxygen_block(std::ostream& s, const std::string& block, const std::string& content) const { if (!use_documentation_tool_markup_) return; std::string trimmed(boost::algorithm::trim_copy(content)); if (trimmed.empty()) return; if (style_ == comment_styles::c_style) s << doxygen_c_style_start << block << c_style_end; else s << doxygen_cpp_style << block; }
void ConcreteSite::handleReplyFinished () { auto reply = qobject_cast<QNetworkReply*> (sender ()); const auto& data = reply->readAll (); const auto& contentType = reply->header (QNetworkRequest::ContentTypeHeader); reply->deleteLater (); deleteLater (); if (reply->error () != QNetworkReply::NoError) return; #ifdef QT_DEBUG qDebug () << Q_FUNC_INFO << "got from" << Desc_.Name_ << "the data:" << data; #endif const auto codec = QTextCodec::codecForName (Desc_.Charset_.toLatin1 ()); if (!codec) qWarning () << Q_FUNC_INFO << "no codec for charset" << Desc_.Charset_ << "; will fallback to UTF-8"; auto str = codec ? codec->toUnicode (data) : QString::fromUtf8 (data.constData ()); if (std::any_of (Desc_.InvalidIndicators_.begin (), Desc_.InvalidIndicators_.end (), [&str] (const QString& ind) { return str.contains (ind); })) return; for (auto excluder : Desc_.Matchers_) str = (*excluder) (str); str = str.trimmed (); const bool isPlainText = contentType.toString ().toLower ().startsWith ("text/plain"); if (isPlainText) { str.prepend ("<pre>"); str.append ("</pre>"); } if (str.size () >= 100) emit gotLyrics ({ Query_, { { Desc_.Name_, str } } }); }
QString FSRComment(uint16_t statusWord) { const auto stackFaultDetail=FPUStackFaultDetail(statusWord); const auto comparisonResult=FPUComparExplain(statusWord); const auto comparComment=comparisonResult.isEmpty()?"":'('+comparisonResult+')'; const auto peExplanation=FPUExplainPE(statusWord); auto comment=comparComment; if(comment.length() && stackFaultDetail.length()) comment+=", "; comment+=stackFaultDetail; if(comment.length() && peExplanation.length()) comment+=", "; comment+=peExplanation; return comment.trimmed(); }
/* 删除指定的记录 */ void delete_information(struct Info_list * list_head) { char condition[100]; char * trimmed_condition = NULL; long int id; printf("Enter ID which you want delete. \n>>>> "); fgets(condition, 100, stdin); trimmed_condition = trimmed(condition); id = atol(trimmed_condition); delete_id_in_list(list_head, id); /* 保存 */ write_list_to_file(list_head); }
JExecutor::token_sequence JExecutor::parse_line(const string& line) const { string trimmed(trim_string(line)); token_sequence res; string::iterator iter(trimmed.begin()); try { res = tokenizer->parse(&iter, trimmed.end()); } catch (J::JParser::ParserFailure& mf) { throw JParserException(); } if (iter != trimmed.end()) { throw JParserException(); } return res; }
void ConfigurationFile::load() { std::map<std::string, std::string> props; std::string line; while(std::getline(inFile, line)) { std::string trimmed(StringUtils::trim(line)); if (!trimmed.length() || trimmed[0] == '#') continue; if (StringUtils::startsWith(trimmed,"@")) continue; if (!StringUtils::has(trimmed, "=")) continue; std::pair<std::string, std::string> parts = StringUtils::partition(trimmed, "="); props[StringUtils::trim(parts.first)] = parts.second; } //TODO: If everything went well, copy into this->properties properties = props; }
string trim(const string& str, const char& ch) { string trimmed(str); string::size_type pos = trimmed.find_last_not_of(ch); if(pos != string::npos) { trimmed.erase(pos + 1); pos = trimmed.find_first_not_of(ch); if(pos != string::npos) { trimmed.erase(0, pos); } } else { trimmed.erase(trimmed.begin(), trimmed.end()); } return trimmed; }
int wxExGetNumberOfLines(const wxString& text) { if (text.empty()) { return 0; } wxString trimmed(text); trimmed.Trim(); const int c = std::count(trimmed.begin(), trimmed.end(), '\r') + 1; if (c != 1) { return c; } return std::count(trimmed.begin(), trimmed.end(), '\n') + 1; }