当前位置: 首页>>代码示例>>C++>>正文


C++ Strings类代码示例

本文整理汇总了C++中Strings的典型用法代码示例。如果您正苦于以下问题:C++ Strings类的具体用法?C++ Strings怎么用?C++ Strings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Strings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addStrings

void Strings::addStrings(const Strings& strings)
{
	AutoUpdater autoUpdater(*this);

	for (int i = 0; i < strings.getCount(); i++)
		add(strings.getString(i).c_str(), strings.getData(i));
}
开发者ID:cckck1103,项目名称:ProjectFrame,代码行数:7,代码来源:StringList.cpp

示例2: dir_children

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());
    }
开发者ID:npge,项目名称:npge,代码行数:7,代码来源:name_to_stream.cpp

示例3: FindAllFilesOfType

///---------------------------------------------------------------------------------
///
///---------------------------------------------------------------------------------
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


}
开发者ID:tbgeorge,项目名称:putty_engine,代码行数:32,代码来源:FileUtilities.cpp

示例4: readNodenames

void ConfigTool::writeConfig() const
{
    Global* global = Global::instance();
    global->setConfigFAttribute( Config::FATTR_VERSION, 1.2f );
    global->setWindowIAttribute( eq::server::Window::IATTR_HINT_FULLSCREEN,
                                 eq::fabric::ON );
    if( _mode != MODE_WALL )
    {
        global->setWindowIAttribute(eq::server::Window::IATTR_HINT_DOUBLEBUFFER,
                                    eq::fabric::OFF );
        global->setWindowIAttribute( eq::server::Window::IATTR_HINT_DRAWABLE,
                                     eq::fabric::PBUFFER );
    }
    if( _mode >= MODE_DB && _mode <= MODE_DB_STREAM )
        global->setWindowIAttribute( eq::server::Window::IATTR_PLANES_STENCIL,
                                     eq::fabric::ON );

    ServerPtr server = new eq::server::Server;
    const Strings nodeNames = readNodenames( _nodesFile );
    co::ConnectionDescriptionPtr desc = new ConnectionDescription;
    if( !nodeNames.empty( ))
        desc->setHostname( nodeNames.front( ));
    server->addConnectionDescription( desc );

    Config* config = new Config( server );
    _writeResources( config, nodeNames );
    _writeCompound( config );

    lunchbox::Log::instance( "", 0 )
        << lunchbox::disableHeader << global << *server << std::endl
        << lunchbox::enableHeader << lunchbox::disableFlush;
}
开发者ID:bsmr-c-cpp,项目名称:Equalizer,代码行数:32,代码来源:configTool.cpp

示例5: buildTree

void NeighbourJoining::buildTree(Matrix& distMatrix, const Strings& labels, Tree* tree)
{
	// allocation space for temporary variables
  m_separationSums = new double[distMatrix.size()];
  m_separations = new double[distMatrix.size()];
  m_numActiveClusters = distMatrix.size();      
  m_activeClusters = new bool[distMatrix.size()];

	//calculate initial seperation rows
  for(uint i = 0; i < distMatrix.size(); i++)
	{
    double sum = 0;
    for(uint j = 0; j < distMatrix.size(); j++)
      sum += distMatrix[i][j];

    m_separationSums[i] = sum;
    m_separations[i] = sum / (m_numActiveClusters-2); 
    m_activeClusters[i] = true;
  }

	// create initial singleton clusters
	std::vector< Node* > clusters;
	for(uint i = 0; i < labels.size(); ++i)
	{
		Node* node = new Node(labels.at(i));
		clusters.push_back(node);
	}

  while(m_numActiveClusters > 2)
	{
    findNearestClusters(distMatrix);
    updateClusters(distMatrix, clusters);
    updateDistanceMatrix(distMatrix);                       
  }

  // finish by joining the two remaining clusters
  int index1 = -1;
  int index2 = -1;

  // find the last nodes
  for(uint i = 0; i < distMatrix.size(); i++)
	{
    if(m_activeClusters[i])
		{
      if(index1 == -1)
				index1 = i;
      else
			{
				index2 = i;	
				break;
      }            
    }
  }  

	// connect remaining subtrees and define arbitrary root of tree
	clusters.at(index1)->addChild(clusters.at(index2));
	clusters.at(index2)->distanceToParent(distMatrix[index1][index2]);

	tree->root(clusters.at(index1));
}
开发者ID:dparks1134,项目名称:PETs,代码行数:60,代码来源:NeighbourJoining.cpp

示例6: expandShellWildcard

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;
}
开发者ID:eile,项目名称:Brion,代码行数:25,代码来源:spikeReportNEST.cpp

示例7: setName

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;
}
开发者ID:tribal-tec,项目名称:Equalizer,代码行数:60,代码来源:client.cpp

示例8: split

std::string 
StringTools::wrap( const std::string &text,
                   int wrapColumn )
{
  const char lineBreak = '\n';
  Strings lines = split( text, lineBreak );

  std::string wrapped;
  for ( Strings::const_iterator it = lines.begin(); it != lines.end(); ++it )
  {
    if ( it != lines.begin() )
      wrapped += lineBreak;

    const std::string &line = *it;
    unsigned int index =0;
    while ( index < line.length() )
    {
      std::string lineSlice( line.substr( index, wrapColumn ) );
      wrapped += lineSlice;
      index += wrapColumn;
      if ( index < line.length() )
        wrapped += lineBreak;
    }
  }

  return wrapped;
}
开发者ID:nyhnpya,项目名称:ClSockets,代码行数:27,代码来源:StringTools.cpp

示例9: Split

// 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;
}
开发者ID:AD87,项目名称:Not-Fast-Not-Furious,代码行数:32,代码来源:ObjUsefulFunctions.cpp

示例10: initComponents

    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_);
    }
开发者ID:Nirlendu,项目名称:mona,代码行数:33,代码来源:bplayer.cpp

示例11: stringToHypergraph

Position stringToHypergraph(Strings const& inputTokens, IMutableHypergraph<Arc>* pHgResult,
                            StringToHypergraphOptions const& opts = StringToHypergraphOptions(),
                            TokenWeights const& inputWeights = TokenWeights()) {
  IVocabularyPtr const& pVoc = pHgResult->getVocabulary();
  if (!pVoc) SDL_THROW_LOG(Hypergraph, InvalidInputException, "pHgResult hypergraph must contain vocabulary");
  for (std::size_t i = 0, numNonlexicalStates = inputTokens.size() + 1; i < numNonlexicalStates; ++i)
    pHgResult->addState();
  pHgResult->setStart(0);
  StateId prevState = 0;

  typedef typename Arc::Weight Weight;
  typedef FeatureInsertFct<Weight> FI;
  Position i = 0, n = inputTokens.size();
  for (; i != n; ++i) {
    std::string const& token = inputTokens[i];
    SDL_TRACE(Hypergraph.StringToHypergraph, i << ": " << token);
    const Sym sym = opts.terminalMaybeUnk(pVoc.get(), token);
    const StateId nextState = prevState + 1;
    Arc* pArc = new Arc(nextState, Tails(prevState, pHgResult->addState(sym)));
    Weight& weight = pArc->weight();
    assert(opts.inputFeatures != NULL);
    for (FeatureId featureId : opts.inputFeatures->getFeaturesForInputPosition(i)) {
      FI::insertNew(&weight, featureId, 1);
      if (opts.tokens) opts.tokens->insert(sym, featureId);
    }
    inputWeights.reweight(i, weight);
    pHgResult->addArc(pArc);
    prevState = nextState;
  }
  pHgResult->setFinal(prevState);
  return n;
}
开发者ID:anibalanto,项目名称:hyp,代码行数:32,代码来源:StringToHypergraph.hpp

示例12: GetPlayerNames

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;
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:26,代码来源:PlayerInfo.cpp

示例13: Compile

bool User_Program::Compile (string &text, bool list_flag)
{
	Strings lines;
	Str_Itr line_itr;

	//---- split the text into lines ----

	String_Ptr (text)->Parse (lines, "\n\r\f");

	for (line_itr = lines.begin (); line_itr != lines.end (); line_itr++) {
		line_num++;

		if (list_flag) {
			exe->Print (1, "\t") << *line_itr;
		}
		line_itr->Clean ();
		if (line_itr->empty ()) continue;

		if (declare_flag) {
			if (!Initial_Declare (*line_itr)) break;
		} else if (table_flag) {
			if (!Initial_Table (*line_itr)) break;
		} else {
			while (Get_Token (*line_itr)) {
				if (!Process_Token ()) break;
			}
		}
	}
	return (true);
}
开发者ID:kravitz,项目名称:transims5,代码行数:30,代码来源:Compile.cpp

示例14: _startLocalServer

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( ));
}
开发者ID:omega-hub,项目名称:Equalizer-1.0.2,代码行数:59,代码来源:client.cpp

示例15: Split

bool PlayerInfo::Load()
{
  // FileExists doesn't append File::Root
  if (FileExists(File::GetRoot() + m_filename))
  {
#ifdef PI_DEBUG
std::cout << "Loading player info " << m_filename << "...\n";
#endif
  }
  else
  {
#ifdef PI_DEBUG
std::cout << "Loading player info " << m_filename << " doesn't exist! - - it's a new file\n";
#endif
    // We assume the player is new and has not saved any player info yet - this is OK.
    return true;
  }

#ifdef PI_DEBUG
std::cout << "Loading player info " << m_filename << "...\n";
#endif

  File f;
  if (!f.OpenRead(m_filename))
  {
    return false;
  }
  int num = 0;
  if (!f.GetInteger(&num))
  {
    return false;
  }
  for (int i = 0; i < num; i++)
  {
    std::string s;
    if (!f.GetDataLine(&s))
    {
      return false;
    }

#ifdef PI_DEBUG
std::cout << " Got line: " << s << "\n";
#endif

    Strings strs = Split(s, ',');
    if (strs.size() != 2)
    {
      f.ReportError("Bad line in player info: " + s);
      return false;
    }
    PISetString(strs[0], strs[1]);
  }
#ifdef PI_DEBUG
std::cout << "End of player info load.\n";
#endif

  return true;
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:58,代码来源:PlayerInfo.cpp


注:本文中的Strings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。