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


C++ StringBuilder::setTo方法代码示例

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


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

示例1: XthOf

std::vector<std::string> StringBuilder::tokenise( const std::string &_delimiters ) const
{
	std::vector<std::string> parts;
	size_t i;
	size_t j = 0;
	size_t x = 0;
	StringBuilder sub;
	while( SIZE_T_FAIL != (i = XthOf(x++,_delimiters) ) )
	{
		sub.setTo(*this,j,i-j);
		j = i;
		sub.Trim(_delimiters);
		if( sub.size() > 0 )
		{
			parts.push_back(sub.toString());
		}
	}
	if( j != m_pos )
	{
		sub.setTo(*this,j,m_pos-j);
		sub.Trim(_delimiters);
		if( sub.size() > 0 )
		{
			parts.push_back(sub.toString());
		}
	}
	return parts;
}
开发者ID:JonnyWideFoot,项目名称:pd,代码行数:28,代码来源:stringbuilder.cpp

示例2: parse

	bool ParseData::parse(StringBuilder& sb)
	{
		if( sb.size() < 107 ) 
			return false;
		phi = (short)sb.parseInt(5,4);
		psi = (short)sb.parseInt(10,4);
		ASSERT( 
			180 >= phi &&
			-180 <= phi &&
			180 >= psi &&
			-180 <= psi, 
			ParseException, "Phi/Psi range error");
		rotID.setTo(sb, 24, 7 );
		rotID.removeAll(' ');
		ASSERT(rotID.size() == 4, ParseException, "RotID is bad");
		probability = (float)sb.parseDouble(33, 8);
		float chi;
		chis.clear();
		chi = (float)sb.parseDouble( 42, 7 );
		if( chi != 0.0 ) // As a coder, this line makes me vomit, but unfortunatly their library is written this way. Eugh!
			chis.push_back(chi);
		chi = (float)sb.parseDouble( 50, 7 );
		if( chi != 0.0 ) // Why could they not have a gap, or at least use NULL or something ?!?
			chis.push_back(chi);
		chi = (float)sb.parseDouble( 58, 7 );
		if( chi != 0.0 ) 
			chis.push_back(chi);
		chi = (float)sb.parseDouble( 66, 7 );
		if( chi != 0.0 ) 
			chis.push_back(chi);
		return true;		
	}
开发者ID:JonnyWideFoot,项目名称:pd,代码行数:32,代码来源:rotamer_dunbrack.cpp

示例3: readLib

	void RotLibConvert_Dunbrack_BBDep::readLib( const std::string& _LibraryFilename, RotamerLibrary& _RotLib )
	{
		StringBuilder sb;
		std::ifstream* p_torsionFile;
		try
		{
			if( _RotLib.isFinalised() ) 
				throw ProcedureException("readLib() is not allowed, the rotamer library has been finalised, no further import can occur");

			// Mappings for things like HIS -> HIE HID HIP
			_RotLib.addIonisationAliasWorkingDefaults();

			// Make sure Alanine and Glycine are defined non-rotamer residues (the library itself ignores them)
			_RotLib.addAsBlankRotamer("ALA");
			_RotLib.addAsBlankRotamer("GLY");

			p_torsionFile = new std::ifstream(_LibraryFilename.c_str(), std::ifstream::in);
			std::ifstream& torsionFile = *p_torsionFile;
			if( !torsionFile.is_open() ) 
				throw(IOException( "Dunbrack BB-independent torsional definition file not found: '" + _LibraryFilename + "'!" ));
		
			ParseData pd;
			ContainerType data; 
	
			StringBuilder prevResName(3);
			StringBuilder currResName(4);
			StringBuilder cacheLine;

			while( true )
			{
				if( cacheLine.size() > 0 )
				{
					sb.setTo(cacheLine);
					cacheLine.clear();
				}
				else if( !(sb << torsionFile) )
				{
					break;
				}

				sb.Trim();
				if( sb.size() == 0 ) 
					continue; // blank line

				currResName.setTo(sb,0,3);

				if( prevResName.size() == 0 )
				{
					prevResName.setTo( currResName );
					ASSERT( pd.parse( sb ), ParseException, "Malformed line");
					data.push_back( pd );
				}
				else if( prevResName.compare( currResName, 0, 3, 0 ) )
				{
					// Woooo - we found one :-D
					ASSERT( pd.parse( sb ), ParseException, "Malformed line");
					data.push_back( pd );
				}
				else
				{					
					if( data.size() > 0 )
					{
						processResData( prevResName.toString(), data, _RotLib, switchImportMode );
						ASSERT( data.size() == 0, CodeException, "CodeFail");
					}
					prevResName.setTo( currResName );
					cacheLine.setTo( sb ); // we havent actually processed the current line! Store it.
				}
			}
			if( data.size() > 0 )
			{
				processResData( prevResName.toString(), data, _RotLib, switchImportMode );
				ASSERT( data.size() == 0, CodeException, "CodeFail");
			}
			
			// Ensure file-handle cleanup
			p_torsionFile->close();
			delete p_torsionFile;
		}
		catch( ExceptionBase ex )
		{
			// Ensure file-handle cleanup
			p_torsionFile->close();
			delete p_torsionFile;
			throw ex;
		}
	}
开发者ID:JonnyWideFoot,项目名称:pd,代码行数:87,代码来源:rotamer_dunbrack.cpp


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