目的:学习CommandLineParser
首先看CommandLineParser的类定义。
class CV_EXPORTS CommandLineParser
{
.........//此处省略;
protected:
void getByName(const String& name, bool space_delete, int type, void* dst) const;
void getByIndex(int index, bool space_delete, int type, void* dst) const;
struct Impl;
Impl* impl;
};
其中有类里放了Impl的结构体声明,struct Impl;接着用Impl定义了该类型的一个指针标量。此时发现Impl并没有定义。
继续找,发现有:
struct CommandLineParser::Impl
{
bool error;
String error_message;
String about_message;
String path_to_app;
String app_name;
std::vector<CommandLineParserParams> data;
std::vector<String> split_range_string(const String& str, char fs, char ss) const;
std::vector<String> split_string(const String& str, char symbol = ' ', bool create_empty_item = false) const;
void apply_params(const String& key, const String& value);
void apply_params(int i, String value);
void sort_params();
int refcount;
}
可以看到是在CommandLineParser类外对Impl进行定义的。
或许是我少见多怪,第一遇到这种用法。