本文整理汇总了C++中String::AsLong方法的典型用法代码示例。如果您正苦于以下问题:C++ String::AsLong方法的具体用法?C++ String::AsLong怎么用?C++ String::AsLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::AsLong方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FormatNumber
bool DecimalFormatRenderer::FormatNumber( String &sString, String &sScale, String &sDecSeparator )
{
StartTrace(DecimalFormatRenderer.FormatNumber);
String strTmp(sString);
String strToken, strNumber, strDecPlaces;
StringTokenizer tok(strTmp, sDecSeparator[0L]);
if ( tok(strToken) ) {
Trace("current token [" << strToken << "]");
strNumber = strToken;
} else {
strNumber = "0";
}
if ( tok(strToken) ) {
Trace("current token [" << strToken << "]");
strDecPlaces = strToken;
} else {
strDecPlaces = "";
}
if (sScale.AsLong(0L) > 0L) {
InsertFiller( sScale, strDecPlaces );
Trace("decimal [" << strDecPlaces << "] scale [" << sScale.AsLong(0L) << "]");
sString = strNumber << sDecSeparator << strDecPlaces.SubString(0L, sScale.AsLong(0L));
} else {
sString = strNumber;
Trace("result scale = 0 [" << sString << "]");
}
return true;
}
示例2: InsertFiller
void DecimalFormatRenderer::InsertFiller(String &sScale, String &strDecPlaces )
{
StartTrace(DecimalFormatRenderer.InsertFiller);
for ( long lIdx = strDecPlaces.Length(); lIdx < sScale.AsLong(0L) ; lIdx++) {
strDecPlaces.Append("0");
Trace("scale [ " << strDecPlaces << "] index [ " << lIdx << " ]");
}
}
示例3: IsMultipleSelect
bool SelectBoxRenderer::IsMultipleSelect(Context &context, const ROAnything &config)
{
StartTrace(SelectBoxRenderer.IsMultipleSelect);
String str;
if (config.IsDefined("Multiple")) {
RenderOnString(str, context, config["Multiple"]);
}
return (str.AsLong(0L) == 1L);
}
示例4: RenderOptions
void SelectBoxRenderer::RenderOptions(std::ostream &reply, Context &context, const ROAnything &config)
{
// render SIZE argument
reply << " size=\"";
// length of list (default 1 see HTML-Spec.)
String str;
if (config.IsDefined("Size")) {
RenderOnString(str, context, config["Size"]);
}
reply << str.AsLong(1L);
reply << "\"";
if (IsMultipleSelect(context, config)) {
reply << " multiple";
}
FieldRenderer::RenderOptions(reply, context, config);
}
示例5: RenderAll
void FormattedStringRenderer::RenderAll(std::ostream &reply, Context &c, const ROAnything &config)
{
StartTrace(FormattedStringRenderer.RenderAll);
TraceAny(config, "config");
String align, value, filler;
long nSpaces = 4;
ROAnything roaSlotConfig;
if (config.LookupPath(roaSlotConfig, "Value")) {
RenderOnString(value, c, roaSlotConfig);
} else {
reply << "Error in FormattedStringRenderer::RenderAll, Value not defined";
return;
}
Trace("Value: [" << value << "]");
if (config.LookupPath(roaSlotConfig, "Align")) {
RenderOnString(align, c, roaSlotConfig);
} else {
align = "left";
}
Trace("Align: [" << align << "]");
if (config.LookupPath(roaSlotConfig, "Filler")) {
RenderOnString(filler, c, roaSlotConfig);
} else {
filler = " ";
}
Trace("Filler: [" << filler << "]");
long valueLen = getStringLength(value);
long width = valueLen;
if (config.LookupPath(roaSlotConfig, "Width")) {
String sWidth;
RenderOnString(sWidth, c, roaSlotConfig);
width = sWidth.AsLong(valueLen);
}
Trace("Width: " << width);
if (config.LookupPath(roaSlotConfig, "SpacesForTab")) {
String sWidth;
RenderOnString(sWidth, c, roaSlotConfig);
nSpaces = sWidth.AsLong(nSpaces);
}
Trace("SpacesForTab: " << nSpaces);
String result(128);
long lLeftFill = 0, lRightFill = 0;
// string is longer than field width, trim string
if ( valueLen > width ) {
valueLen = getStringLength(trim(value, width ));
} else {
if ( align.IsEqual("right") ) {
lLeftFill = width - valueLen;
} else if ( align.IsEqual("center") ) {
lLeftFill = ( width - valueLen ) / 2L;
lRightFill = width - valueLen - lLeftFill;
} else {
// default: left alignment
lRightFill = width - valueLen;
}
}
Trace("LeftFills: " << lLeftFill << ", RightFill : " << lRightFill );
for ( long iL = 0; iL < lLeftFill; ++iL) {
result << filler;
}
std::for_each(value.begin(), value.end(), whitespaceReplacer(result, filler, nSpaces));
for ( long iR = 0; iR < lRightFill; ++iR ) {
result << filler;
}
Trace("Rendered Value: [" << result << "]");
reply << result;
}