Skip to content

kaityo256/param

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Single-header C++ library for parameter file

Usage

Pass the file name to the constructor.

param::parameter param(filename);

You can check the error on reading file as

  if (!param) {
    std::cerr << "Error occurs" << std::endl;
  }

The format of an input file (a parameter file) is key=value.

# Comment
bool=yes
int=12345
double=12.345

Lines starting with # are considered comments.

You can obtain the values by the keys.

bool b = param.get<bool>("bool");
int  i = param.get<int>("int");
double d = param.get<double>("double");

You can specify the default value at the second argument if a key does not exist.

bool b = param.get<bool>("non-existing key", false);
int  i = param.get<int>("non-existing key", 0);
double d = param.get<double>("non-existing key", 0.0);

License

This software is released under the MIT License, see LICENSE.

About

Single-header C++ library for parameter file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published