C++ 配置文件解析类 ParseConfig
依赖项:
依赖于 ProcessString 类,可从该篇博客获取「字符串处理类 ProcessString (包含常用字符串处理函数)」
ParseConfig.h
//Linux & C++11
#pragma once
//包含系统头文件
#include <string>
#include <exception>
#include <memory>
#include <map>
//宏定义:函数参数流向
#define IN
#define OUT
#define INOUT
//使用命名
using std::string;
using std::exception;
using std::shared_ptr;
using std::make_shared;
using std::map;
namespace sinicheveen
{
class ParseConfig
{
public:
//group 1:解析、获取配置
//解析配置文件到 map 中
static void parseConfFileIntoMap();
//输出 m_mConfs 中的配置项
static void printConfInMap();
//从 m_mConfs 中获取某个 section 下的某项配置
static string getSpecConfValFromMap(IN const string& strSectionName, IN const string& strConfName);
//从 m_mConfs 中获取某项配置,如果在多个 section 下有相同的配置名,则获取第一个 seciton 下的配置值
static string getSpecConfValFromMap(IN const string& strConfName);
//从配置文件中获取某个 section 下的某项配置
static string getSpecConfValFromFile(IN const string& strSectionName, IN const string& strConfName);
//从配置文件中获取某项配置,如果在多个 section 下有相同的配置名,则获取第一个 seciton 下的配置值
static string getSpecConfValFromFile(IN const string& strConfName);
//guoup 2:格式校验
//校验 section name 格式,格式必须是 [XXXX]
static void checkSectionNameFromat(INOUT const string& strConf, IN const uint32_t lineNum);
//校验配置项格式
static void checkConfItemFormat(INOUT const string& strConf, IN const uint32_t lineNum);
//group 3:静态成员初始化
//初始化静态成员 m_mConfs
static map<string, map<string, string>> initStaticMapConfs();
//group 4:静态变量
private:
static string m_strConfFilePath;
static map<string, map<string, string> > m_mConfs;
}; //ParseConfig
} //sinicheveen
ParseConfig.cpp
未完 ......
点击访问原文(进入后根据右侧标签,快速定位到本文)
C++ 配置文件解析类 ParseConfig的更多相关文章
- ibatis源码学习2_初始化和配置文件解析
问题在详细介绍ibatis初始化过程之前,让我们先来思考几个问题. 1. ibatis初始化的目标是什么?上文中提到过,ibatis初始化的核心目标是构造SqlMapClientImpl对象,主要是其 ...
- MyBatis配置文件解析
MyBatis配置文件解析(概要) 1.configuration:根元素 1.1 properties:定义配置外在化 1.2 settings:一些全局性的配置 1.3 typeAliases:为 ...
- Hadoop配置文件解析
Hadoop源码解析 2 --- Hadoop配置文件解析 1 Hadoop Configuration简介 Hadoop没有使用java.util.Properties管理配置文件, 也没有使 ...
- Hibernate的配置文件解析
配置mybatis.xml或hibernate.cfg.xml报错: <property name="connection.url">jdbc:mysql://loca ...
- WCF中配置文件解析
WCF中配置文件解析[1] 2014-06-14 WCF中配置文件解析 参考 WCF中配置文件解析 返回 在WCF Service Configuration Editor的使用中,我们通过配置工具自 ...
- 自己用的框架写了一个PHP模版解析类
<?php if(!defined('IS_HEARTPHP')) exit('Access Denied'); /** * template.class.php 模板解析类 * * @copy ...
- nginx源代码分析--配置文件解析
ngx-conf-parsing 对 Nginx 配置文件的一些认识: 配置指令具有作用域,分为全局作用域和使用 {} 创建其他作用域. 同一作用域的不同的配置指令没有先后顺序:同一作用域能否使用同样 ...
- PHP模板解析类实例
作者:mckee 这篇文章主要介绍了PHP模板解析类,涉及php针对模板文件的解析与字符串处理的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下 <?php class template { ...
- Spring Security 入门(1-6-1)Spring Security - 配置文件解析和访问请求处理
1.在pom.xml中添加maven坐标 <dependency> <groupId>org.springframework.security</groupId> ...
随机推荐
- js中的那些遍历
说到遍历,首先想到的是数组的遍历,方法不要太多,比如 for, forEach,map,filter,every,some等 下面来看下,用法 首先 定义一个数组: 1. for循环,需要知道数组的长 ...
- JDBC 操作
简单的 JDBC 操作主要有: JdbcTemplate query queryForObject queryForList update execute 简单使用如下所示. 初始化数据库 sprin ...
- Ubuntu+QEMU+Xv6环境搭建
操作系统:Ubuntu 16.04 32位 虚拟机:VMware 模拟器:QEMU 之前有一台centos 64位虚拟机,使用源码安装配置环境,出了一些列问题,最终环境都已经配好了,也能够在qemu上 ...
- 大数据技术之kettle(2)——练习三个基本操作
一.同一数据库两表数据关联更新 实现效果:把stu1的数据按id同步到stu2,stu2有相同id则更新数据 步骤: 1.在mysql中创建两张表: mysql>create database ...
- PHP的ini_set函数用法
PHP ini_set用来设置php.ini的值,在函数执行的时候生效,脚本结束后,设置失效.无需打开php.ini文件,就能修改配置,对于虚拟空间来说,很方便. 函数格式:string in ...
- 关于Delphi中二维数组的声明和大小调整
这是一个实例: procedure TMainForm.Button1Click(Sender: TObject);var arr:array of array of string;begin s ...
- laravel修改了配置文件不生效,修改了数据库配置文件不生效
Laravel缓存配置文件,因此您可能只需要清除缓存: php artisan config:clear 转: http://www.voidcn.com/article/p-sgcusrjp-bxw ...
- Android 调用WCF实例详解
上篇文章已经对Web Service及其相关知识进行了介绍(Android开发之WebService介绍 ),相信有的朋友已经忍耐不住想试试在Android应用中调用Web Service.本文将通过 ...
- MySQL 行转列 -》动态行转列 -》动态行转列带计算
Pivot Table Using MySQL - A Complete Guide | WebDevZoomhttp://webdevzoom.com/pivot-table-using-mysql ...
- 小D课堂 - 零基础入门SpringBoot2.X到实战_第9节 SpringBoot2.x整合Redis实战_38、源码编译安装Redis4.x
笔记 2.源码编译安装Redis4.x 简介:使用源码安装Redis4.x和配置外网访问 1.快速安装 https://redis.io/download#installation ...