本文整理汇总了C++中Number::Value方法的典型用法代码示例。如果您正苦于以下问题:C++ Number::Value方法的具体用法?C++ Number::Value怎么用?C++ Number::Value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Number
的用法示例。
在下文中一共展示了Number::Value方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Handle<Value> HashTable::MaxLoadFactor(const Arguments& args) {
HandleScope scope;
HashTable *obj = ObjectWrap::Unwrap<HashTable>(args.This());
if(args.Length() > 0) {
Number *num = static_cast<Number*>(*args[0]);
float factor = (float)num->Value();
if(factor > 0)
obj->map.max_load_factor(factor);
return scope.Close(Local<Value>());
} else {
float factor = obj->map.max_load_factor();
return scope.Close(Number::New((double)factor));
}
}
示例2: HandleUpdateSettings
static void HandleUpdateSettings(Object &obj)
{
auto UpdateHotkey = [&](HOTKEY_TYPE hotkey, const char *setting_name)
{
Object key_data = obj[setting_name];
if (!key_data.HasMember("keycode"))
return;
Boolean meta = key_data["meta"];
if (meta)
return hlog("meta modifier not supported for hotkey '%s' (%s)", HotKeyTypeName(hotkey), setting_name);
Boolean shift = key_data["shift"];
Boolean ctrl = key_data["ctrl"];
Boolean alt = key_data["alt"];
Number code = key_data["keycode"];
WORD mods = ((shift ? HOTKEYF_SHIFT : 0) |
(ctrl ? HOTKEYF_CONTROL : 0) |
(alt ? HOTKEYF_ALT : 0)) << 8;
hotkeys[hotkey] = mods | static_cast<int>(code.Value());
if (!hotkeys[hotkey])
return;
hlog("hotkey '%s' (%s) updated", HotKeyTypeName(hotkey), setting_name);
};
{
LOCK(hotkeys_mutex);
//UpdateHotkey(HOTKEY_Screenshot, "...?");
UpdateHotkey(HOTKEY_Bookmark, "bookmark_key");
UpdateHotkey(HOTKEY_Overlay, "highlight_key");
UpdateHotkey(HOTKEY_Stream, "stream_key");
}
}
示例3: filename
Map::Map(Gosu::Graphics& graphics, wstring fn) {
string filename(fn.begin(), fn.end());
string input;
ifstream inFile;
inFile.open(filename.c_str());
char buf[65536];
while (inFile.good()) {
inFile.getline(buf, 65536);
input += buf;
}
inFile.close();
stringstream stream(input);
Object root;
Reader::Read(root, stream);
String name = root["name"];
String author = root["author"];
String url = root["url"];
String version = root["version"];
String tilesetFilename = root["tileset"]["image"];
Number tileSizeNum = root["tileset"]["tilesize"];
this->tilesize = tileSizeNum.Value();
string ts = tilesetFilename.Value();
this->tileset.assign(ts.begin(), ts.end());
this->tileset = Gosu::resourcePrefix() + this->tileset;
wcout << this->tileset << endl;
Array tiledefs = root["tiledefs"];
Array tiles = root["tiles"];
vector<Tile> tileDefinitions;
Array::const_iterator itTiledefs(tiledefs.Begin()), itTiledefsEnd(tiledefs.End());
for (; itTiledefs != itTiledefsEnd; ++itTiledefs) {
Object def = *itTiledefs;
if (def.Find("offset") == def.End()) {
Tile tile(graphics, this->tileset, -this->tilesize, -this->tilesize, this->tilesize, false);
tileDefinitions.push_back(tile);
} else {
Number offX = def["offset"][0];
Number offY = def["offset"][1];
Boolean solid = def["solid"];
Tile tile(graphics, this->tileset, offX.Value(), offY.Value(), this->tilesize, solid.Value());
tileDefinitions.push_back(tile);
}
}
int x = 0;
int y = 0;
Array::const_iterator itTiles(tiles.Begin()), itTilesEnd(tiles.End());
for (; itTiles != itTilesEnd; ++itTiles) {
Array row = *itTiles;
Array::const_iterator itRow(row.Begin()), itRowEnd(row.End());
vector<Tile> tileRow;
for (; itRow != itRowEnd; ++itRow) {
Number tileRef = *itRow;
Tile tile(tileDefinitions[tileRef.Value()]);
tile.setPosition(Vec(x * this->tilesize, y * this->tilesize));
tileRow.insert(tileRow.begin()+x, tile);
x++;
}
this->tiles.insert(this->tiles.begin() + y, tileRow);
x = 0;
y++;
}
this->dim = Vec(this->tiles[0].size(), this->tiles.size());
}