本文整理汇总了C++中ConfigReader::read方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigReader::read方法的具体用法?C++ ConfigReader::read怎么用?C++ ConfigReader::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigReader
的用法示例。
在下文中一共展示了ConfigReader::read方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool Config::init(const fs::path & file) {
fs::ifstream ifs;
ifs.open(file);
bool loaded = ifs.is_open();
ConfigReader reader;
if(!reader.read(ifs)) {
LogWarning << "Errors while parsing config file";
}
// Get locale language
language = reader.getKey(Section::Language, Key::language, Default::language);
// Get video settings
string resolution = reader.getKey(Section::Video, Key::resolution, Default::resolution);
if(resolution == "auto") {
video.resolution = Vec2i_ZERO;
} else {
video.resolution = parseResolution(resolution);
}
video.bpp = reader.getKey(Section::Video, Key::bpp, Default::bpp);
video.fullscreen = reader.getKey(Section::Video, Key::fullscreen, Default::fullscreen);
video.levelOfDetail = reader.getKey(Section::Video, Key::levelOfDetail, Default::levelOfDetail);
video.fogDistance = reader.getKey(Section::Video, Key::fogDistance, Default::fogDistance);
video.showCrosshair = reader.getKey(Section::Video, Key::showCrosshair, Default::showCrosshair);
video.antialiasing = reader.getKey(Section::Video, Key::antialiasing, Default::antialiasing);
video.vsync = reader.getKey(Section::Video, Key::vsync, Default::vsync);
// Get window settings
string windowSize = reader.getKey(Section::Window, Key::windowSize, Default::windowSize);
window.size = parseResolution(windowSize);
window.framework = reader.getKey(Section::Window, Key::windowFramework, Default::windowFramework);
// Get audio settings
audio.volume = reader.getKey(Section::Audio, Key::volume, Default::volume);
audio.sfxVolume = reader.getKey(Section::Audio, Key::sfxVolume, Default::sfxVolume);
audio.speechVolume = reader.getKey(Section::Audio, Key::speechVolume, Default::speechVolume);
audio.ambianceVolume = reader.getKey(Section::Audio, Key::ambianceVolume, Default::ambianceVolume);
audio.eax = reader.getKey(Section::Audio, Key::eax, Default::eax);
audio.backend = reader.getKey(Section::Audio, Key::audioBackend, Default::audioBackend);
// Get input settings
input.invertMouse = reader.getKey(Section::Input, Key::invertMouse, Default::invertMouse);
input.autoReadyWeapon = reader.getKey(Section::Input, Key::autoReadyWeapon, Default::autoReadyWeapon);
input.mouseLookToggle = reader.getKey(Section::Input, Key::mouseLookToggle, Default::mouseLookToggle);
input.mouseSensitivity = reader.getKey(Section::Input, Key::mouseSensitivity, Default::mouseSensitivity);
input.autoDescription = reader.getKey(Section::Input, Key::autoDescription, Default::autoDescription);
input.linkMouseLookToUse = reader.getKey(Section::Input, Key::linkMouseLookToUse, Default::linkMouseLookToUse);
input.backend = reader.getKey(Section::Input, Key::inputBackend, Default::inputBackend);
// Get action key settings
for(size_t i = 0; i < NUM_ACTION_KEY; i++) {
actions[i] = reader.getActionKey(Section::Key, (ControlAction)i);
}
// Get miscellaneous settings
misc.forceToggle = reader.getKey(Section::Misc, Key::forceToggle, Default::forceToggle);
misc.migration = (MigrationStatus)reader.getKey(Section::Misc, Key::migration, Default::migration);
misc.quicksaveSlots = std::max(reader.getKey(Section::Misc, Key::quicksaveSlots, Default::quicksaveSlots), 1);
misc.debug = reader.getKey(Section::Misc, Key::debugLevels, Default::debugLevels);
return loaded;
}