A class that represents a specific section in a configuration file. More...
#include "darknet_cfg.hpp"
Public Member Functions | |
CfgSection () | |
Consructor. | |
CfgSection (const std::string &l, const size_t ln) | |
Consructor. | |
~CfgSection () | |
Destructor. | |
CfgSection & | clear () |
Reset the section to be empty. | |
std::string | debug () const |
Iterate over the section and create a debug text message for every line. | |
bool | empty () const |
Determine if a section is empty. | |
float | find_float (const std::string &key, const float default_value) |
Find a float config item in lines. If the key does not exist, then the given default value is returned. | |
VFloat | find_float_array (const std::string &key) |
Find an array of float values in lines. If the key does not exist, then an empty std::vector is returned. | |
int | find_int (const std::string &key) |
Find an int config item in lines. The given key must exist. | |
int | find_int (const std::string &key, const int default_value) |
Find an int config item in lines. If the key does not exist, then the given default value is returned. | |
VInt | find_int_array (const std::string &key) |
Find an array of int values in lines. If the key does not exist, then an empty std::vector is returned. | |
std::string | find_str (const std::string &key, const std::string &default_value="") |
Find a text config item in lines. If the key does not exist, then the given default value is returned. | |
const CfgSection & | find_unused_lines () const |
Verify that there are no "unused" lines in this section. | |
Public Attributes | |
size_t | line_number |
Line number where this section starts. | |
CfgLines | lines |
All of the non-empty lines within a section. | |
std::string | name |
The name of the section (so we don't have to keep looking up the type). | |
ELayerType | type |
The layer type for this section (e.g., [convolutional] or [yolo]). | |
A class that represents a specific section in a configuration file.
The start of each section has a [name] delimiter which gives the section a name. For example, Darknet/YOLO config files start with either
[net] or
[network].
[net] or
[network], the section names are not unique. For example, a
.cfg file may have multiple
[conv] or
[yolo] sections. Darknet::CfgSection::CfgSection | ( | ) |
Consructor.
Darknet::CfgSection::CfgSection | ( | const std::string & | l, |
const size_t | ln | ||
) |
Consructor.
Darknet::CfgSection::~CfgSection | ( | ) |
Destructor.
Darknet::CfgSection & Darknet::CfgSection::clear | ( | ) |
Reset the section to be empty.
std::string Darknet::CfgSection::debug | ( | ) | const |
Iterate over the section and create a debug text message for every line.
|
inline |
Determine if a section is empty.
float Darknet::CfgSection::find_float | ( | const std::string & | key, |
const float | default_value | ||
) |
Find a float
config item in lines. If the key does not exist, then the given default value is returned.
Darknet::VFloat Darknet::CfgSection::find_float_array | ( | const std::string & | key | ) |
Find an array of float
values in lines. If the key does not exist, then an empty std::vector
is returned.
int Darknet::CfgSection::find_int | ( | const std::string & | key | ) |
Find an int
config item in lines. The given key must exist.
int Darknet::CfgSection::find_int | ( | const std::string & | key, |
const int | default_value | ||
) |
Find an int
config item in lines. If the key does not exist, then the given default value is returned.
Darknet::VInt Darknet::CfgSection::find_int_array | ( | const std::string & | key | ) |
Find an array of int
values in lines. If the key does not exist, then an empty std::vector
is returned.
std::string Darknet::CfgSection::find_str | ( | const std::string & | key, |
const std::string & | default_value = "" |
||
) |
Find a text config item in lines. If the key does not exist, then the given default value is returned.
const Darknet::CfgSection & Darknet::CfgSection::find_unused_lines | ( | ) | const |
Verify that there are no "unused" lines in this section.
size_t Darknet::CfgSection::line_number |
Line number where this section starts.
CfgLines Darknet::CfgSection::lines |
All of the non-empty lines within a section.
std::string Darknet::CfgSection::name |
The name of the section (so we don't have to keep looking up the type).
ELayerType Darknet::CfgSection::type |
The layer type for this section (e.g., [convolutional] or
[yolo]).