本文整理汇总了C++中BaseParser类的典型用法代码示例。如果您正苦于以下问题:C++ BaseParser类的具体用法?C++ BaseParser怎么用?C++ BaseParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BaseParserPtr
BaseParserPtr BaseParser::FindSymbol(const std::string& name, bool curScope)
{
if(m_parent == nullptr)
{
return BaseParserPtr();
}
if(curScope)
{
for(auto v : m_parent->m_members)
{
if(v->Name() == name)
{
return v;
}
}
return false;
}
BaseParser* pNode = m_parent;
while(pNode)
{
for(auto v : pNode->m_members)
{
if(v->Name() == name)
{
return v;
}
}
pNode = pNode->Parent();
}
return false;
}
示例2: TOKEN_TABLE_START
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdScaleLevel::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(SCALE_LEVEL)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(Y)
TOKEN_TABLE(SCALE)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE_END
byte *params;
int cmd;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SCALE_LEVEL) {
_gameRef->LOG(0, "'SCALE_LEVEL' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
if (DID_FAIL(loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_Y:
parser.scanStr((char *)params, "%d", &_posY);
break;
case TOKEN_SCALE: {
int i;
parser.scanStr((char *)params, "%d", &i);
_scale = (float)i;
}
break;
case TOKEN_EDITOR_PROPERTY:
parseEditorProperty(params, false);
break;
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
_gameRef->LOG(0, "Syntax error in SCALE_LEVEL definition");
return STATUS_FAILED;
}
return STATUS_OK;
}
示例3: TOKEN_TABLE_START
bool AdActor::mergeAnims(const char *animsFilename) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(ANIMATION)
TOKEN_TABLE_END
byte *fileBuffer = BaseFileManager::getEngineInstance()->readWholeFile(animsFilename);
if (fileBuffer == nullptr) {
_gameRef->LOG(0, "AdActor::MergeAnims failed for file '%s'", animsFilename);
return STATUS_FAILED;
}
byte *buffer = fileBuffer;
byte *params;
int cmd;
BaseParser parser;
bool ret = STATUS_OK;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_ANIMATION: {
AdSpriteSet *anim = new AdSpriteSet(_gameRef, this);
if (!anim || DID_FAIL(anim->loadBuffer(params, false))) {
cmd = PARSERR_GENERIC;
ret = STATUS_FAILED;
} else {
_anims.add(anim);
}
}
break;
}
}
delete[] fileBuffer;
return ret;
}
示例4: TOKEN_TABLE_START
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdRegion::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(REGION)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(NAME)
TOKEN_TABLE(ACTIVE)
TOKEN_TABLE(ZOOM)
TOKEN_TABLE(SCALE)
TOKEN_TABLE(BLOCKED)
TOKEN_TABLE(DECORATION)
TOKEN_TABLE(POINT)
TOKEN_TABLE(ALPHA_COLOR)
TOKEN_TABLE(ALPHA)
TOKEN_TABLE(EDITOR_SELECTED_POINT)
TOKEN_TABLE(EDITOR_SELECTED)
TOKEN_TABLE(SCRIPT)
TOKEN_TABLE(CAPTION)
TOKEN_TABLE(PROPERTY)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE_END
byte *params;
int cmd;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) {
_gameRef->LOG(0, "'REGION' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
for (uint32 i = 0; i < _points.size(); i++) {
delete _points[i];
}
_points.clear();
int ar = 255, ag = 255, ab = 255, alpha = 255;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
if (DID_FAIL(loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_NAME:
setName((char *)params);
break;
case TOKEN_CAPTION:
setCaption((char *)params);
break;
case TOKEN_ACTIVE:
parser.scanStr((char *)params, "%b", &_active);
break;
case TOKEN_BLOCKED:
parser.scanStr((char *)params, "%b", &_blocked);
break;
case TOKEN_DECORATION:
parser.scanStr((char *)params, "%b", &_decoration);
break;
case TOKEN_ZOOM:
case TOKEN_SCALE: {
int j;
parser.scanStr((char *)params, "%d", &j);
_zoom = (float)j;
}
break;
case TOKEN_POINT: {
int x, y;
parser.scanStr((char *)params, "%d,%d", &x, &y);
_points.add(new BasePoint(x, y));
}
break;
case TOKEN_ALPHA_COLOR:
parser.scanStr((char *)params, "%d,%d,%d", &ar, &ag, &ab);
break;
case TOKEN_ALPHA:
parser.scanStr((char *)params, "%d", &alpha);
break;
case TOKEN_EDITOR_SELECTED:
parser.scanStr((char *)params, "%b", &_editorSelected);
break;
case TOKEN_EDITOR_SELECTED_POINT:
parser.scanStr((char *)params, "%d", &_editorSelectedPoint);
break;
//.........这里部分代码省略.........
示例5: TOKEN_TABLE_START
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdResponseBox::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(RESPONSE_BOX)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(FONT_HOVER)
TOKEN_TABLE(FONT)
TOKEN_TABLE(AREA)
TOKEN_TABLE(HORIZONTAL)
TOKEN_TABLE(SPACING)
TOKEN_TABLE(WINDOW)
TOKEN_TABLE(CURSOR)
TOKEN_TABLE(TEXT_ALIGN)
TOKEN_TABLE(VERTICAL_ALIGN)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE_END
byte *params;
int cmd;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_RESPONSE_BOX) {
_gameRef->LOG(0, "'RESPONSE_BOX' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
if (DID_FAIL(loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_WINDOW:
delete _window;
_window = new UIWindow(_gameRef);
if (!_window || DID_FAIL(_window->loadBuffer(params, false))) {
delete _window;
_window = nullptr;
cmd = PARSERR_GENERIC;
} else if (_shieldWindow) {
_shieldWindow->_parent = _window;
}
break;
case TOKEN_FONT:
if (_font) {
_gameRef->_fontStorage->removeFont(_font);
}
_font = _gameRef->_fontStorage->addFont((char *)params);
if (!_font) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_FONT_HOVER:
if (_fontHover) {
_gameRef->_fontStorage->removeFont(_fontHover);
}
_fontHover = _gameRef->_fontStorage->addFont((char *)params);
if (!_fontHover) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_AREA:
parser.scanStr((char *)params, "%d,%d,%d,%d", &_responseArea.left, &_responseArea.top, &_responseArea.right, &_responseArea.bottom);
break;
case TOKEN_HORIZONTAL:
parser.scanStr((char *)params, "%b", &_horizontal);
break;
case TOKEN_TEXT_ALIGN:
if (scumm_stricmp((char *)params, "center") == 0) {
_align = TAL_CENTER;
} else if (scumm_stricmp((char *)params, "right") == 0) {
_align = TAL_RIGHT;
} else {
_align = TAL_LEFT;
}
break;
case TOKEN_VERTICAL_ALIGN:
if (scumm_stricmp((char *)params, "top") == 0) {
_verticalAlign = VAL_TOP;
} else if (scumm_stricmp((char *)params, "center") == 0) {
_verticalAlign = VAL_CENTER;
} else {
_verticalAlign = VAL_BOTTOM;
}
break;
case TOKEN_SPACING:
//.........这里部分代码省略.........
示例6: main
//.........这里部分代码省略.........
SimpleLogger().Write(logWARNING) << "No input file specified";
SimpleLogger().Write() << visible_options;
return -1;
}
if(1 > requested_num_threads) {
SimpleLogger().Write(logWARNING) << "Number of threads must be 1 or larger";
return -1;
}
SimpleLogger().Write() << "Input file: " << input_path.filename().string();
SimpleLogger().Write() << "Profile: " << profile_path.filename().string();
SimpleLogger().Write() << "Threads: " << requested_num_threads;
/*** Setup Scripting Environment ***/
ScriptingEnvironment scriptingEnvironment(profile_path.c_str());
omp_set_num_threads( std::min( omp_get_num_procs(), requested_num_threads) );
bool file_has_pbf_format(false);
std::string output_file_name(input_path.c_str());
std::string restrictionsFileName(input_path.c_str());
std::string::size_type pos = output_file_name.find(".osm.bz2");
if(pos==std::string::npos) {
pos = output_file_name.find(".osm.pbf");
if(pos!=std::string::npos) {
file_has_pbf_format = true;
}
}
if(pos==std::string::npos) {
pos = output_file_name.find(".pbf");
if(pos!=std::string::npos) {
file_has_pbf_format = true;
}
}
if(pos!=std::string::npos) {
output_file_name.replace(pos, 8, ".osrm");
restrictionsFileName.replace(pos, 8, ".osrm.restrictions");
} else {
pos=output_file_name.find(".osm");
if(pos!=std::string::npos) {
output_file_name.replace(pos, 5, ".osrm");
restrictionsFileName.replace(pos, 5, ".osrm.restrictions");
} else {
output_file_name.append(".osrm");
restrictionsFileName.append(".osrm.restrictions");
}
}
StringMap stringMap;
ExtractionContainers externalMemory;
stringMap[""] = 0;
extractCallBacks = new ExtractorCallbacks(&externalMemory, &stringMap);
BaseParser* parser;
if(file_has_pbf_format) {
parser = new PBFParser(input_path.c_str(), extractCallBacks, scriptingEnvironment);
} else {
parser = new XMLParser(input_path.c_str(), extractCallBacks, scriptingEnvironment);
}
if(!parser->ReadHeader()) {
throw OSRMException("Parser not initialized!");
}
SimpleLogger().Write() << "Parsing in progress..";
double parsing_start_time = get_timestamp();
parser->Parse();
SimpleLogger().Write() << "Parsing finished after " <<
(get_timestamp() - parsing_start_time) <<
" seconds";
if( externalMemory.all_edges_list.empty() ) {
SimpleLogger().Write(logWARNING) << "The input data is empty, exiting.";
return -1;
}
externalMemory.PrepareData(output_file_name, restrictionsFileName);
delete parser;
delete extractCallBacks;
SimpleLogger().Write() <<
"extraction finished after " << get_timestamp() - startup_time <<
"s";
SimpleLogger().Write() << "To prepare the data for routing, run: "
<< "./osrm-prepare " << output_file_name << std::endl;
} catch(boost::program_options::too_many_positional_options_error& e) {
SimpleLogger().Write(logWARNING) << "Only one input file can be specified";
return -1;
} catch(boost::program_options::error& e) {
SimpleLogger().Write(logWARNING) << e.what();
return -1;
} catch(std::exception & e) {
SimpleLogger().Write(logWARNING) << "Unhandled exception: " << e.what();
return -1;
}
return 0;
}
示例7: TOKEN_TABLE_START
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(PROPERTY)
TOKEN_TABLE(NAME)
TOKEN_TABLE(VALUE)
TOKEN_TABLE_END
byte *params;
int cmd;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) {
_gameRef->LOG(0, "'PROPERTY' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
char *propName = NULL;
char *propValue = NULL;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_NAME:
delete[] propName;
propName = new char[strlen((char *)params) + 1];
if (propName) {
strcpy(propName, (char *)params);
} else {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_VALUE:
delete[] propValue;
propValue = new char[strlen((char *)params) + 1];
if (propValue) {
strcpy(propValue, (char *)params);
} else {
cmd = PARSERR_GENERIC;
}
break;
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
delete[] propName;
delete[] propValue;
propName = NULL;
propValue = NULL;
_gameRef->LOG(0, "Syntax error in PROPERTY definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) {
delete[] propName;
delete[] propValue;
propName = NULL;
propValue = NULL;
_gameRef->LOG(0, "Error loading PROPERTY definition");
return STATUS_FAILED;
}
ScValue *val = new ScValue(_gameRef);
val->setString(propValue);
scSetProperty(propName, val);
delete val;
delete[] propName;
delete[] propValue;
propName = NULL;
propValue = NULL;
return STATUS_OK;
}
示例8: TOKEN_TABLE_START
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdTalkDef::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(TALK)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(ACTION)
TOKEN_TABLE(DEFAULT_SPRITESET_FILE)
TOKEN_TABLE(DEFAULT_SPRITESET)
TOKEN_TABLE(DEFAULT_SPRITE)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE_END
byte *params;
int cmd;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TALK) {
_gameRef->LOG(0, "'TALK' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
if (DID_FAIL(loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_ACTION: {
AdTalkNode *node = new AdTalkNode(_gameRef);
if (node && DID_SUCCEED(node->loadBuffer(params, false))) {
_nodes.add(node);
} else {
delete node;
node = nullptr;
cmd = PARSERR_GENERIC;
}
}
break;
case TOKEN_DEFAULT_SPRITE:
BaseUtils::setString(&_defaultSpriteFilename, (char *)params);
break;
case TOKEN_DEFAULT_SPRITESET_FILE:
BaseUtils::setString(&_defaultSpriteSetFilename, (char *)params);
break;
case TOKEN_DEFAULT_SPRITESET: {
delete _defaultSpriteSet;
_defaultSpriteSet = new AdSpriteSet(_gameRef);
if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadBuffer(params, false))) {
delete _defaultSpriteSet;
_defaultSpriteSet = nullptr;
cmd = PARSERR_GENERIC;
}
}
break;
case TOKEN_EDITOR_PROPERTY:
parseEditorProperty(params, false);
break;
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
_gameRef->LOG(0, "Syntax error in TALK definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
_gameRef->LOG(0, "Error loading TALK definition");
return STATUS_FAILED;
}
delete _defaultSprite;
delete _defaultSpriteSet;
_defaultSprite = nullptr;
_defaultSpriteSet = nullptr;
if (_defaultSpriteFilename) {
_defaultSprite = new BaseSprite(_gameRef);
if (!_defaultSprite || DID_FAIL(_defaultSprite->loadFile(_defaultSpriteFilename))) {
return STATUS_FAILED;
}
}
if (_defaultSpriteSetFilename) {
_defaultSpriteSet = new AdSpriteSet(_gameRef);
if (!_defaultSpriteSet || DID_FAIL(_defaultSpriteSet->loadFile(_defaultSpriteSetFilename))) {
return STATUS_FAILED;
}
}
//.........这里部分代码省略.........
示例9: TOKEN_TABLE_START
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool UIEdit::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(DISABLED)
TOKEN_TABLE(VISIBLE)
TOKEN_TABLE(BACK)
TOKEN_TABLE(IMAGE)
TOKEN_TABLE(FONT_SELECTED)
TOKEN_TABLE(FONT)
TOKEN_TABLE(TEXT)
TOKEN_TABLE(X)
TOKEN_TABLE(Y)
TOKEN_TABLE(WIDTH)
TOKEN_TABLE(HEIGHT)
TOKEN_TABLE(CURSOR_BLINK_RATE)
TOKEN_TABLE(CURSOR)
TOKEN_TABLE(FRAME_WIDTH)
TOKEN_TABLE(NAME)
TOKEN_TABLE(SCRIPT)
TOKEN_TABLE(PARENT_NOTIFY)
TOKEN_TABLE(MAX_LENGTH)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE(EDIT)
TOKEN_TABLE(CAPTION)
TOKEN_TABLE_END
byte *params;
int cmd = 2;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDIT) {
_gameRef->LOG(0, "'EDIT' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
if (DID_FAIL(loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_NAME:
setName((char *)params);
break;
case TOKEN_BACK:
delete _back;
_back = new UITiledImage(_gameRef);
if (!_back || DID_FAIL(_back->loadFile((char *)params))) {
delete _back;
_back = NULL;
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_IMAGE:
delete _image;
_image = new BaseSprite(_gameRef);
if (!_image || DID_FAIL(_image->loadFile((char *)params))) {
delete _image;
_image = NULL;
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_FONT:
if (_font) {
_gameRef->_fontStorage->removeFont(_font);
}
_font = _gameRef->_fontStorage->addFont((char *)params);
if (!_font) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_FONT_SELECTED:
if (_fontSelected) {
_gameRef->_fontStorage->removeFont(_fontSelected);
}
_fontSelected = _gameRef->_fontStorage->addFont((char *)params);
if (!_fontSelected) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_TEXT:
setText((char *)params);
_gameRef->_stringTable->expand(&_text);
break;
case TOKEN_X:
parser.scanStr((char *)params, "%d", &_posX);
break;
//.........这里部分代码省略.........
示例10: TOKEN_TABLE_START
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool BaseGameSettings::loadSettings(const char *filename) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(SETTINGS)
TOKEN_TABLE(GAME)
TOKEN_TABLE(STRING_TABLE)
TOKEN_TABLE(RESOLUTION)
TOKEN_TABLE(REQUIRE_3D_ACCELERATION)
TOKEN_TABLE(REQUIRE_SOUND)
TOKEN_TABLE(HWTL_MODE)
TOKEN_TABLE(ALLOW_WINDOWED_MODE)
TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB)
TOKEN_TABLE(ALLOW_ABOUT_TAB)
TOKEN_TABLE(ALLOW_ADVANCED)
TOKEN_TABLE(ALLOW_DESKTOP_RES)
TOKEN_TABLE(REGISTRY_PATH)
TOKEN_TABLE(RICH_SAVED_GAMES)
TOKEN_TABLE(SAVED_GAME_EXT)
TOKEN_TABLE(GUID)
TOKEN_TABLE_END
byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename);
if (origBuffer == nullptr) {
BaseEngine::LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename);
return STATUS_FAILED;
}
bool ret = STATUS_OK;
byte *buffer = origBuffer;
byte *params;
int cmd;
BaseParser parser;
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) {
BaseEngine::LOG(0, "'SETTINGS' keyword expected in game settings file.");
return STATUS_FAILED;
}
buffer = params;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_GAME:
delete[] _gameFile;
_gameFile = new char[strlen((char *)params) + 1];
if (_gameFile) {
strcpy(_gameFile, (char *)params);
}
break;
case TOKEN_STRING_TABLE:
if (DID_FAIL(_stringTable->loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_RESOLUTION:
parser.scanStr((char *)params, "%d,%d", &_resWidth, &_resHeight);
break;
case TOKEN_REQUIRE_3D_ACCELERATION:
parser.scanStr((char *)params, "%b", &_requireAcceleration);
break;
case TOKEN_REQUIRE_SOUND:
parser.scanStr((char *)params, "%b", &_requireSound);
break;
case TOKEN_HWTL_MODE:
parser.scanStr((char *)params, "%d", &_TLMode);
break;
case TOKEN_ALLOW_WINDOWED_MODE:
parser.scanStr((char *)params, "%b", &_allowWindowed);
break;
case TOKEN_ALLOW_DESKTOP_RES:
parser.scanStr((char *)params, "%b", &_allowDesktopRes);
break;
case TOKEN_ALLOW_ADVANCED:
parser.scanStr((char *)params, "%b", &_allowAdvanced);
break;
case TOKEN_ALLOW_ACCESSIBILITY_TAB:
parser.scanStr((char *)params, "%b", &_allowAccessTab);
break;
case TOKEN_ALLOW_ABOUT_TAB:
parser.scanStr((char *)params, "%b", &_allowAboutTab);
break;
case TOKEN_REGISTRY_PATH:
//BaseEngine::instance().getRegistry()->setBasePath((char *)params);
break;
case TOKEN_RICH_SAVED_GAMES:
parser.scanStr((char *)params, "%b", &_richSavedGames);
//.........这里部分代码省略.........
示例11: TOKEN_TABLE_START
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool UIText::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(STATIC)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(DISABLED)
TOKEN_TABLE(VISIBLE)
TOKEN_TABLE(BACK)
TOKEN_TABLE(IMAGE)
TOKEN_TABLE(FONT)
TOKEN_TABLE(TEXT_ALIGN)
TOKEN_TABLE(VERTICAL_ALIGN)
TOKEN_TABLE(TEXT)
TOKEN_TABLE(X)
TOKEN_TABLE(Y)
TOKEN_TABLE(WIDTH)
TOKEN_TABLE(HEIGHT)
TOKEN_TABLE(CURSOR)
TOKEN_TABLE(NAME)
TOKEN_TABLE(SCRIPT)
TOKEN_TABLE(CAPTION)
TOKEN_TABLE(PARENT_NOTIFY)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE_END
byte *params;
int cmd = 2;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_STATIC) {
_gameRef->LOG(0, "'STATIC' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
if (DID_FAIL(loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_NAME:
setName((char *)params);
break;
case TOKEN_CAPTION:
setCaption((char *)params);
break;
case TOKEN_BACK:
delete _back;
_back = new UITiledImage(_gameRef);
if (!_back || DID_FAIL(_back->loadFile((char *)params))) {
delete _back;
_back = nullptr;
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_IMAGE:
delete _image;
_image = new BaseSprite(_gameRef);
if (!_image || DID_FAIL(_image->loadFile((char *)params))) {
delete _image;
_image = nullptr;
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_FONT:
if (_font) {
_gameRef->_fontStorage->removeFont(_font);
}
_font = _gameRef->_fontStorage->addFont((char *)params);
if (!_font) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_TEXT:
setText((char *)params);
_gameRef->expandStringByStringTable(&_text);
break;
case TOKEN_TEXT_ALIGN:
if (scumm_stricmp((char *)params, "left") == 0) {
_textAlign = TAL_LEFT;
} else if (scumm_stricmp((char *)params, "right") == 0) {
_textAlign = TAL_RIGHT;
} else {
_textAlign = TAL_CENTER;
}
break;
case TOKEN_VERTICAL_ALIGN:
//.........这里部分代码省略.........
示例12: TOKEN_TABLE_START
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool UIButton::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(BUTTON)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(DISABLED)
TOKEN_TABLE(VISIBLE)
TOKEN_TABLE(FOCUSABLE)
TOKEN_TABLE(BACK_HOVER)
TOKEN_TABLE(BACK_PRESS)
TOKEN_TABLE(BACK_DISABLE)
TOKEN_TABLE(BACK_FOCUS)
TOKEN_TABLE(BACK)
TOKEN_TABLE(CENTER_IMAGE)
TOKEN_TABLE(IMAGE_HOVER)
TOKEN_TABLE(IMAGE_PRESS)
TOKEN_TABLE(IMAGE_DISABLE)
TOKEN_TABLE(IMAGE_FOCUS)
TOKEN_TABLE(IMAGE)
TOKEN_TABLE(FONT_HOVER)
TOKEN_TABLE(FONT_PRESS)
TOKEN_TABLE(FONT_DISABLE)
TOKEN_TABLE(FONT_FOCUS)
TOKEN_TABLE(FONT)
TOKEN_TABLE(TEXT_ALIGN)
TOKEN_TABLE(TEXT)
TOKEN_TABLE(X)
TOKEN_TABLE(Y)
TOKEN_TABLE(WIDTH)
TOKEN_TABLE(HEIGHT)
TOKEN_TABLE(CURSOR)
TOKEN_TABLE(NAME)
TOKEN_TABLE(EVENTS)
TOKEN_TABLE(SCRIPT)
TOKEN_TABLE(CAPTION)
TOKEN_TABLE(PARENT_NOTIFY)
TOKEN_TABLE(PRESSED)
TOKEN_TABLE(PIXEL_PERFECT)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE_END
byte *params;
int cmd = 2;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_BUTTON) {
_gameRef->LOG(0, "'BUTTON' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
while (cmd > 0 && (cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
if (DID_FAIL(loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_NAME:
setName((char *)params);
break;
case TOKEN_CAPTION:
setCaption((char *)params);
break;
case TOKEN_BACK:
delete _back;
_back = new UITiledImage(_gameRef);
if (!_back || DID_FAIL(_back->loadFile((char *)params))) {
delete _back;
_back = nullptr;
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_BACK_HOVER:
delete _backHover;
_backHover = new UITiledImage(_gameRef);
if (!_backHover || DID_FAIL(_backHover->loadFile((char *)params))) {
delete _backHover;
_backHover = nullptr;
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_BACK_PRESS:
delete _backPress;
_backPress = new UITiledImage(_gameRef);
if (!_backPress || DID_FAIL(_backPress->loadFile((char *)params))) {
delete _backPress;
_backPress = nullptr;
cmd = PARSERR_GENERIC;
}
break;
//.........这里部分代码省略.........
示例13: TOKEN_TABLE_START
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdEntity::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(ENTITY)
TOKEN_TABLE(SPRITE)
TOKEN_TABLE(X)
TOKEN_TABLE(Y)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(NAME)
TOKEN_TABLE(SCALABLE)
TOKEN_TABLE(REGISTRABLE)
TOKEN_TABLE(INTERACTIVE)
TOKEN_TABLE(SHADOWABLE)
TOKEN_TABLE(COLORABLE)
TOKEN_TABLE(ACTIVE)
TOKEN_TABLE(EVENTS)
TOKEN_TABLE(FONT)
TOKEN_TABLE(TALK_SPECIAL)
TOKEN_TABLE(TALK)
TOKEN_TABLE(CURSOR)
TOKEN_TABLE(REGION)
TOKEN_TABLE(BLOCKED_REGION)
TOKEN_TABLE(EDITOR_SELECTED)
TOKEN_TABLE(SCRIPT)
TOKEN_TABLE(SOUND_START_TIME)
TOKEN_TABLE(SOUND_VOLUME)
TOKEN_TABLE(SOUND_PANNING)
TOKEN_TABLE(SOUND)
TOKEN_TABLE(SUBTYPE)
TOKEN_TABLE(CAPTION)
TOKEN_TABLE(PROPERTY)
TOKEN_TABLE(WAYPOINTS)
TOKEN_TABLE(IGNORE_ITEMS)
TOKEN_TABLE(ROTABLE)
TOKEN_TABLE(ROTATABLE)
TOKEN_TABLE(ALPHA_COLOR)
TOKEN_TABLE(SCALE)
TOKEN_TABLE(RELATIVE_SCALE)
TOKEN_TABLE(ALPHA)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE(ITEM)
TOKEN_TABLE(WALK_TO_X)
TOKEN_TABLE(WALK_TO_Y)
TOKEN_TABLE(WALK_TO_DIR)
TOKEN_TABLE(SAVE_STATE)
TOKEN_TABLE_END
byte *params;
int cmd;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) {
_gameRef->LOG(0, "'ENTITY' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
AdGame *adGame = (AdGame *)_gameRef;
BaseSprite *spr = nullptr;
int ar = 0, ag = 0, ab = 0, alpha = 0;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
if (DID_FAIL(loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_X:
parser.scanStr((char *)params, "%d", &_posX);
break;
case TOKEN_Y:
parser.scanStr((char *)params, "%d", &_posY);
break;
case TOKEN_SPRITE: {
delete _sprite;
_sprite = nullptr;
spr = new BaseSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
} else {
_sprite = spr;
}
}
break;
case TOKEN_TALK: {
spr = new BaseSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) {
cmd = PARSERR_GENERIC;
} else {
_talkSprites.add(spr);
}
}
break;
//.........这里部分代码省略.........
示例14: TIMER_START
int Extractor::Run(int argc, char *argv[])
{
try
{
LogPolicy::GetInstance().Unmute();
TIMER_START(extracting);
if (!ParseArguments(argc, argv))
return 0;
if (1 > requested_num_threads)
{
SimpleLogger().Write(logWARNING) << "Number of threads must be 1 or larger";
return 1;
}
if (!boost::filesystem::is_regular_file(input_path))
{
SimpleLogger().Write(logWARNING) << "Input file " << input_path.string()
<< " not found!";
return 1;
}
if (!boost::filesystem::is_regular_file(profile_path))
{
SimpleLogger().Write(logWARNING) << "Profile " << profile_path.string()
<< " not found!";
return 1;
}
const unsigned recommended_num_threads = tbb::task_scheduler_init::default_num_threads();
SimpleLogger().Write() << "Input file: " << input_path.filename().string();
SimpleLogger().Write() << "Profile: " << profile_path.filename().string();
SimpleLogger().Write() << "Threads: " << requested_num_threads;
if (recommended_num_threads != requested_num_threads)
{
SimpleLogger().Write(logWARNING) << "The recommended number of threads is "
<< recommended_num_threads
<< "! This setting may have performance side-effects.";
}
tbb::task_scheduler_init init(requested_num_threads);
/*** Setup Scripting Environment ***/
ScriptingEnvironment scripting_environment(profile_path.string().c_str());
GenerateOutputFilesNames();
std::unordered_map<std::string, NodeID> string_map;
ExtractionContainers extraction_containers;
string_map[""] = 0;
auto extractor_callbacks = new ExtractorCallbacks(extraction_containers, string_map);
BaseParser *parser;
if (file_has_pbf_format)
{
parser = new PBFParser(input_path.string().c_str(),
extractor_callbacks,
scripting_environment,
requested_num_threads);
}
else
{
parser = new XMLParser(input_path.string().c_str(),
extractor_callbacks,
scripting_environment);
}
if (!parser->ReadHeader())
{
throw OSRMException("Parser not initialized!");
}
SimpleLogger().Write() << "Parsing in progress..";
TIMER_START(parsing);
parser->Parse();
delete parser;
delete extractor_callbacks;
TIMER_STOP(parsing);
SimpleLogger().Write() << "Parsing finished after " << TIMER_SEC(parsing) << " seconds";
if (extraction_containers.all_edges_list.empty())
{
SimpleLogger().Write(logWARNING) << "The input data is empty, exiting.";
return 1;
}
extraction_containers.PrepareData(output_file_name, restriction_file_name);
TIMER_STOP(extracting);
SimpleLogger().Write() << "extraction finished after " << TIMER_SEC(extracting) << "s";
SimpleLogger().Write() << "To prepare the data for routing, run: "
<< "./osrm-prepare " << output_file_name << std::endl;
}
catch (boost::program_options::too_many_positional_options_error &)
{
//.........这里部分代码省略.........
示例15: TOKEN_TABLE_START
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdTalkNode::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(ACTION)
TOKEN_TABLE(SPRITESET_FILE)
TOKEN_TABLE(SPRITESET)
TOKEN_TABLE(SPRITE)
TOKEN_TABLE(START_TIME)
TOKEN_TABLE(END_TIME)
TOKEN_TABLE(COMMENT)
TOKEN_TABLE(PRECACHE)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE_END
byte *params;
int cmd;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ACTION) {
_gameRef->LOG(0, "'ACTION' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
_endTime = 0;
_playToEnd = false;
_preCache = false;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_SPRITE:
BaseUtils::setString(&_spriteFilename, (char *)params);
break;
case TOKEN_SPRITESET_FILE:
BaseUtils::setString(&_spriteSetFilename, (char *)params);
break;
case TOKEN_SPRITESET: {
delete _spriteSet;
_spriteSet = new AdSpriteSet(_gameRef);
if (!_spriteSet || DID_FAIL(_spriteSet->loadBuffer(params, false))) {
delete _spriteSet;
_spriteSet = nullptr;
cmd = PARSERR_GENERIC;
}
}
break;
case TOKEN_START_TIME:
parser.scanStr((char *)params, "%d", &_startTime);
break;
case TOKEN_END_TIME:
parser.scanStr((char *)params, "%d", &_endTime);
break;
case TOKEN_PRECACHE:
parser.scanStr((char *)params, "%b", &_preCache);
break;
case TOKEN_COMMENT:
if (_gameRef->_editorMode) {
BaseUtils::setString(&_comment, (char *)params);
}
break;
case TOKEN_EDITOR_PROPERTY:
parseEditorProperty(params, false);
break;
}
}
if (cmd == PARSERR_TOKENNOTFOUND) {
_gameRef->LOG(0, "Syntax error in ACTION definition");
return STATUS_FAILED;
}
if (cmd == PARSERR_GENERIC) {
_gameRef->LOG(0, "Error loading ACTION definition");
return STATUS_FAILED;
}
if (_endTime == 0) {
_playToEnd = true;
} else {
_playToEnd = false;
}
if (_preCache && _spriteFilename) {
delete _sprite;
_sprite = new BaseSprite(_gameRef);
if (!_sprite || DID_FAIL(_sprite->loadFile(_spriteFilename))) {
return STATUS_FAILED;
}
}
if (_preCache && _spriteSetFilename) {
//.........这里部分代码省略.........