Strings String::split(Strings tokens) const { if(tokens.empty()) tokens.push_back(L" "); Strings ans; base_wstring nowS; IndexVar index = 0; while(index<mContent.size()) { bool flag = false; for(Strings::iterator ptr = tokens.begin(); ptr != tokens.end(); ptr++) if(find(*ptr,index)==index) { flag = true; ans.push_back(nowS); nowS = L""; break; } if(!flag) nowS += mContent[index]; index++; } ans.push_back(nowS); return ans; }
// Split string cs into a vector of strings. // Character c is used to split the strings. // Strings in the result vector do not include the c character. Strings Split(const std::string& cs, char c) { Strings r; std::string s(cs); while (true) { int i = s.find(c); if (i == std::string::npos) { // No special character found, so push back the entire string and finish. r.push_back(s); break; } else { // Found the special character. // Push back whatever is before the character, then work on the remainder // of the string. r.push_back(s.substr(0, i)); s = s.substr(i + 1); Trim(&s); if (s.empty()) { break; } } } return r; }
void initComponents() { setBackground(BG_COLOR); setBounds(120, 120, ICON_WIDTH * 3 + PROGRESS_SIZE + PADDING * 3 + 40, ICON_HEIGHT + PROGRESS_SIZE + 50); statusLabel_ = new Label("ready"); statusLabel_->setBounds(START_X, START_Y, ICON_WIDTH * 4, ICON_HEIGHT); statusLabel_->setBackground(BG_COLOR); statusLabel_->setForeground(monagui::Color::gray); add(statusLabel_); playButton_ = new ImageSinkButton(playImage_, stopImage_, playImageFocused_); playButton_->setBounds(ICON_WIDTH + PADDING + START_X, ICON_HEIGHT + START_Y + PADDING, ICON_WIDTH, ICON_HEIGHT); add(playButton_); backButton_ = new ImageButton(backImage_, backImageFocused_); backButton_->setBounds(START_X, ICON_HEIGHT + START_Y + PADDING, ICON_WIDTH, ICON_HEIGHT); add(backButton_); forwardButton_ = new ImageButton(forwardImage_, forwardImageFocused_); forwardButton_->setBounds(ICON_WIDTH * 2 + PADDING * 2 + START_X, ICON_HEIGHT + START_Y + PADDING, ICON_WIDTH, ICON_HEIGHT); add(forwardButton_); Strings icons; icons.push_back(APPLICATION_DATA_DIR"/BAR0.JPG"); icons.push_back(APPLICATION_DATA_DIR"/BAR1.JPG"); icons.push_back(APPLICATION_DATA_DIR"/BAR2.JPG"); icons.push_back(APPLICATION_DATA_DIR"/BAR3.JPG"); icons.push_back(APPLICATION_DATA_DIR"/BAR4.JPG"); progressIcon_ = new ProgressIcon(icons, PROGRESS_SIZE, PROGRESS_SIZE); progressIcon_->setBounds(ICON_WIDTH * 3 + PADDING * 3 + START_X, ICON_HEIGHT + START_Y + PADDING, PROGRESS_SIZE, PROGRESS_SIZE); add(progressIcon_); }
bool AbstractAligner::test(bool gaps) const { Strings aln; aln.push_back("AT"); aln.push_back(gaps ? "T" : "A"); try { align_seqs(aln); } catch (...) { return false; } return aln[0] == "AT" && aln[1] == (gaps ? "-T" : "A-"); }
Strings CUtils::Split(String data, const String & separator) { Strings dataSplitted; int position(0); while ((position = data.find(separator)) != -1) { dataSplitted.push_back(data.substr(0, position)); data = data.substr(position + separator.length()); } if (data.length() > 0) dataSplitted.push_back(data); return dataSplitted; }
co::ConnectionPtr _startLocalServer() { Strings dirNames; dirNames.push_back( "" ); #ifdef EQ_BUILD_DIR #ifdef NDEBUG dirNames.push_back( std::string( EQ_BUILD_DIR ) + "lib/Release/" ); #else dirNames.push_back( std::string( EQ_BUILD_DIR ) + "lib/Debug/" ); #endif dirNames.push_back( std::string( EQ_BUILD_DIR ) + "lib/" ); #endif #ifdef _MSC_VER const std::string libName = "EqualizerServer.dll"; #elif defined (_WIN32) const std::string libName = "libEqualizerServer.dll"; #elif defined (Darwin) const std::string libName = "libEqualizerServer.dylib"; #else const std::string libName = "libEqualizerServer.so"; #endif while( !_libeqserver.isOpen() && !dirNames.empty( )) { _libeqserver.open( dirNames.back() + libName ); dirNames.pop_back(); } if( !_libeqserver.isOpen( )) { LBWARN << "Can't open Equalizer server library" << std::endl; return 0; } eqsStartLocalServer_t eqsStartLocalServer = (eqsStartLocalServer_t) _libeqserver.getFunctionPointer( "eqsStartLocalServer" ); if( !eqsStartLocalServer ) { LBWARN << "Can't find server entry function eqsStartLocalServer" << std::endl; return 0; } return eqsStartLocalServer( Global::getConfigFile( )); }
String String::strip(Strings tokens) const { if(tokens.empty()) tokens.push_back(L" "); IndexVar left = 0, right = mContent.size(); while(left<mContent.size()) { bool flag = false; for(Strings::iterator ptr = tokens.begin(); ptr != tokens.end(); ptr++) if(find(*ptr,left)==left) { flag = true; break; } if(!flag) break; left++; } while(right>=0) { bool flag = false; for(Strings::iterator ptr = tokens.begin(); ptr != tokens.end(); ptr++) if(rfind(*ptr,right-1)==right-1) { flag = true; break; } if(!flag) break; right--; } return substr(left,right-left); }
///--------------------------------------------------------------------------------- /// ///--------------------------------------------------------------------------------- bool FindAllFilesOfType( const std::string& directory, const std::string& searchPattern, Strings& out_filesFound ) { #ifdef WIN32 _finddata_t fd; std::string searchPath = directory + searchPattern; intptr_t searchHandle = _findfirst( searchPath.c_str(), &fd ); if (searchHandle != -1) { do { // ConsolePrintf( "%s %i\n", (directory + std::string(fd.name)).c_str(), fd.attrib ); out_filesFound.push_back( directory + std::string( fd.name ) ); } while (_findnext( searchHandle, &fd ) == 0); } else return false; if (_findclose( searchHandle ) == 0 && out_filesFound.size() != 0) return true; return false; #else return false; #endif }
bool Client::initLocal( const int argc, char** argv ) { if( _impl->name.empty() && argc > 0 && argv ) { const boost::filesystem::path prog = argv[0]; setName( prog.stem().string( )); } const auto options = _getProgramOptions(); arg::variables_map vm; try { Strings args; for( int i = 0; i < argc; ++i ) if( strcmp( argv[i], "--" ) != 0 ) args.push_back( argv[i] ); arg::store( arg::command_line_parser( args ) .options( options ).allow_unregistered().run(), vm ); arg::notify( vm ); } catch( const std::exception& e ) { LBERROR << "Error in argument parsing: " << e.what() << std::endl; return false; } const bool isClient = vm.count( "eq-client" ); std::string clientOpts; if( vm.count( "eq-layout" )) _impl->activeLayouts.push_back( vm["eq-layout"].as< std::string >( )); if( vm.count( "eq-gpufilter" )) _impl->gpuFilter = vm["eq-gpufilter"].as< std::string >(); if( vm.count( "eq-modelunit" )) _impl->modelUnit = vm["eq-modelunit"].as< float >(); LBVERB << "Launching " << getNodeID() << std::endl; if( !Super::initLocal( argc, argv )) return false; if( isClient ) { LBVERB << "Client node started from command line with option " << clientOpts << std::endl; if( !_setupClient( clientOpts )) { exitLocal(); return false; } _impl->running = true; clientLoop(); exitClient(); } _impl->initQt( argc, argv ); return true; }
Strings PlayerInfoManager::GetPlayerNames() const { // TODO Sort strings in order of use, most recent first, i.e. descending order typedef std::map<unsigned int, std::string, std::greater<unsigned int> > TimestampName; TimestampName tn; // Put names into map so they will be sorted, most recent first for (PIMap::const_iterator it = m_map.begin(); it != m_map.end(); ++it) { unsigned int timestamp = it->second.first; tn[timestamp] = it->first; } // Copy names in order into vector Strings s; for (TimestampName::const_iterator it = tn.begin(); it != tn.end(); ++it) { s.push_back(it->second); } // TODO something like // std::copy(tn.begin, tn.end, std::back_inserter(s)); return s; }
Strings getKeys() const { Strings keys; for( ValueMapCIter i = _data.begin(); i != _data.end(); ++i ) keys.push_back( i->first ); return keys; }
Strings dir_children(const std::string& d) { Strings result; fs::directory_iterator dir(d), end; BOOST_FOREACH (const fs::path& child, std::make_pair(dir, end)) { result.push_back(child.string()); }
Strings expandShellWildcard( const std::string& filename ) { Strings expandedFilenames; namespace fs = boost::filesystem; const fs::path& filePath( filename ); const fs::path& parent = filePath.parent_path(); if( !fs::exists( parent ) || !fs::is_directory( parent )) LBTHROW( std::runtime_error( "Not a valid path" )); // Convert the filename with shell-like wildcard into a POSIX regex const boost::regex regex = convertToRegex( filename ); for( fs::directory_iterator it( parent ); it != fs::directory_iterator(); ++it ) { const std::string& candidate = it->path().string(); if( boost::regex_match( candidate, regex )) expandedFilenames.push_back( candidate ); } return expandedFilenames; }
int main(int argc, char **argv) { std::cout << "Usage: " << StripPath(argv[0]) << " [modelPath]\n"; glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); int windowX = 640; int windowY = 480; glutInitWindowSize(windowX, windowY); glutCreateWindow("Anim Test"); // Set callbacks glutDisplayFunc(draw); glutIdleFunc(idle); glutReshapeFunc(resize); glutKeyboardFunc(keydown); //glutKeyboardUpFunc(keyup); //glutSpecialFunc(specialkeydown); //glutSpecialUpFunc(specialkeyup); glutMouseFunc(mousedown); glutMotionFunc(mousemove); glutPassiveMotionFunc(mousemove); AmjuGL::SetImpl(new AmjuGLOpenGL(MyCreateWindowGLUT)); AmjuGL::CreateWindow(&w); AmjuGL::Init(); float aspect = (float)windowX / (float)windowY; AmjuGL::SetMatrixMode(AmjuGL::AMJU_PROJECTION_MATRIX); AmjuGL::SetPerspectiveProjection(45.0f, aspect, 1.0f, 1000.0f); glDisable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); AmjuGL::Enable(AmjuGL::AMJU_BLEND); // glFrontFace(GL_CW); // this means we need to reverse the winding order when we load the tris for an MD3 // Look for md3 characters DirEnts des; Dir(".", &des, false); for (unsigned int i = 0; i < des.size(); i++) { DirEnt& de = des[i]; if (de.m_name[0] == '.') { continue; } if (de.m_isDir) { std::cout << de.m_name << "\n"; charlist.push_back(de.m_name); } } glutMainLoop(); return 0; }
void Node::leafNames(Node* node, Strings& leafNameVec) { if(node->isLeaf()) leafNameVec.push_back(node->name()); for(unsigned int i = 0; i < node->numberOfChildren(); i++) leafNames(node->child(i), leafNameVec); }
// Read the stream `in' as a sequence of lines. void read(Strings& strings, std::istream& in) { std::string s; while (true) { std::getline(in, s); if (in.eof()) return; strings.push_back(s); } }
Options(int argc, char* argv[]) : mode(Auto) , threads(0) , help(false) , printAlign(false) { for (int i = 1; i < argc; ++i) { String arg = argv[i]; if (arg.substr(0, 2) == "-h" || arg.substr(0, 2) == "-?") { help = true; break; } else if (arg.find("-m=") == 0) { switch (arg[3]) { case 'a': mode = Auto; break; case 'c': mode = Create; break; case 'v': mode = Verify; break; case 's': mode = Special; break; default: TEST_LOG_SS(Error, "Unknown command line options: '" << arg << "'!" << std::endl); exit(1); } } else if (arg.find("-t=") == 0) { #ifdef NDEBUG threads = FromString<size_t>(arg.substr(3, arg.size() - 3)); #endif } else if (arg.find("-f=") == 0) { filters.push_back(arg.substr(3, arg.size() - 3)); } else if (arg.find("-o=") == 0) { output = arg.substr(3, arg.size() - 3); } else if (arg.find("-r=") == 0) { ROOT_PATH = arg.substr(3, arg.size() - 3); } else if (arg.find("-pa=") == 0) { printAlign = FromString<bool>(arg.substr(4, arg.size() - 4)); } else { TEST_LOG_SS(Error, "Unknown command line options: '" << arg << "'!" << std::endl); exit(1); } } }
const Strings SqlSource::options() const { Strings options; Strings k = keys(); for (size_t i = 0; i < k.size(); ++i) if (!starts_with(k[i], _T("&"))) options.push_back(k[i]); return options; }
Strings getInstances() const { Strings instances; for( InstanceMapCIter i = _instanceMap.begin(); i != _instanceMap.end(); ++i ) { instances.push_back( i->first ); } return instances; }
ChemicalValidity::Strings ChemicalValidity::optimalSplit(const std::string& input, const ChemicalValidity::Strings& dictionary) { Strings result; for (size_t u = 0; u < dictionary.size(); u++) { const std::string& word = dictionary[u]; size_t idx = input.find(word); if (idx != std::string::npos) { if (idx > 0) { std::string s1 = input.substr(0, idx); Strings r1 = optimalSplit(s1, dictionary); for (size_t p = 0; p < r1.size(); p++) result.push_back(r1[p]); } result.push_back(word); if (idx + word.size() < input.size()) { std::string s2 = input.substr(idx + word.size()); Strings r2 = optimalSplit(s2, dictionary); for (size_t p = 0; p < r2.size(); p++) result.push_back(r2[p]); } return result; } } // no dictionary strings found in input, return input as the minimal split for (size_t u = 0; u < input.size(); u++) { std::string temp; temp += input[u]; result.push_back(temp); } return result; }
CrustaVislet:: CrustaVislet(int numArguments, const char* const arguments[]) { typedef std::vector<std::string> Strings; Strings dataFiles; Strings settingsFiles; for (int i=0; i<numArguments; ++i) { std::string token = std::string(arguments[i]); if (token == std::string("-settings")) settingsFiles.push_back(std::string(arguments[++i])); else dataFiles.push_back(token); } crusta = new Crusta(); crusta->init(settingsFiles); crusta->load(dataFiles); }
void AbstractAligner::align_block(Block* block) const { TimeIncrementer ti(this); if (!alignment_needed(block)) { return; } Fragments fragments((block->begin()), block->end()); Strings rows; BOOST_FOREACH (Fragment* f, fragments) { rows.push_back(f->str(/* gap */ 0)); }
static Strings split(const std::string &str, char delim) { Strings elems; std::stringstream ss(str); std::string item; while(std::getline(ss, item, delim)) elems.push_back(item); return elems; }
//------------------------------------------------------------------------ MaterialTypes::Strings MaterialTypes::GetTypeNames() const { Strings result; for( uint32_t i = 0, e = mEntries.Count(); i < e; i ++ ) { result.push_back( mEntries[ i ].name.c_str() ); } return result; }
int String::Parse (Strings &result, const char *chars) { String element; result.clear (); while (Split (element, chars)) { result.push_back (element); } return ((int) result.size ()); }
Strings getInstances() const { Strings instances; #ifdef LUNCHBOX_USE_DNSSD for( InstanceMapCIter i = instanceMap_.begin(); i != instanceMap_.end(); ++i ) { instances.push_back( i->first ); } #endif return instances; }
Strings getKeys( const std::string& instance ) const { Strings keys; InstanceMapCIter i = _instanceMap.find( instance ); if( i == _instanceMap.end( )) return keys; const ValueMap& values = i->second; for( ValueMapCIter j = values.begin(); j != values.end(); ++j ) keys.push_back( j->first ); return keys; }
static void split( const std::string& str, char delimiter, Strings& items ) { std::stringstream s_stream(str); std::string item; while (std::getline(s_stream, item, delimiter)) { if (!item.empty()) { items.push_back(item); } } }
PathSpecifiers (std::string const & s0, std::string const & s1 = "", std::string const & s2 = "", std::string const & s3 = "", std::string const & s4 = "", std::string const & s5 = "", std::string const & s6 = "", std::string const & s7 = "", std::string const & s8 = "", std::string const & s9 = "" ) : path() { if (s0 != "") path.push_back(s0); if (s1 != "") path.push_back(s1); if (s2 != "") path.push_back(s2); if (s3 != "") path.push_back(s3); if (s4 != "") path.push_back(s4); if (s5 != "") path.push_back(s5); if (s6 != "") path.push_back(s6); if (s7 != "") path.push_back(s7); if (s8 != "") path.push_back(s8); if (s9 != "") path.push_back(s9); }
co::ConnectionPtr _startLocalServer() { Strings dirNames; dirNames.push_back( "" ); dirNames.push_back( "./" ); // Add path of current .so so search paths for EqualizerServer #ifndef _WIN32 Dl_info dl_info; dladdr((void *)_startLocalServer, &dl_info); char libPath[1024]; strncpy(libPath, dl_info.dli_fname, 1024); char* k = strrchr(libPath, '/'); *(k + 1) = '\0'; dirNames.push_back( libPath ); #endif #ifdef EQ_BUILD_DIR #ifdef NDEBUG dirNames.push_back( std::string( EQ_BUILD_DIR ) + "libs/server/Release/" ); #else dirNames.push_back( std::string( EQ_BUILD_DIR ) + "libs/server/Debug/" ); #endif dirNames.push_back( std::string( EQ_BUILD_DIR ) + "libs/server/" ); #endif #ifdef _MSC_VER const std::string libName = "EqualizerServer.dll"; #elif defined (_WIN32) const std::string libName = "libEqualizerServer.dll"; #elif defined (Darwin) const std::string libName = "libEqualizerServer.dylib"; #else const std::string libName = "libEqualizerServer.so"; #endif while( !_libeqserver.isOpen() && !dirNames.empty( )) { _libeqserver.open( dirNames.back() + libName ); dirNames.pop_back(); } if( !_libeqserver.isOpen( )) { EQWARN << "Can't open Equalizer server library" << std::endl; return 0; } eqsStartLocalServer_t eqsStartLocalServer = (eqsStartLocalServer_t) _libeqserver.getFunctionPointer( "eqsStartLocalServer" ); if( !eqsStartLocalServer ) { EQWARN << "Can't find server entry function eqsStartLocalServer" << std::endl; return 0; } return eqsStartLocalServer( Global::getConfigFile( )); }