本文整理汇总了C++中StringObject::toNum方法的典型用法代码示例。如果您正苦于以下问题:C++ StringObject::toNum方法的具体用法?C++ StringObject::toNum怎么用?C++ StringObject::toNum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringObject
的用法示例。
在下文中一共展示了StringObject::toNum方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strstr
ToUnicodeCMap::ToUnicodeCMap(IndirectObject * io)
{
this->indirectObject = io;
if(io != null)
{
//Probably not necessary but harmless
io->load();
io->processAsStream();
}
if(this->indirectObject->unencodedStream != null)
{
char * stream = this->indirectObject->unencodedStream;
char * bcsr = strstr(stream, "begincodespacerange");
bcsr += 19; //skip 'begincodespacerange' keyword
bcsr = StringUtils::skipWhiteSpace(bcsr, this->indirectObject->unencodedStreamSize - (bcsr - stream));
do
{
StringObject * codeFrom = new StringObject(&bcsr, bcsr);
StringObject * codeTo = new StringObject(&bcsr, bcsr);
if(codeFrom->isHexa && codeTo->isHexa)
{
codeRanges.push_front(make_pair(codeFrom, codeTo));
}
else
{
cerr<<"\nToUnicodeMap: Couldn't read code ranges properly.\n";
break;
}
bcsr = StringUtils::skipWhiteSpace(bcsr, this->indirectObject->unencodedStreamSize - (bcsr - stream));
}while(*bcsr == '<');
codeRanges.sort(compareRangeLen);
char * bbfc = strstr(stream, "beginbfchar");
while(bbfc != null)
{
bbfc += 11; //skip 'beginbfchar' keyword
do
{
StringObject code = StringObject(&bbfc, bbfc);
StringObject * utfString = new StringObject(&bbfc, bbfc);
if(code.isHexa)
codeCharMap[code.toNum()] = utfString;
bbfc = StringUtils::skipWhiteSpace(bbfc, this->indirectObject->unencodedStreamSize - (bbfc - stream));
}while(*bbfc == '<');
bbfc = strstr(bbfc, "beginbfchar");
}
list<bfrange> rangeMapList;
bbfc = strstr(stream, "beginbfrange");
while(bbfc != null)
{
bbfc += 12;
do
{
StringObject beginCode = StringObject(&bbfc, bbfc);
StringObject endCode = StringObject(&bbfc, bbfc);
PdfObject * objectForRange = PdfObject::readValue(&bbfc, bbfc, false);
BFRange bfr = BFRange();
bfr.begin = beginCode.toNum();
bfr.end = endCode.toNum();
bfr.object = objectForRange;
rangeMapList.push_front(bfr);
bbfc = StringUtils::skipWhiteSpace(bbfc, this->indirectObject->unencodedStreamSize - (bbfc - stream));
}while(*bbfc == '<');
bbfc = strstr(bbfc, "beginbfrange");
}
rangeMapList.sort(compareBFRanges);
while(!rangeMapList.empty())
{
codeRangeMapVector.push_back(rangeMapList.front());
rangeMapList.pop_front();
}
}
}
示例2: if
StringObject * ToUnicodeCMap::getUTFChar(unsigned char * charCode, int len)
{
int charCodeNum = 0;
for(int i = 0; i<len; i++)
{
charCodeNum *= 16;
charCodeNum += charCode[i];
}
StringObject * utfChar = codeCharMap[charCodeNum];
if(utfChar == null)
{
//try to find range for char
BFRange * range = null;
int endSearch = codeRangeMapVector.size()-1;
if(endSearch > 0)
{
int beginSearch = 0;
do
{
int actualSearch = (beginSearch + endSearch) / 2;
BFRange * actualItem = &codeRangeMapVector[actualSearch];
if(actualItem->begin <= charCodeNum &&
actualItem->end >= charCodeNum)
{
range = actualItem;
break;
}
if(actualItem->begin > charCodeNum)
{
endSearch = actualSearch-1;
}
else
{
beginSearch = actualSearch+1;
}
}while(beginSearch <= endSearch);
}
if(range == null)
{
//Couldn't map character properly.
return null;
}
else
{
int increment = charCodeNum - range->begin;
if(range->object->objectType == PdfObject::TYPE_STRING)
{
StringObject * string = (StringObject*) range->object;
int numResult = string->toNum();
numResult += increment;
int len = string->getByteStringLen()*2;
char * hexaString = new char[len+3];
hexaString[0] = '<';
hexaString[len+1] = '>';
hexaString[len+2] = 0;
for(int i = len; i>0; i--)
{
int byte = numResult % 16;
switch(byte)
{
case 0:
hexaString[i] = '0';
break;
case 1:
hexaString[i] = '1';
break;
case 2:
hexaString[i] = '2';
break;
case 3:
hexaString[i] = '3';
break;
case 4:
hexaString[i] = '4';
break;
case 5:
hexaString[i] = '5';
break;
case 6:
hexaString[i] = '6';
break;
case 7:
hexaString[i] = '7';
break;
case 8:
hexaString[i] = '8';
break;
case 9:
hexaString[i] = '9';
break;
case 10:
hexaString[i] = 'A';
break;
case 11:
hexaString[i] = 'B';
break;
case 12:
hexaString[i] = 'C';
break;
case 13:
//.........这里部分代码省略.........