本文整理汇总了C++中Tokenizer::getDouble方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokenizer::getDouble方法的具体用法?C++ Tokenizer::getDouble怎么用?C++ Tokenizer::getDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokenizer
的用法示例。
在下文中一共展示了Tokenizer::getDouble方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parse
/* CTPatchEx::parse
* Parses a ZDoom TEXTURES format patch definition
*******************************************************************/
bool CTPatchEx::parse(Tokenizer& tz, uint8_t type)
{
// Read basic info
this->type = type;
name = tz.getToken().Upper();
tz.getToken(); // Skip ,
offset_x = tz.getInteger();
tz.getToken(); // Skip ,
offset_y = tz.getInteger();
// Check if there is any extended info
if (tz.peekToken() == "{")
{
// Skip {
tz.getToken();
// Parse extended info
string property = tz.getToken();
while (property != "}")
{
// FlipX
if (S_CMPNOCASE(property, "FlipX"))
flip_x = true;
// FlipY
if (S_CMPNOCASE(property, "FlipY"))
flip_y = true;
// UseOffsets
if (S_CMPNOCASE(property, "UseOffsets"))
use_offsets = true;
// Rotate
if (S_CMPNOCASE(property, "Rotate"))
rotation = tz.getInteger();
// Translation
if (S_CMPNOCASE(property, "Translation"))
{
// Add first translation string
translation.parse(tz.getToken());
// Add any subsequent translations (separated by commas)
while (tz.peekToken() == ",")
{
tz.getToken(); // Skip ,
translation.parse(tz.getToken());
}
blendtype = 1;
}
// Blend
if (S_CMPNOCASE(property, "Blend"))
{
double val;
wxColour col;
blendtype = 2;
// Read first value
string first = tz.getToken();
// If no second value, it's just a colour string
if (tz.peekToken() != ",")
{
col.Set(first);
colour.set(col.Red(), col.Green(), col.Blue());
}
else
{
// Second value could be alpha or green
tz.getToken(); // Skip ,
double second = tz.getDouble();
// If no third value, it's an alpha value
if (tz.peekToken() != ",")
{
col.Set(first);
colour.set(col.Red(), col.Green(), col.Blue(), second*255);
blendtype = 3;
}
else
{
// Third value exists, must be R,G,B,A format
tz.getToken(); // Skip ,
first.ToDouble(&val);
colour.r = val*255;
colour.g = second*255;
colour.b = tz.getDouble()*255;
if (tz.peekToken() != ",")
{
wxLogMessage("Invalid TEXTURES definition, expected ',', got '%s'", tz.getToken());
return false;
}
tz.getToken(); // Skip ,
colour.a = tz.getDouble()*255;
blendtype = 3;
//.........这里部分代码省略.........
示例2: openMap
/* MapPreviewCanvas::openMap
* Opens a map from a mapdesc_t
*******************************************************************/
bool MapPreviewCanvas::openMap(Archive::mapdesc_t map)
{
// All errors = invalid map
Global::error = "Invalid map";
// Check if this map is a pk3 map
bool map_archive = false;
if (map.archive)
{
map_archive = true;
// Attempt to open entry as wad archive
temp_archive = new WadArchive();
if (!temp_archive->open(map.head))
{
delete temp_archive;
return false;
}
// Detect maps
vector<Archive::mapdesc_t> maps = temp_archive->detectMaps();
// Set map if there are any in the archive
if (maps.size() > 0)
map = maps[0];
else
return false;
}
// Parse UDMF map
if (map.format == MAP_UDMF)
{
ArchiveEntry* udmfdata = NULL;
for (ArchiveEntry* mapentry = map.head; mapentry != map.end; mapentry = mapentry->nextEntry())
{
// Check entry type
if (mapentry->getType() == EntryType::getType("udmf_textmap"))
{
udmfdata = mapentry;
break;
}
}
if (udmfdata == NULL)
return false;
// Start parsing
Tokenizer tz;
tz.openMem(udmfdata->getData(), udmfdata->getSize(), map.head->getName());
// Get first token
string token = tz.getToken();
size_t vertcounter = 0, linecounter = 0, thingcounter = 0;
while (!token.IsEmpty())
{
if (!token.CmpNoCase("namespace"))
{
// skip till we reach the ';'
do { token = tz.getToken(); }
while (token.Cmp(";"));
}
else if (!token.CmpNoCase("vertex"))
{
// Get X and Y properties
bool gotx = false;
bool goty = false;
double x = 0.;
double y = 0.;
do
{
token = tz.getToken();
if (!token.CmpNoCase("x") || !token.CmpNoCase("y"))
{
bool isx = !token.CmpNoCase("x");
token = tz.getToken();
if (token.Cmp("="))
{
wxLogMessage("Bad syntax for vertex %i in UDMF map data", vertcounter);
return false;
}
if (isx) x = tz.getDouble(), gotx = true;
else y = tz.getDouble(), goty = true;
// skip to end of declaration after each key
do { token = tz.getToken(); }
while (token.Cmp(";"));
}
}
while (token.Cmp("}"));
if (gotx && goty)
addVertex(x, y);
else
{
wxLogMessage("Wrong vertex %i in UDMF map data", vertcounter);
return false;
}
vertcounter++;
}
else if (!token.CmpNoCase("linedef"))
//.........这里部分代码省略.........
示例3: openMap
/* MapPreviewCanvas::openMap
* Opens a map from a mapdesc_t
*******************************************************************/
bool MapPreviewCanvas::openMap(Archive::mapdesc_t map)
{
// All errors = invalid map
Global::error = "Invalid map";
// Check if this map is a pk3 map
bool map_archive = false;
if (map.archive)
{
map_archive = true;
// Attempt to open entry as wad archive
temp_archive = new WadArchive();
if (!temp_archive->open(map.head))
{
delete temp_archive;
return false;
}
// Detect maps
vector<Archive::mapdesc_t> maps = temp_archive->detectMaps();
// Set map if there are any in the archive
if (maps.size() > 0)
map = maps[0];
else
return false;
}
// Parse UDMF map
if (map.format == MAP_UDMF)
{
ArchiveEntry* udmfdata = NULL;
for (ArchiveEntry* mapentry = map.head; mapentry != map.end; mapentry = mapentry->nextEntry())
{
// Check entry type
if (mapentry->getType() == EntryType::getType("udmf_textmap"))
{
udmfdata = mapentry;
break;
}
}
if (udmfdata == NULL)
return false;
// Start parsing
Tokenizer tz;
tz.openMem(udmfdata->getData(), udmfdata->getSize(), map.head->getName());
// Get first token
string token = tz.getToken();
size_t vertcounter = 0, linecounter = 0;
while (!token.IsEmpty())
{
if (!token.CmpNoCase("namespace"))
{
// skip till we reach the ';'
do { token = tz.getToken(); }
while (token.Cmp(";"));
}
else if (!token.CmpNoCase("vertex"))
{
// Get X and Y properties
bool gotx = false;
bool goty = false;
double x = 0.;
double y = 0.;
do
{
token = tz.getToken();
if (!token.CmpNoCase("x") || !token.CmpNoCase("y"))
{
bool isx = !token.CmpNoCase("x");
token = tz.getToken();
if (token.Cmp("="))
{
wxLogMessage("Bad syntax for vertex %i in UDMF map data", vertcounter);
return false;
}
if (isx) x = tz.getDouble(), gotx = true;
else y = tz.getDouble(), goty = true;
// skip to end of declaration after each key
do { token = tz.getToken(); }
while (token.Cmp(";"));
}
}
while (token.Cmp("}"));
if (gotx && goty)
addVertex(x, y);
else
{
wxLogMessage("Wrong vertex %i in UDMF map data", vertcounter);
return false;
}
vertcounter++;
}
else if (!token.CmpNoCase("linedef"))
//.........这里部分代码省略.........