本文整理汇总了C++中StringBuilder::size方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuilder::size方法的具体用法?C++ StringBuilder::size怎么用?C++ StringBuilder::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuilder
的用法示例。
在下文中一共展示了StringBuilder::size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: readDefinition
void RotLibConvert_Dunbrack_BBInd::readDefinition( StringBuilder& sb, RotamerLibrary& _RotLib ) const
{
ASSERT( sb.size() >= 67, ParseException, "String too short to parse!!");
StringBuilder resname(3);
resname.setTo( sb, 0, 3 );
sb.TruncateLeftBy(18);
int pdbCount = sb.parseInt(0,7);
if( pdbCount == 0 )
return;
double probability = sb.parseDouble(7,8);
sb.TruncateLeftBy(37);
std::vector<double> importChis;
std::vector<std::string> parts = sb.tokenise();
ASSERT( (parts.size() % 2 == 0), ParseException, "Unexpected element count");
for( size_t i = 0; i < parts.size(); i+=2 )
{
double chi;
ASSERT( 0 == str2double( parts[i], chi ), ParseException, "Error parsing chi def");
importChis.push_back(Maths::DegToRad(chi));
}
ASSERT( importChis.size() != 0, ParseException, "No chis found!!");
_RotLib.addRotamer( resname.toString(), importChis, ConstantProbability( probability ) );
}
示例4: append
void StringBuilder::append( const StringBuilder &_string, size_t _index, size_t _length )
{
size_t strLen = _string.size();
if( strLen < (_index+_length) ) throw OutOfRangeException("Range given is outside of the range of the given string!");
while( (m_pos + _length) > m_alloc ) growCapacity();
memcpy(&m_buffer[m_pos],&_string.m_buffer[_index],_length);
m_pos += _length;
zeroTerminateIfDebug();
}
示例5: appendQuotedString
void Stringifier::appendQuotedString(StringBuilder& builder, const UString& value)
{
int length = value.size();
// String length plus 2 for quote marks plus 8 so we can accomodate a few escaped characters.
builder.reserveCapacity(builder.size() + length + 2 + 8);
builder.append('"');
const UChar* data = value.data();
for (int i = 0; i < length; ++i) {
int start = i;
while (i < length && (data[i] > 0x1F && data[i] != '"' && data[i] != '\\'))
++i;
builder.append(data + start, i - start);
if (i >= length)
break;
switch (data[i]) {
case '\t':
builder.append('\\');
builder.append('t');
break;
case '\r':
builder.append('\\');
builder.append('r');
break;
case '\n':
builder.append('\\');
builder.append('n');
break;
case '\f':
builder.append('\\');
builder.append('f');
break;
case '\b':
builder.append('\\');
builder.append('b');
break;
case '"':
builder.append('\\');
builder.append('"');
break;
case '\\':
builder.append('\\');
builder.append('\\');
break;
default:
static const char hexDigits[] = "0123456789abcdef";
UChar ch = data[i];
UChar hex[] = { '\\', 'u', hexDigits[(ch >> 12) & 0xF], hexDigits[(ch >> 8) & 0xF], hexDigits[(ch >> 4) & 0xF], hexDigits[ch & 0xF] };
builder.append(hex, sizeof(hex) / sizeof(UChar));
break;
}
}
示例6: readLib
void RotLibConvert_Dunbrack_BBInd::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 + "'!" ));
sb << torsionFile;
ASSERT( sb.size() >= 36 && sb.compare("Backbone-independent rotamer library",0,36,0,false),
ParseException,
"The input coordinate file does not appear to be in Dunbrack BB-independent format");
const char* initLine = "Res Rotamer n(r1) n(r1234) p(r1234) sig p(r234|r1) sig chi1 sig chi2 sig chi3 sig chi4 sig";
int initLineLength = strlen(initLine);
bool begun = false;
while( sb << torsionFile )
{
if( sb.size() >= initLineLength &&
sb.compare( initLine, 0, initLineLength, 0 ) )
{
begun = true;
break;
}
}
ASSERT(begun,ParseException,"Unexpected EOF whilst parsing the Dunbrack BB-independent format library");
sb << torsionFile; // Two blanking lines are present here
sb << torsionFile; // So eradicate them - mwa ha ha ha!
while( sb << torsionFile )
{
sb.Trim();
if( sb.size() == 0 ) continue;
readDefinition( sb, _RotLib );
}
// 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;
}
}