C++自定义API参考http://blog.csdn.net/qq910894904/article/details/38583485

windows api 参考https://wenku.baidu.com/view/f3d7636648d7c1c708a145b1.html

linux api参考https://wenku.baidu.com/view/ac526681d4d8d15abe234e54.html

代码参考自https://github.com/Winnerhust/inifile2

代码api参考http://blog.csdn.net/qq910894904/article/details/38583485


C++读取配置文件常见的类型有ini .conf  .cfg等。ARIA ARNL 中采用的也是读取配置文件的方法,格式为.p参考如下!!

ini文件

ini文件(即Initialization file),这种类型的文件中通常存放的是一个程序的初始化信息。

ini文件组成部分:组group、键值key-value、内容parameter、注释comment .

ini文件可以包含若干个节(Section),每个Section由节名(section 开头?)若干键值对(Key-value),  注释comment组成。读写ini文件实际上就是读写某个的Section中相应的Key的value值value

注释comment一般以分号“;”开头,在分号后面的文字,直到该行结尾都全部为注解。但是也有很多的配置文件的注释是以“#”开头的(linux tradition)。

注释一般以分号“;”开头,在分号后面的文字,直到该行结尾都全部为注解。但是也有很多的配置文件的注释是以“#”开头的。
[sys_table]
table_id=1
max_column_id=11
table_type=1
#rowkey is table name
rowkey_is_fixed_length=0 
column_info=table_name,varchar,128
column_info=table_id,int 
column_info=table_type,int
column_info=rowkey_len,int
column_info=max_column_id,int

【】为组名

table_id = 1 ; 键为 table_id 值为11  (=号键值对定义)或者p3dx.p里面的空格定义map一对。

inifile.h

#ifndef _INIFILE_H
#define _INIFILE_H

#include <map>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
namespace inifile
{
const int RET_OK  = 0;
const int RET_ERR = -1;
const string delim = "\n";
struct IniItem {
    string key;
    string value;
    string comment;
};
struct IniSection {
    typedef vector<IniItem>::iterator iterator;
    iterator begin() {
        return items.begin();
    }
    iterator end() {
        return items.end();
    }

    string name;
    string comment;
    vector<IniItem> items;
};

class IniFile
{
public:
    IniFile();
    ~IniFile() {
        release();
    }

public:
    typedef map<string, IniSection *>::iterator iterator;

    iterator begin() {
        return sections_.begin();
    }
    iterator end() {
        return sections_.end();
    }
public:
    /* 打开并解析一个名为fname的INI文件 */
    int load(const string &fname);
    /*将内容保存到当前文件*/
    int save();
    /*将内容另存到一个名为fname的文件*/
    int saveas(const string &fname);

    /*获取section段第一个键为key的值,并返回其string型的值*/
    string getStringValue(const string §ion, const string &key, int &ret);
    /*获取section段第一个键为key的值,并返回其int型的值*/
    int getIntValue(const string §ion, const string &key, int &ret);
    /*获取section段第一个键为key的值,并返回其double型的值*/
    double getDoubleValue(const string §ion, const string &key, int &ret);

    /*获取section段第一个键为key的值,并将值赋到value中*/
    int getValue(const string §ion, const string &key, string &value);
    /*获取section段第一个键为key的值,并将值赋到value中,将注释赋到comment中*/
    int getValue(const string §ion, const string &key, string &value, string &comment);

    /*获取section段所有键为key的值,并将值赋到values的vector中*/
    int getValues(const string §ion, const string &key, vector<string> &values);
    /*获取section段所有键为key的值,并将值赋到values的vector中,,将注释赋到comments的vector中*/
    int getValues(const string §ion, const string &key, vector<string> &value, vector<string> &comments);

    bool hasSection(const string §ion) ;
    bool hasKey(const string §ion, const string &key) ;

    /* 获取section段的注释 */
    int getSectionComment(const string §ion, string &comment);
    /* 设置section段的注释 */
    int setSectionComment(const string §ion, const string &comment);
    /*获取注释标记符列表*/
    void getCommentFlags(vector<string> &flags);
    /*设置注释标记符列表*/
    void setCommentFlags(const vector<string> &flags);

    /*同时设置值和注释*/
    int setValue(const string §ion, const string &key, const string &value, const string &comment = "");
    /*删除段*/
    void deleteSection(const string §ion);
    /*删除特定段的特定参数*/
    void deleteKey(const string §ion, const string &key);
public:
    /*去掉str后面的c字符*/
    static void trimleft(string &str, char c = ' ');
    /*去掉str前面的c字符*/
    static void trimright(string &str, char c = ' ');
    /*去掉str前面和后面的空格符,Tab符等空白符*/
    static void trim(string &str);
    /*将字符串str按分割符delim分割成多个子串*/
private:
    IniSection *getSection(const string §ion = "");
    void release();
    int getline(string &str, FILE *fp);
    bool isComment(const string &str);
    bool parse(const string &content, string &key, string &value, char c = '=');
    //for dubug
    void print();

private:
    map<string, IniSection *> sections_;
    string fname_;
    vector<string> flags_;
};
}

#endif
inifile.cpp

#ifndef _INIFILE_CPP
#define _INIFILE_CPP

#include "inifile.h"
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>

namespace inifile
{

int INI_BUF_SIZE = 2048;

IniFile::IniFile()
{
    flags_.push_back("#");
    flags_.push_back(";");
}

bool IniFile::parse(const string &content, string &key, string &value, char c/*= '='*/)
{
    int i = 0;
    int len = content.length();

    while (i < len && content[i] != c) {
        ++i;
    }

    if (i >= 0 && i < len) {
        key = string(content.c_str(), i);
        value = string(content.c_str() + i + 1, len - i - 1);
        return true;
    }

    return false;
}

int IniFile::getline(string &str, FILE *fp)
{
    int plen = 0;
    int buf_size = INI_BUF_SIZE * sizeof(char);

    char *buf = (char *) malloc(buf_size);
    char *pbuf = NULL;
    char *p = buf;

    if (buf == NULL) {
        fprintf(stderr, "no enough memory!exit!\n");
        exit(-1);
    }

    memset(buf, 0, buf_size);
    int total_size = buf_size;

    while (fgets(p, buf_size, fp) != NULL) {
        plen = strlen(p);

        if (plen > 0 && p[plen - 1] != '\n' && !feof(fp)) {

            total_size = strlen(buf) + buf_size;
            pbuf = (char *)realloc(buf, total_size);

            if (pbuf == NULL) {
                free(buf);
                fprintf(stderr, "no enough memory!exit!\n");
                exit(-1);
            }

            buf = pbuf;

            p = buf + strlen(buf);

            continue;
        } else {
            break;
        }
    }

    str = buf;

    free(buf);
    buf = NULL;
    return str.length();

}
int IniFile::load(const string &filename)
{
    release();
    fname_ = filename;
    IniSection *section = NULL;
    FILE *fp = fopen(filename.c_str(), "r");

    if (fp == NULL) {
        return -1;
    }

    string line;
    string comment;

    //增加默认段
    section = new IniSection();
    sections_[""] = section;

    while (getline(line, fp) > 0) {

        trimright(line, '\n');
        trimright(line, '\r');
        trim(line);

        if (!isComment(line)) {
            /* 针对 “value=1 #测试” 这种后面有注释的语句
             * 重新分割line,并添加注释到commnet
             * 注意:这种情况保存后会变成
             * #测试
             * value=1
             * */
            string subline;
            string tmp = line;

            for (size_t i = 0; i < flags_.size(); ++i) {
                subline = line.substr(0, line.find(flags_[i]));
                line = subline;
            }

            comment += tmp.substr(line.length());
        }

        trim(line);

        if (line.length() <= 0) {
            continue;
        }

        if (line[0] == '[') {
            section = NULL;
            int index = line.find_first_of(']');

            if (index == -1) {
                fclose(fp);
                fprintf(stderr, "没有找到匹配的]\n");
                return -1;
            }

            int len = index - 1;

            if (len <= 0) {
                fprintf(stderr, "段为空\n");
                continue;
            }

            string s(line, 1, len);

            if (getSection(s.c_str()) != NULL) {
                fclose(fp);
                fprintf(stderr, "此段已存在:%s\n", s.c_str());
                return -1;
            }

            section = new IniSection();
            sections_[s] = section;

            section->name = s;
            section->comment = comment;
            comment = "";
        } else if (isComment(line)) {
            if (comment != "") {
                comment += delim + line ;
            } else {
                comment = line;
            }
        } else {
            string key, value;

            if (parse(line, key, value)) {
                IniItem item;
                item.key = key;
                item.value = value;
                item.comment = comment;

                section->items.push_back(item);
            } else {
                fprintf(stderr, "解析参数失败[%s]\n", line.c_str());
            }

            comment = "";
        }
    }

    fclose(fp);

    return 0;
}

int IniFile::save()
{
    return saveas(fname_);
}

int IniFile::saveas(const string &filename)
{
    string data = "";

    for (iterator sect = sections_.begin(); sect != sections_.end(); ++sect) {
        if (sect->second->comment != "") {
            data += sect->second->comment;
            data += delim;
        }

        if (sect->first != "") {
            data += string("[") + sect->first + string("]");
            data += delim;
        }

        for (IniSection::iterator item = sect->second->items.begin(); item != sect->second->items.end(); ++item) {
            if (item->comment != "") {
                data += item->comment;
                data += delim;
            }

            data += item->key + "=" + item->value;
            data += delim;
        }
    }

    FILE *fp = fopen(filename.c_str(), "w");

    fwrite(data.c_str(), 1, data.length(), fp);

    fclose(fp);

    return 0;
}
IniSection *IniFile::getSection(const string §ion /*=""*/)
{
    iterator it = sections_.find(section);

    if (it != sections_.end()) {
        return it->second;
    }

    return NULL;
}

string IniFile::getStringValue(const string §ion, const string &key, int &ret)
{
    string value, comment;

    ret = getValue(section, key, value, comment);

    return value;
}

int IniFile::getIntValue(const string §ion, const string &key, int &ret)
{
    string value, comment;

    ret = getValue(section, key, value, comment);

    return atoi(value.c_str());
}

double IniFile::getDoubleValue(const string §ion, const string &key, int &ret)
{
    string value, comment;

    ret = getValue(section, key, value, comment);

    return atof(value.c_str());

}

int IniFile::getValue(const string §ion, const string &key, string &value)
{
    string comment;
    return getValue(section, key, value, comment);
}
int IniFile::getValue(const string §ion, const string &key, string &value, string &comment)
{
    IniSection *sect = getSection(section);

    if (sect != NULL) {
        for (IniSection::iterator it = sect->begin(); it != sect->end(); ++it) {
            if (it->key == key) {
                value = it->value;
                comment = it->comment;
                return RET_OK;
            }
        }
    }

    return RET_ERR;
}
int IniFile::getValues(const string §ion, const string &key, vector<string> &values)
{
    vector<string> comments;
    return getValues(section, key, values, comments);
}
int IniFile::getValues(const string §ion, const string &key,
                       vector<string> &values, vector<string> &comments)
{
    string value, comment;

    values.clear();
    comments.clear();

    IniSection *sect = getSection(section);

    if (sect != NULL) {
        for (IniSection::iterator it = sect->begin(); it != sect->end(); ++it) {
            if (it->key == key) {
                value = it->value;
                comment = it->comment;

                values.push_back(value);
                comments.push_back(comment);
            }
        }
    }

    return (values.size() ? RET_OK : RET_ERR);

}
bool IniFile::hasSection(const string §ion)
{
    return (getSection(section) != NULL);

}

bool IniFile::hasKey(const string §ion, const string &key)
{
    IniSection *sect = getSection(section);

    if (sect != NULL) {
        for (IniSection::iterator it = sect->begin(); it != sect->end(); ++it) {
            if (it->key == key) {
                return true;
            }
        }
    }

    return false;
}
int IniFile::getSectionComment(const string §ion, string &comment)
{
    comment = "";
    IniSection *sect = getSection(section);

    if (sect != NULL) {
        comment = sect->comment;
        return RET_OK;
    }

    return RET_ERR;
}
int IniFile::setSectionComment(const string §ion, const string &comment)
{
    IniSection *sect = getSection(section);

    if (sect != NULL) {
        sect->comment = comment;
        return RET_OK;
    }

    return RET_ERR;
}

int IniFile::setValue(const string §ion, const string &key,
                      const string &value, const string &comment /*=""*/)
{
    IniSection *sect = getSection(section);

    string comt = comment;

    if (comt != "") {
        comt = flags_[0] + comt;
    }

    if (sect == NULL) {
        sect = new IniSection();

        if (sect == NULL) {
            fprintf(stderr, "no enough memory!\n");
            exit(-1);
        }

        sect->name = section;
        sections_[section] = sect;
    }

    for (IniSection::iterator it = sect->begin(); it != sect->end(); ++it) {
        if (it->key == key) {
            it->value = value;
            it->comment = comt;
            return RET_OK;
        }
    }

    //not found key
    IniItem item;
    item.key = key;
    item.value = value;
    item.comment = comt;

    sect->items.push_back(item);

    return RET_OK;

}
void IniFile::getCommentFlags(vector<string> &flags)
{
    flags = flags_;
}
void IniFile::setCommentFlags(const vector<string> &flags)
{
    flags_ = flags;
}
void IniFile::deleteSection(const string §ion)
{
    IniSection *sect = getSection(section);

    if (sect != NULL) {

        sections_.erase(section);
        delete sect;
    }
}
void IniFile::deleteKey(const string §ion, const string &key)
{
    IniSection *sect = getSection(section);

    if (sect != NULL) {
        for (IniSection::iterator it = sect->begin(); it != sect->end(); ++it) {
            if (it->key == key) {
                sect->items.erase(it);
                break;
            }
        }
    }

}

void IniFile::release()
{
    fname_ = "";

    for (iterator i = sections_.begin(); i != sections_.end(); ++i) {
        delete i->second;
    }

    sections_.clear();

}

bool IniFile::isComment(const string &str)
{
    bool ret = false;

    for (size_t i = 0; i < flags_.size(); ++i) {
        size_t k = 0;

        if (str.length() < flags_[i].length()) {
            continue;
        }

        for (k = 0; k < flags_[i].length(); ++k) {
            if (str[k] != flags_[i][k]) {
                break;
            }
        }

        if (k == flags_[i].length()) {
            ret = true;
            break;
        }
    }

    return ret;
}
//for debug
void IniFile::print()
{
    printf("filename:[%s]\n", fname_.c_str());

    printf("flags_:[");

    for (size_t i = 0; i < flags_.size(); ++i) {
        printf(" %s ", flags_[i].c_str());
    }

    printf("]\n");

    for (iterator it = sections_.begin(); it != sections_.end(); ++it) {
        printf("section:[%s]\n", it->first.c_str());
        printf("comment:[%s]\n", it->second->comment.c_str());

        for (IniSection::iterator i = it->second->items.begin(); i != it->second->items.end(); ++i) {
            printf("    comment:%s\n", i->comment.c_str());
            printf("    parm   :%s=%s\n", i->key.c_str(), i->value.c_str());
        }
    }
}

void IniFile::trimleft(string &str, char c/*=' '*/)
{
    //trim head

    int len = str.length();

    int i = 0;

    while (str[i] == c && str[i] != '\0') {
        i++;
    }

    if (i != 0) {
        str = string(str, i, len - i);
    }
}

void IniFile::trimright(string &str, char c/*=' '*/)
{
    //trim tail
    int i = 0;
    int len = str.length();


    for (i = len - 1; i >= 0; --i) {
        if (str[i] != c) {
            break;
        }
    }

    str = string(str, 0, i + 1);
}

void IniFile::trim(string &str)
{
    //trim head

    int len = str.length();

    int i = 0;

    while (isspace(str[i]) && str[i] != '\0') {
        i++;
    }

    if (i != 0) {
        str = string(str, i, len - i);
    }

    //trim tail
    len = str.length();

    for (i = len - 1; i >= 0; --i) {
        if (!isspace(str[i])) {
            break;
        }
    }

    str = string(str, 0, i + 1);
}
}
#endif

inifile_test.cpp 

#include <iostream>
#include <gtest/gtest.h>
#include "inifile.h"

using namespace std;
using namespace inifile;

TEST(inifile, trim)
{
    string buf = "   aaa    ";
    IniFile::trim(buf);

    EXPECT_EQ(buf, string("aaa"));

    buf =  "   aaa";
    IniFile::trim(buf);
    EXPECT_EQ(buf, string("aaa"));

    buf =  "aaa    ";
    IniFile::trim(buf);
    EXPECT_EQ(buf, string("aaa"));
}

TEST(inifile, trimleft)
{
    string p = "   aaa    ";
    IniFile::trimleft(p);

    EXPECT_EQ(p, string("aaa    "));

    p =  "   aaa";
    IniFile::trimleft(p);
    EXPECT_EQ(p, string("aaa"));

    p = "aaa    ";
    IniFile::trimleft(p);
    EXPECT_EQ(p, string("aaa    "));
}

TEST(inifile, trimright)
{
    string p = "   aaa    ";
    IniFile::trimright(p);

    EXPECT_EQ(p, string("   aaa"));

    p =  "   aaa";
    IniFile::trimright(p);
    EXPECT_EQ(p, string("   aaa"));

    p = "aaa    ";
    IniFile::trimright(p);
    EXPECT_EQ(p, string("aaa"));
}



TEST(IniFile, pasre)
{
    IniFile section;
    string s = "DB=sys";
    string key, value;

    EXPECT_EQ(section.parse(s.c_str(), key, value), true);
    EXPECT_EQ(key, "DB");
    EXPECT_EQ(value, "sys");

    s = "DB";
    key = value = "";

    EXPECT_EQ(section.parse(s.c_str(), key, value), false);
    EXPECT_EQ(key, "");
    EXPECT_EQ(value, "");

    s = "DB=";
    key = value = "";

    EXPECT_EQ(section.parse(s.c_str(), key, value), true);
    EXPECT_EQ(key, "DB");
    EXPECT_EQ(value, "");

    s = "=sys";
    key = value = "";

    EXPECT_EQ(section.parse(s.c_str(), key, value), true);
    EXPECT_EQ(key, "");
    EXPECT_EQ(value, "sys");
}



//
TEST(IniFile, getline)
{
    //create a new ini file
    char filepath[] = "test/test.ini";
    FILE *fp = fopen(filepath, "w+");
    char content[] = " USER=root \r\n [COMMON] \n DB=sys   	\nPASSWD=tt   \n#commit   \n ;--------- \n[DEFINE] \nname=cxy\n";
    fwrite(content, 1, sizeof(content), fp);
    fclose(fp);

    //test
    IniFile ini;
    string line;
    fp = fopen(filepath, "r");

    ini.getline(line, fp);
    IniFile::trimright(line, '\n');
    IniFile::trimright(line, '\r');
    IniFile::trim(line);
    EXPECT_EQ(line, "USER=root");

    ini.getline(line, fp);
    IniFile::trimright(line, '\n');
    IniFile::trimright(line, '\r');
    IniFile::trim(line);
    EXPECT_EQ(line, "[COMMON]");

    ini.getline(line, fp);
    IniFile::trimright(line, '\n');
    IniFile::trimright(line, '\r');
    IniFile::trim(line);
    EXPECT_EQ(line, "DB=sys");

    ini.getline(line, fp);
    ini.getline(line, fp);
    IniFile::trimright(line, '\n');
    IniFile::trimright(line, '\r');
    IniFile::trim(line);
    EXPECT_EQ(line, "#commit");
    fclose(fp);
}
TEST(IniFile, hasSection_and_getValue)
{
    //create a new ini file
    char filepath[] = "test/test.ini";
    FILE *fp = fopen(filepath, "w+");
    char content[] = " USER=root \r\n [COMMON] \n DB=sys   	\nPASSWD=tt   \n#commit   \n ;--------- \n[DEFINE] \nname=cxy\nvalue=1 #测试\n";
    fwrite(content, 1, sizeof(content), fp);
    fclose(fp);

    //test
    IniFile ini;
    ini.load(filepath);
    /*cout<<"---------------\n"<<endl;
    ini.print();
    cout<<"---------------\n"<<endl;
    */
    EXPECT_EQ(ini.hasSection(string("")), true);
    EXPECT_EQ(ini.hasSection("COMMON"), true);
    EXPECT_EQ(ini.hasSection("DEFINE"), true);
    EXPECT_EQ(ini.hasSection("ss"), false);

    string value;
    EXPECT_EQ(ini.getValue("", "USER", value), 0);
    EXPECT_EQ(value, string("root"));
    EXPECT_EQ(ini.getValue("COMMON", "DB", value), 0);
    EXPECT_EQ(value, string("sys"));
    EXPECT_EQ(ini.getValue("COMMON", "PASSWD", value), 0);
    EXPECT_EQ(value, string("tt"));
    EXPECT_EQ(ini.getValue("DEFINE", "name", value), 0);
    EXPECT_EQ(value, string("cxy"));
    EXPECT_EQ(ini.getValue("DEFINE", "value", value), 0);
    EXPECT_EQ(value, string("1"));

}

TEST(IniFile, reopen)
{
    //create a new ini file
    char filepath[] = "test/test.ini";
    FILE *fp = fopen(filepath, "w");
    char content[] = " USER=root \r\n [COMMON] \n DB=sys   	\nPASSWD=tt   \n#commit   \n ;--------- \n[DEFINE] \nname=cxy\n";
    fwrite(content, sizeof(char), strlen(content), fp);
    fclose(fp);

    //test
    IniFile ini;
    ini.load(filepath);

    //reopen

    fp = fopen(filepath, "w");
    strcpy(content, " USER=root2 \r\n [COMMON] \n DB=sys2   	\n\n#commit   \n ;--------- \n\n\n");
    fwrite(content, sizeof(char), strlen(content), fp);
    fclose(fp);

    //test
    ini.load(filepath);

    EXPECT_EQ(ini.hasSection(""), true);
    EXPECT_EQ(ini.hasSection("COMMON"), true);
    EXPECT_EQ(ini.hasSection("DEFINE"), false);

    string value;
    EXPECT_EQ(ini.getValue("", "USER", value), 0);
    EXPECT_EQ(value, string("root2"));
    EXPECT_EQ(ini.getValue("COMMON", "DB", value), 0);
    EXPECT_EQ(value, string("sys2"));
    EXPECT_EQ(ini.getValue("COMMON", "PASSWD", value), -1);
    EXPECT_EQ(ini.getValue("DEFINE", "name", value), -1);

}

TEST(IniFile, saveas)
{
    //create a new ini file
    char filepath[] = "test/test.ini";
    FILE *fp = fopen(filepath, "w");
    char content[] = " USER=root \r\n [COMMON] \n DB=sys   	\nPASSWD=tt   \n#commit   \n ;--------- \n[DEFINE] \nname=cxy\nvalue=1 #测试";
    fwrite(content, sizeof(char), strlen(content), fp);
    fclose(fp);

    //test
    IniFile ini;
    ini.load(filepath);

    char saveas_path[] = "test/test_save_as.ini";

    ini.saveas(saveas_path);

    fp = fopen(saveas_path, "r");
    char buf[200];
    memset(buf, 0, 200 * sizeof(char));

    fread(buf, sizeof(char), 200, fp);
    fclose(fp);
    EXPECT_EQ(buf, string("USER=root\n[COMMON]\nDB=sys\nPASSWD=tt\n#commit\n;---------\n[DEFINE]\nname=cxy\n#测试\nvalue=1\n"));

}

TEST(IniFile, setValue)
{
    IniFile ini;

    ini.setValue("COMMON", "DB", "sys", "数据库");
    ini.setValue("COMMON", "PASSWD", "root", "数据库密码");
    ini.setValue("", "NAME", "cxy", "");

    char filepath[] = "test/test_set.ini";
    ini.saveas(filepath);

    FILE *fp = fopen(filepath, "r");
    char buf[200];
    memset(buf, 0, 200 * sizeof(char));

    fread(buf, sizeof(char), 200, fp);
    fclose(fp);
    EXPECT_EQ(buf, string("NAME=cxy\n[COMMON]\n#数据库\nDB=sys\n#数据库密码\nPASSWD=root\n"));
}
TEST(IniFile, deleteSection)
{
    //create a new ini file
    char filepath[] = "test/test.ini";
    FILE *fp = fopen(filepath, "w");
    char content[] = " USER=root \r\n [COMMON] \n DB=sys   	\nPASSWD=tt   \n#commit   \n ;--------- \n[DEFINE] \nname=cxy\n";
    fwrite(content, sizeof(char), strlen(content), fp);
    fclose(fp);

    //test
    IniFile ini;
    ini.load(filepath);

    ini.deleteSection("COMMON");

    char saveas_path[] = "test/test_save_deleteS.ini";

    ini.saveas(saveas_path);

    fp = fopen(saveas_path, "r");
    char buf[200];
    memset(buf, 0, 200 * sizeof(char));

    fread(buf, sizeof(char), 200, fp);
    fclose(fp);
    EXPECT_EQ(buf, string("USER=root\n#commit\n;---------\n[DEFINE]\nname=cxy\n"));

}
TEST(IniFile, deleteKey)
{
    //create a new ini file
    char filepath[] = "test/test.ini";
    FILE *fp = fopen(filepath, "w");
    char content[] = " USER=root \r\n [COMMON] \n DB=sys   	\nPASSWD=tt   \n#commit   \n ;--------- \n[DEFINE] \nname=cxy\n";
    fwrite(content, sizeof(char), strlen(content), fp);
    fclose(fp);

    //test
    IniFile ini;
    ini.load(filepath);

    ini.deleteKey("COMMON", "DB");

    char saveas_path[] = "test/test_save_deleteK.ini";

    ini.saveas(saveas_path);

    fp = fopen(saveas_path, "r");
    char buf[200];
    memset(buf, 0, 200 * sizeof(char));

    fread(buf, sizeof(char), 200, fp);
    fclose(fp);
    EXPECT_EQ(buf, string("USER=root\n[COMMON]\nPASSWD=tt\n#commit\n;---------\n[DEFINE]\nname=cxy\n"));

}

//#ifdef GTEST_MAIN
int main(int argc, char *argv[])
{
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}

//#endif




如下是 P3DX.p的参数文件

ConfigVersion 2.0
;SectionFlags for : 
;  Robot parameter file

Section General settings
;SectionFlags for General settings: 
Class Pioneer            ; general type of robot
Subclass p3dx            ; specific type of robot
RobotRadius 250.00000    ; radius in mm
RobotDiagonal 120.00000  ; half-height to diagonal of octagon
RobotWidth 425.00000     ; width in mm
RobotLength 511.00000    ; length in mm of the whole robot
RobotLengthFront 210.00000 ; length in mm to the front of the robot (if this is
                         ; 0 (or non existent) this value will be set to half
                         ; of RobotLength)
RobotLengthRear 301.00000 ; length in mm to the rear of the robot (if this is 0
                         ; (or non existent) this value will be set to half of
                         ; RobotLength)
Holonomic true           ; turns in own radius
MaxRVelocity 500         ; absolute maximum degrees / sec
MaxVelocity 2200         ; absolute maximum mm / sec
MaxLatVelocity 0         ; absolute lateral maximum mm / sec
HasMoveCommand true      ; has built in move command
RequestIOPackets false   ; automatically request IO packets
RequestEncoderPackets false ; automatically request encoder packets
SwitchToBaudRate 38400   ; switch to this baud if non-0 and supported on robot

Section Conversion factors
;SectionFlags for Conversion factors: 
AngleConvFactor 0.00153  ; radians per angular unit (2PI/4096)
DistConvFactor 0.48500   ; multiplier to mm from robot units
VelConvFactor 1.00000    ; multiplier to mm/sec from robot units
RangeConvFactor 1.00000  ; multiplier to mm from sonar units
DiffConvFactor 0.00560   ; ratio of angular velocity to wheel velocity (unused
                         ; in newer firmware that calculates and returns this)
Vel2Divisor 20.00000     ; divisor for VEL2 commands
GyroScaler 1.62600       ; Scaling factor for gyro readings

Section Accessories the robot has
;SectionFlags for Accessories the robot has: 
TableSensingIR false     ; if robot has upwards facing table sensing IR
NewTableSensingIR false  ; if table sensing IR are sent in IO packet
FrontBumpers false       ; if robot has a front bump ring
NumFrontBumpers 5        ; number of front bumpers on the robot
RearBumpers false        ; if the robot has a rear bump ring
NumRearBumpers 5         ; number of rear bumpers on the robot

Section IR parameters
;SectionFlags for IR parameters: 
IRNum 0                  ; number of IRs on the robot
;  IRUnit <IR Number> <IR Type> <Persistance, cycles> <x position, mm> <y
 position, mm>

Section Movement control parameters
;  if these are 0 the parameters from robot flash will be used, otherwise these
;  values will be used
;SectionFlags for Movement control parameters: 
SettableVelMaxes true    ; if TransVelMax and RotVelMax can be set
TransVelMax 0            ; maximum desired translational velocity for the robot
RotVelMax 0              ; maximum desired rotational velocity for the robot
SettableAccsDecs true    ; if the accel and decel parameters can be set
TransAccel 0             ; translational acceleration
TransDecel 0             ; translational deceleration
RotAccel 0               ; rotational acceleration
RotDecel 0               ; rotational deceleration
HasLatVel false          ; if the robot has lateral velocity
LatVelMax 0              ; maximum desired lateral velocity for the robot
LatAccel 0               ; lateral acceleration
LatDecel 0               ; lateral deceleration

Section GPS parameters
;SectionFlags for GPS parameters: 
GPSPX 0                  ; x location of gps receiver antenna on robot, mm
GPSPY 0                  ; y location of gps receiver antenna on robot, mm
GPSType standard         ; type of gps receiver (trimble, novatel, standard)
GPSPort COM2             ; port the gps is on
GPSBaud 9600             ; gps baud rate (9600, 19200, 38400, etc.)

Section Compass parameters
;SectionFlags for Compass parameters: 
CompassType robot        ; type of compass: robot (typical configuration), or
                         ; serialTCM (computer serial port)
CompassPort              ; serial port name, if CompassType is serialTCM

Section Sonar parameters
;SectionFlags for Sonar parameters: 
SonarNum 16              ; Number of sonars on the robot.
;  SonarUnit <sonarNumber> <x position, mm> <y position, mm> <heading of disc,
 degrees> <MTX sonar board> <MTX sonar board unit position> <MTX gain> <MTX
 detection threshold> <MTX max range> <autonomous driving sensor flag>
SonarUnit 0 69 136 90
SonarUnit 1 114 119 50
SonarUnit 2 148 78 30
SonarUnit 3 166 27 10
SonarUnit 4 166 -27 -10
SonarUnit 5 148 -78 -30
SonarUnit 6 114 -119 -50
SonarUnit 7 69 -136 -90
SonarUnit 8 -157 -136 -90
SonarUnit 9 -203 -119 -130
SonarUnit 10 -237 -78 -150
SonarUnit 11 -255 -27 -170
SonarUnit 12 -255 27 170
SonarUnit 13 -237 78 150
SonarUnit 14 -203 119 130
SonarUnit 15 -157 136 90

Section SonarBoard_1
;  Information about the connection to this Sonar Board.
;SectionFlags for SonarBoard_1: 
SonarAutoConnect false   ; SonarBoard_1 exists and should be automatically
                         ; connected at startup.
SonarBoardType           ; Type of the sonar board.
SonarBoardPortType       ; Port type that the sonar is on.
SonarBoardPort           ; Port the sonar is on.
SonarBoardPowerOutput    ; Power output that controls this Sonar Board's power.
SonarBaud 0              ; Baud rate for the sonar board communication. (9600,
                         ; 19200, 38400, etc.).
SonarDelay 2             ; range [0, 10],  Sonar delay (in ms).
SonarGain 10             ; range [0, 31],  Default sonar gain for the board,
                         ; range 0-31.
SonarDetectionThreshold 25 ; range [0, 65535],  Default sonar detection
                         ; threshold for the board.
SonarMaxRange 4335       ; range [0, 4335],  Default maximum sonar range for
                         ; the board.

Section Laser parameters
;  Information about the connection to this laser and its position on the
;  vehicle.
;SectionFlags for Laser parameters: 
LaserAutoConnect true    ; Laser_1 exists and should be automatically connected
                         ; at startup.
LaserX 18                ; Location (in mm) of the laser in X (+ front, - back)
                         ; relative to the robot's idealized center of
                         ; rotation.
LaserY 0                 ; Location (in mm) of the laser in Y (+ left, - right)
                         ; relative to the robot's idealized center of
                         ; rotation.
LaserTh 0.00000          ; range [-180, 180],  Rotation (in deg) of the laser
                         ; (+ counterclockwise, - clockwise).
LaserZ 0                 ; minimum 0,  Height (in mm) of the laser from the
                         ; ground. 0 means unknown.
LaserIgnore              ; Angles (in deg) at which to ignore readings, +/1 one
                         ; degree. Angles are entered as strings, separated by
                         ; a space.
LaserFlipped false       ; Laser_1 is upside-down.
LaserType lms2xx         ; Type of laser.
LaserPortType serial     ; Type of port the laser is on.
LaserPort COM3           ; Port the laser is on.
LaserPowerOutput         ; Power output that controls this laser's power.
LaserStartingBaudChoice  ; StartingBaud for this laser. Leave blank to use the
                         ; default.
LaserAutoBaudChoice      ; AutoBaud for this laser. Leave blank to use the
                         ; default.
LaserPowerControlled true ; When enabled (true), this indicates that the power
                         ; to the laser is controlled by the serial port line.
LaserMaxRange 0          ; Maximum range (in mm) to use for the laser. This
                         ; should be specified only when the range needs to be
                         ; shortened. 0 to use the default range.
LaserCumulativeBufferSize 0 ; Cumulative buffer size to use for the laser. 0 to
                         ; use the default.
LaserStartDegrees        ; Start angle (in deg) for the laser. This may be used
                         ; to constrain the angle. Fractional degrees are
                         ; permitted. Leave blank to use the default.
LaserEndDegrees          ; End angle (in deg) for the laser. This may be used
                         ; to constrain the angle. Fractional degreees are
                         ; permitted. Leave blank to use the default.
LaserDegreesChoice       ; Degrees choice for the laser. This may be used to
                         ; constrain the range. Leave blank to use the default.
LaserIncrement           ; Increment (in deg) for the laser. Fractional degrees
                         ; are permitted. Leave blank to use the default.
LaserIncrementChoice     ; Increment choice for the laser. This may be used to
                         ; increase the increment. Leave blank to use the
                         ; default.
LaserUnitsChoice         ; Units for the laser. This may be used to increase
                         ; the size of the units. Leave blank to use the
                         ; default.
LaserReflectorBitsChoice  ; ReflectorBits for the laser. Leave blank to use the
                         ; default.

Section Laser 2 parameters
;  Information about the connection to this laser and its position on the
;  vehicle.
;SectionFlags for Laser 2 parameters: 
LaserAutoConnect false   ; Laser_2 exists and should be automatically connected
                         ; at startup.
LaserX 0                 ; Location (in mm) of the laser in X (+ front, - back)
                         ; relative to the robot's idealized center of
                         ; rotation.
LaserY 0                 ; Location (in mm) of the laser in Y (+ left, - right)
                         ; relative to the robot's idealized center of
                         ; rotation.
LaserTh 0.00000          ; range [-180, 180],  Rotation (in deg) of the laser
                         ; (+ counterclockwise, - clockwise).
LaserZ 0                 ; minimum 0,  Height (in mm) of the laser from the
                         ; ground. 0 means unknown.
LaserIgnore              ; Angles (in deg) at which to ignore readings, +/1 one
                         ; degree. Angles are entered as strings, separated by
                         ; a space.
LaserFlipped false       ; Laser_2 is upside-down.
LaserType                ; Type of laser.
LaserPortType            ; Type of port the laser is on.
LaserPort                ; Port the laser is on.
LaserPowerOutput         ; Power output that controls this laser's power.
LaserStartingBaudChoice  ; StartingBaud for this laser. Leave blank to use the
                         ; default.
LaserAutoBaudChoice      ; AutoBaud for this laser. Leave blank to use the
                         ; default.
LaserPowerControlled true ; When enabled (true), this indicates that the power
                         ; to the laser is controlled by the serial port line.
LaserMaxRange 0          ; Maximum range (in mm) to use for the laser. This
                         ; should be specified only when the range needs to be
                         ; shortened. 0 to use the default range.
LaserCumulativeBufferSize 0 ; Cumulative buffer size to use for the laser. 0 to
                         ; use the default.
LaserStartDegrees        ; Start angle (in deg) for the laser. This may be used
                         ; to constrain the angle. Fractional degrees are
                         ; permitted. Leave blank to use the default.
LaserEndDegrees          ; End angle (in deg) for the laser. This may be used
                         ; to constrain the angle. Fractional degreees are
                         ; permitted. Leave blank to use the default.
LaserDegreesChoice       ; Degrees choice for the laser. This may be used to
                         ; constrain the range. Leave blank to use the default.
LaserIncrement           ; Increment (in deg) for the laser. Fractional degrees
                         ; are permitted. Leave blank to use the default.
LaserIncrementChoice     ; Increment choice for the laser. This may be used to
                         ; increase the increment. Leave blank to use the
                         ; default.
LaserUnitsChoice         ; Units for the laser. This may be used to increase
                         ; the size of the units. Leave blank to use the
                         ; default.
LaserReflectorBitsChoice  ; ReflectorBits for the laser. Leave blank to use the
                         ; default.

Section Battery_1
;  Information about the connection to this battery.
;SectionFlags for Battery_1: 
BatteryAutoConnect false ; Battery_1 exists and should be automatically
                         ; connected at startup.
BatteryType              ; Type of battery.
BatteryPortType          ; Port type that the battery is on.
BatteryPort              ; Port the battery is on.
BatteryBaud 0            ; Baud rate to use for battery communication (9600,
                         ; 19200, 38400, etc.).

Section LCD_1
;  The physical definition of this LCD.
;SectionFlags for LCD_1: 
LCDAutoConnect false     ; LCD_1 exists and should automatically be connected
                         ; at startup.
LCDDisconnectOnConnectFailure false ; The LCD is a key component and is
                         ; required for operation. If this is enabled and there
                         ; is a failure in the LCD communications, then the
                         ; robot will restart.
LCDType                  ; Type of LCD.
LCDPortType              ; Port type that the LCD is on.
LCDPort                  ; Port that the LCD is on.
LCDPowerOutput           ; Power output that controls this LCD's power.
LCDBaud 0                ; Baud rate for the LCD communication (9600, 19200,
                         ; 38400, etc.).

Section PTZ 1 parameters
;  Information about the connection to a pan/tilt unit (PTU) or pan/tilt/zoom
;  control (PTZ) of a camera
;SectionFlags for PTZ 1 parameters: 
PTZAutoConnect true      ; If true, connect to this PTZ by default.
PTZType vcc4             ; PTZ or PTU type
PTZInverted false        ; If unit is mounted inverted (upside-down)
PTZSerialPort none       ; serial port, or none if not using serial port
                         ; communication
PTZRobotAuxSerialPort 1  ; Pioneer aux. serial port, or -1 if not using aux.
                         ; serial port for communication.
PTZAddress 192.168.0.90  ; IP address or hostname, or none if not using network
                         ; communication.
PTZTCPPort 80            ; TCP Port to use for HTTP network connection

Section PTZ 2 parameters
;  Information about the connection to a pan/tilt unit (PTU) or pan/tilt/zoom
;  control (PTZ) of a camera
;SectionFlags for PTZ 2 parameters: 
PTZAutoConnect false     ; If true, connect to this PTZ by default.
PTZType unknown          ; PTZ or PTU type
PTZInverted false        ; If unit is mounted inverted (upside-down)
PTZSerialPort none       ; serial port, or none if not using serial port
                         ; communication
PTZRobotAuxSerialPort -1 ; Pioneer aux. serial port, or -1 if not using aux.
                         ; serial port for communication.
PTZAddress 192.168.0.90  ; IP address or hostname, or none if not using network
                         ; communication.
PTZTCPPort 80            ; TCP Port to use for HTTP network connection

Section PTZ 3 parameters
;  Information about the connection to a pan/tilt unit (PTU) or pan/tilt/zoom
;  control (PTZ) of a camera
;SectionFlags for PTZ 3 parameters: 
PTZAutoConnect false     ; If true, connect to this PTZ by default.
PTZType unknown          ; PTZ or PTU type
PTZInverted false        ; If unit is mounted inverted (upside-down)
PTZSerialPort none       ; serial port, or none if not using serial port
                         ; communication
PTZRobotAuxSerialPort -1 ; Pioneer aux. serial port, or -1 if not using aux.
                         ; serial port for communication.
PTZAddress 192.168.0.90  ; IP address or hostname, or none if not using network
                         ; communication.
PTZTCPPort 80            ; TCP Port to use for HTTP network connection

Section PTZ 4 parameters
;  Information about the connection to a pan/tilt unit (PTU) or pan/tilt/zoom
;  control (PTZ) of a camera
;SectionFlags for PTZ 4 parameters: 
PTZAutoConnect false     ; If true, connect to this PTZ by default.
PTZType unknown          ; PTZ or PTU type
PTZInverted false        ; If unit is mounted inverted (upside-down)
PTZSerialPort none       ; serial port, or none if not using serial port
                         ; communication
PTZRobotAuxSerialPort -1 ; Pioneer aux. serial port, or -1 if not using aux.
                         ; serial port for communication.
PTZAddress 192.168.0.90  ; IP address or hostname, or none if not using network
                         ; communication.
PTZTCPPort 80            ; TCP Port to use for HTTP network connection

Section PTZ 5 parameters
;  Information about the connection to a pan/tilt unit (PTU) or pan/tilt/zoom
;  control (PTZ) of a camera
;SectionFlags for PTZ 5 parameters: 
PTZAutoConnect false     ; If true, connect to this PTZ by default.
PTZType unknown          ; PTZ or PTU type
PTZInverted false        ; If unit is mounted inverted (upside-down)
PTZSerialPort none       ; serial port, or none if not using serial port
                         ; communication
PTZRobotAuxSerialPort -1 ; Pioneer aux. serial port, or -1 if not using aux.
                         ; serial port for communication.
PTZAddress 192.168.0.90  ; IP address or hostname, or none if not using network
                         ; communication.
PTZTCPPort 80            ; TCP Port to use for HTTP network connection

Section PTZ 6 parameters
;  Information about the connection to a pan/tilt unit (PTU) or pan/tilt/zoom
;  control (PTZ) of a camera
;SectionFlags for PTZ 6 parameters: 
PTZAutoConnect false     ; If true, connect to this PTZ by default.
PTZType unknown          ; PTZ or PTU type
PTZInverted false        ; If unit is mounted inverted (upside-down)
PTZSerialPort none       ; serial port, or none if not using serial port
                         ; communication
PTZRobotAuxSerialPort -1 ; Pioneer aux. serial port, or -1 if not using aux.
                         ; serial port for communication.
PTZAddress 192.168.0.90  ; IP address or hostname, or none if not using network
                         ; communication.
PTZTCPPort 80            ; TCP Port to use for HTTP network connection

Section PTZ 7 parameters
;  Information about the connection to a pan/tilt unit (PTU) or pan/tilt/zoom
;  control (PTZ) of a camera
;SectionFlags for PTZ 7 parameters: 
PTZAutoConnect false     ; If true, connect to this PTZ by default.
PTZType unknown          ; PTZ or PTU type
PTZInverted false        ; If unit is mounted inverted (upside-down)
PTZSerialPort none       ; serial port, or none if not using serial port
                         ; communication
PTZRobotAuxSerialPort -1 ; Pioneer aux. serial port, or -1 if not using aux.
                         ; serial port for communication.
PTZAddress 192.168.0.90  ; IP address or hostname, or none if not using network
                         ; communication.
PTZTCPPort 80            ; TCP Port to use for HTTP network connection

Section PTZ 8 parameters
;  Information about the connection to a pan/tilt unit (PTU) or pan/tilt/zoom
;  control (PTZ) of a camera
;SectionFlags for PTZ 8 parameters: 
PTZAutoConnect false     ; If true, connect to this PTZ by default.
PTZType unknown          ; PTZ or PTU type
PTZInverted false        ; If unit is mounted inverted (upside-down)
PTZSerialPort none       ; serial port, or none if not using serial port
                         ; communication
PTZRobotAuxSerialPort -1 ; Pioneer aux. serial port, or -1 if not using aux.
                         ; serial port for communication.
PTZAddress 192.168.0.90  ; IP address or hostname, or none if not using network
                         ; communication.
PTZTCPPort 80            ; TCP Port to use for HTTP network connection

Section Video 1 parameters
;  Information about the connection to a video acquisition device,
;  framegrabber, or camera
;SectionFlags for Video 1 parameters: 
VideoAutoConnect true    ; If true, connect to this device by default.
VideoType sx11           ; Device type
VideoInverted false      ; If image should be flipped (for cameras mounted
                         ; inverted/upside-down)
VideoWidth -1            ; Desired width of image
VideoHeight -1           ; Desired height of image
VideoDeviceIndex -1      ; Device index
VideoDeviceName none     ; Device name (overrides VideoDeviceIndex)
VideoChannel -1          ; Input channel
VideoAnalogSignalFormat  ; NTSC or PAL
VideoAddress 192.168.0.90 ; IP address or hostname, or none if not using
                         ; network communication.
VideoTCPPort 80          ; TCP Port to use for HTTP network connection

Section Video 2 parameters
;  Information about the connection to a video acquisition device,
;  framegrabber, or camera
;SectionFlags for Video 2 parameters: 
VideoAutoConnect false   ; If true, connect to this device by default.
VideoType unknown        ; Device type
VideoInverted false      ; If image should be flipped (for cameras mounted
                         ; inverted/upside-down)
VideoWidth -1            ; Desired width of image
VideoHeight -1           ; Desired height of image
VideoDeviceIndex -1      ; Device index
VideoDeviceName none     ; Device name (overrides VideoDeviceIndex)
VideoChannel -1          ; Input channel
VideoAnalogSignalFormat  ; NTSC or PAL
VideoAddress 192.168.0.90 ; IP address or hostname, or none if not using
                         ; network communication.
VideoTCPPort 80          ; TCP Port to use for HTTP network connection

Section Video 3 parameters
;  Information about the connection to a video acquisition device,
;  framegrabber, or camera
;SectionFlags for Video 3 parameters: 
VideoAutoConnect false   ; If true, connect to this device by default.
VideoType unknown        ; Device type
VideoInverted false      ; If image should be flipped (for cameras mounted
                         ; inverted/upside-down)
VideoWidth -1            ; Desired width of image
VideoHeight -1           ; Desired height of image
VideoDeviceIndex -1      ; Device index
VideoDeviceName none     ; Device name (overrides VideoDeviceIndex)
VideoChannel -1          ; Input channel
VideoAnalogSignalFormat  ; NTSC or PAL
VideoAddress 192.168.0.90 ; IP address or hostname, or none if not using
                         ; network communication.
VideoTCPPort 80          ; TCP Port to use for HTTP network connection

Section Video 4 parameters
;  Information about the connection to a video acquisition device,
;  framegrabber, or camera
;SectionFlags for Video 4 parameters: 
VideoAutoConnect false   ; If true, connect to this device by default.
VideoType unknown        ; Device type
VideoInverted false      ; If image should be flipped (for cameras mounted
                         ; inverted/upside-down)
VideoWidth -1            ; Desired width of image
VideoHeight -1           ; Desired height of image
VideoDeviceIndex -1      ; Device index
VideoDeviceName none     ; Device name (overrides VideoDeviceIndex)
VideoChannel -1          ; Input channel
VideoAnalogSignalFormat  ; NTSC or PAL
VideoAddress 192.168.0.90 ; IP address or hostname, or none if not using
                         ; network communication.
VideoTCPPort 80          ; TCP Port to use for HTTP network connection

Section Video 5 parameters
;  Information about the connection to a video acquisition device,
;  framegrabber, or camera
;SectionFlags for Video 5 parameters: 
VideoAutoConnect false   ; If true, connect to this device by default.
VideoType unknown        ; Device type
VideoInverted false      ; If image should be flipped (for cameras mounted
                         ; inverted/upside-down)
VideoWidth -1            ; Desired width of image
VideoHeight -1           ; Desired height of image
VideoDeviceIndex -1      ; Device index
VideoDeviceName none     ; Device name (overrides VideoDeviceIndex)
VideoChannel -1          ; Input channel
VideoAnalogSignalFormat  ; NTSC or PAL
VideoAddress 192.168.0.90 ; IP address or hostname, or none if not using
                         ; network communication.
VideoTCPPort 80          ; TCP Port to use for HTTP network connection

Section Video 6 parameters
;  Information about the connection to a video acquisition device,
;  framegrabber, or camera
;SectionFlags for Video 6 parameters: 
VideoAutoConnect false   ; If true, connect to this device by default.
VideoType unknown        ; Device type
VideoInverted false      ; If image should be flipped (for cameras mounted
                         ; inverted/upside-down)
VideoWidth -1            ; Desired width of image
VideoHeight -1           ; Desired height of image
VideoDeviceIndex -1      ; Device index
VideoDeviceName none     ; Device name (overrides VideoDeviceIndex)
VideoChannel -1          ; Input channel
VideoAnalogSignalFormat  ; NTSC or PAL
VideoAddress 192.168.0.90 ; IP address or hostname, or none if not using
                         ; network communication.
VideoTCPPort 80          ; TCP Port to use for HTTP network connection

Section Video 7 parameters
;  Information about the connection to a video acquisition device,
;  framegrabber, or camera
;SectionFlags for Video 7 parameters: 
VideoAutoConnect false   ; If true, connect to this device by default.
VideoType unknown        ; Device type
VideoInverted false      ; If image should be flipped (for cameras mounted
                         ; inverted/upside-down)
VideoWidth -1            ; Desired width of image
VideoHeight -1           ; Desired height of image
VideoDeviceIndex -1      ; Device index
VideoDeviceName none     ; Device name (overrides VideoDeviceIndex)
VideoChannel -1          ; Input channel
VideoAnalogSignalFormat  ; NTSC or PAL
VideoAddress 192.168.0.90 ; IP address or hostname, or none if not using
                         ; network communication.
VideoTCPPort 80          ; TCP Port to use for HTTP network connection

Section Video 8 parameters
;  Information about the connection to a video acquisition device,
;  framegrabber, or camera
;SectionFlags for Video 8 parameters: 
VideoAutoConnect false   ; If true, connect to this device by default.
VideoType unknown        ; Device type
VideoInverted false      ; If image should be flipped (for cameras mounted
                         ; inverted/upside-down)
VideoWidth -1            ; Desired width of image
VideoHeight -1           ; Desired height of image
VideoDeviceIndex -1      ; Device index
VideoDeviceName none     ; Device name (overrides VideoDeviceIndex)
VideoChannel -1          ; Input channel
VideoAnalogSignalFormat  ; NTSC or PAL
VideoAddress 192.168.0.90 ; IP address or hostname, or none if not using
                         ; network communication.
VideoTCPPort 80          ; TCP Port to use for HTTP network connection


Logo

更多推荐