本文整理汇总了C++中resolveReference函数的典型用法代码示例。如果您正苦于以下问题:C++ resolveReference函数的具体用法?C++ resolveReference怎么用?C++ resolveReference使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resolveReference函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: codeLength
void Loader::loadCode(const char *entryLabel)
{
int length = codeLength() + 64; // NOTE: Code length is not accurate due to alignment issues
machineCode = new unsigned char[length];
unsigned char *currentCode = machineCode;
#ifdef WIN32
unsigned long oldProtection;
VirtualProtect(machineCode, length, PAGE_EXECUTE_READWRITE, &oldProtection);
#elif __unix__
mprotect(machineCode, length, PROT_READ | PROT_WRITE | PROT_EXEC);
#endif
Instruction *instruction = instructions;
while(instruction)
{
Encoding &encoding = *instruction;
encoding.setAddress(currentCode);
const char *reference = encoding.getReference();
const char *label = encoding.getLabel();
if(reference)
{
if(encoding.relativeReference())
{
int offset = resolveReference(reference, instruction) - currentCode - encoding.length(currentCode);
encoding.setJumpOffset(offset);
}
else
{
int address = (int)resolveReference(reference, instruction);
// Encoded as memory reference or immediate?
if(encoding.hasDisplacement())
{
encoding.addDisplacement(address);
}
else if(encoding.hasImmediate())
{
encoding.setImmediate(address);
}
else
{
INTERNAL_ERROR;
}
}
}
else if(encoding.hasImmediate() && encoding.relativeReference())
{
int offset = encoding.getImmediate() - (int)currentCode - encoding.length(currentCode);
encoding.setCallOffset(offset);
}
currentCode += encoding.writeCode(currentCode);
instruction = instruction->next();
}
}
示例2: parseSlotValue
RDF_Error
parseSlotValue (RDFFile f, RDF_Resource s, char* value, void** parsed_value, RDF_ValueType* data_type)
{
if (value[0] == '"') {
int32 size = strlen(value)-1;
*parsed_value = getMem(size);
value[size] = '\0';
*parsed_value = &value[1];
*data_type = RDF_STRING_TYPE;
return noRDFErr;
} else if (value[0] == '#') {
if (value[1] == '"') {
value[strlen(value)-1] = '\0';
value = &value[2];
} else {
value = &value[1];
}
*parsed_value = resolveReference(value, f);
return noRDFErr;
} else if (charSearch('.', value) == -1) {
int16 ans = 0;
/* XXX sscanf(value, "%ld", &ans); */
*data_type = RDF_INT_TYPE;
return noRDFErr;
} else {
return -1;
}
}
示例3: resolveReference
void PdfBookReader::processPage(shared_ptr<PdfObject> pageObject, ZLInputStream &stream) {
pageObject = resolveReference(pageObject, stream);
if (pageObject.isNull() || pageObject->type() != PdfObject::DICTIONARY) {
return;
}
const PdfDictionaryObject &pageDictionary = (const PdfDictionaryObject&)*pageObject;
shared_ptr<PdfObject> contents = pageDictionary["Contents"];
if (contents.isNull()) {
return;
}
switch (contents->type()) {
default:
break;
case PdfObject::REFERENCE:
processContents(contents, stream);
break;
case PdfObject::ARRAY:
{
const PdfArrayObject &array = (const PdfArrayObject&)*contents;
const size_t len = array.size();
for (size_t i = 0; i < len; ++i) {
processContents(array[i], stream);
}
break;
}
}
}
示例4: recordTopicDefinitions
void recordTopicDefinitions( TTopicDefinition *p, THelpFile& helpFile )
{
while (p != 0)
{
resolveReference(p->topic, p->value, *(helpFile.stream));
helpFile.recordPositionInIndex(p->value);
p = p->next;
}
}
示例5: resolveGenlPosReference
RDF_Resource
resolveGenlPosReference(char* tok, RDFFile f)
{
RDF_Resource ans;
char* url = (char*)getMem(MAX_URL_SIZE);
long i1, i2;
i1 = charSearch('"', tok);
i2 = revCharSearch('"', tok);
memcpy(url, &tok[i1], i2-i1+1);
ans = resolveReference(url, f);
freeMem(url);
return ans;
}
示例6: assignSlot
void
assignSlot (RDF_Resource u, char* slot, char* value, RDFFile f)
{
PRBool tv = true;
char* tvstr;
if (value[0] == '(') {
tv = false;
value = &value[1];
value[strlen(value)-1] = '\0';
}
if (tv) {
tvstr = "true";
} else tvstr = "false";
if (startsWith("default_genl", slot)) return;
if (startsWith("name", slot) || (startsWith("local-name", slot))) {
value[strlen(value)-1] = '\0';
addSlotValue(f, u, gCoreVocab->RDF_name, copyString(&value[1]), RDF_STRING_TYPE, tvstr);
} else if (startsWith("specs", slot) || (startsWith("child", slot))) {
RDF_Resource spec = resolveReference(value, f);
if (!nullp(spec)) addSlotValue(f, spec, gCoreVocab->RDF_parent, u, RDF_RESOURCE_TYPE, tvstr);
} else if (startsWith("genls_pos", slot)) {
RDF_Resource genl = resolveGenlPosReference(value, f);
if (!nullp(genl)) addSlotValue(f, u, gCoreVocab->RDF_parent, genl, RDF_RESOURCE_TYPE, tvstr);
} else if ((startsWith("genls", slot)) || (startsWith("parent", slot))) {
RDF_Resource genl = resolveReference(value, f);
if (!nullp(genl)) addSlotValue(f, u, gCoreVocab->RDF_parent, genl, RDF_RESOURCE_TYPE, tvstr);
} else {
void* parsed_value;
RDF_ValueType data_type;
RDF_Resource s = RDF_GetResource(NULL, slot, true);
RDF_Error err = parseSlotValue(f, s, value, &parsed_value, &data_type);
if ((err == noRDFErr) && (!nullp(parsed_value)))
addSlotValue(f, u, s, parsed_value, data_type, tvstr);
}
}
示例7: parseNextMCFLine
void
parseNextMCFLine (RDFFile f, char* line)
{
char* nextToken ;
int16 offset = 0;
RDF_Error err;
if ((nullp(line)) || (line[0] == '\0'))return;
nextToken = getMem(MAX_URL_SIZE);
err = getFirstToken(line, nextToken, &offset);
offset++;
if ((err != noRDFErr) && (nextToken[0] == ';')) {
freeMem(nextToken);
return;
}
if (startsWith("begin-headers", nextToken)) {
f->status = HEADERS;
} else if (startsWith("end-headers", nextToken)) {
f->status = BODY;
} else if (startsWith("unit", nextToken)) {
f->status = BODY;
if (!(nullp(f->currentResource))) resourceTransition(f);
getFirstToken(&line[offset], nextToken, &offset);
f->currentResource = resolveReference(nextToken, f);
} else if (nextToken[strlen(nextToken)-1] == ':') {
memset(f->currentSlot, '\0', 100);
memcpy(f->currentSlot, nextToken, strlen(nextToken)-1);
while (getFirstToken(&line[offset], nextToken, &offset) == noRDFErr) {
if (f->status == HEADERS) {
assignHeaderSlot(f, f->currentSlot, nextToken);
} else if (f->currentResource) {
assignSlot(f->currentResource, f->currentSlot, nextToken, f);
}
offset++;
}
}
freeMem(nextToken);
}
示例8: resolveReference
Value &
Value::operator[]( const char *key )
{
return resolveReference( key, false );
}
示例9: resolveReference
Value &
Value::atStr( const StaticString &key )
{
return resolveReference( key, true );
}
示例10: resolveReference
Value& Value::operator[](const CppTL::ConstString& key) {
return resolveReference(key.c_str(), key.end_c_str());
}
示例11: readLine
bool PdfBookReader::readBook(shared_ptr<ZLInputStream> stream) {
if (stream.isNull() || !stream->open()) {
return false;
}
readLine(*stream, myBuffer);
if (!ZLStringUtil::stringStartsWith(myBuffer, "%PDF-")) {
return false;
}
std::string version = myBuffer.substr(5);
std::cerr << "version = " << version << "\n";
size_t eofOffset = stream->sizeOfOpened();
if (eofOffset < 100) {
return false;
}
stream->seek(eofOffset - 100, true);
bool readXrefOffset = false;
size_t xrefOffset = (size_t)-1;
while (true) {
readLine(*stream, myBuffer);
if (myBuffer.empty()) {
break;
}
stripBuffer(myBuffer);
if (readXrefOffset) {
if (!myBuffer.empty()) {
xrefOffset = atoi(myBuffer.c_str());
break;
}
} else if (myBuffer == "startxref") {
readXrefOffset = true;
}
}
if (!readReferenceTable(*stream, xrefOffset)) {
return false;
}
PdfDictionaryObject &trailerDictionary = (PdfDictionaryObject&)*myTrailer;
shared_ptr<PdfObject> root = resolveReference(trailerDictionary["Root"], *stream);
if (root.isNull() || (root->type() != PdfObject::DICTIONARY)) {
return false;
}
PdfDictionaryObject &rootDictionary = (PdfDictionaryObject&)*root;
if (rootDictionary["Type"] != PdfNameObject::nameObject("Catalog")) {
return false;
}
shared_ptr<PdfObject> pageRootNode = resolveReference(rootDictionary["Pages"], *stream);
if (pageRootNode.isNull() || (pageRootNode->type() != PdfObject::DICTIONARY)) {
return false;
}
PdfDictionaryObject &pageRootNodeDictionary = (PdfDictionaryObject&)*pageRootNode;
if (pageRootNodeDictionary["Type"] != PdfNameObject::nameObject("Pages")) {
return false;
}
/*
shared_ptr<PdfObject> count = pageRootNodeDictionary["Count"];
if (!count.isNull() && (count->type() == PdfObject::INTEGER_NUMBER)) {
std::cerr << "count = " << ((PdfIntegerObject&)*count).value() << "\n";
}
*/
shared_ptr<PdfObject> pages = pageRootNodeDictionary["Kids"];
if (pages.isNull() || (pages->type() != PdfObject::ARRAY)) {
return false;
}
const PdfArrayObject& pagesArray = (const PdfArrayObject&)*pages;
const size_t pageNumber = pagesArray.size();
for (size_t i = 0; i < pageNumber; ++i) {
processPage(pagesArray[i], *stream);
}
return true;
}
示例12: JSON_ASSERT_MESSAGE
Value* Value::demand(char const* begin, char const* end) {
JSON_ASSERT_MESSAGE(type() == nullValue || type() == objectValue,
"in Json::Value::demand(begin, end): requires "
"objectValue or nullValue");
return &resolveReference(begin, end);
}
示例13: resolveReference
Value& Value::operator[](const String& key) {
return resolveReference(key.data(), key.data() + key.length());
}