基于单例模式的配置文件读取方法
来源:互联网 发布:淘宝客户信息 编辑:程序博客网 时间:2024/06/08 10:26
TDOptions.h
#pragma once/** * \class CTDOptions TDOptions.h * \brief mamage options in TenderShower project */class CTDOptions{private: CTDOptions(void); ~CTDOptions(void);public: static CTDOptions * GetInstance();// static void ReleaseInstance();public: //THIDNormFaceGeoFormat* GetFaceGeoFormat(); bool LoadSystemConfig(); void SaveSystemConfig(); ////////////////////////////////////////////// inline CString GetDBLastUpateTime() const { return m_strLastUpdataTime; } inline int GetDBMaxIndex() const { return m_nMaxDBIndex; } void SetDBLastUpdateTime( CString strUpdateTime); void SetFPNum(int nFPNum);private: TCHAR m_pPathName[MAX_PATH]; CString m_strLastUpdataTime; int m_nMaxDBIndex;};#define TDGI CTDOptions::GetInstance()
TDOptions.cpp
#include "stdafx.h"#include "TDOptions.h"//CTDOptions* CTDOptions::m_pSingleInstance = NULL;CTDOptions::CTDOptions(void){ // m_nFeatureSize = THIDGetFaceFeatureSize(); memcpy(m_pPathName, g_strModelPath,MAX_PATH*sizeof(TCHAR)); ::PathAppend(m_pPathName, _T("RegistVerySyConfig.ini"));}CTDOptions::~CTDOptions(void){}CTDOptions * CTDOptions::GetInstance(){ static CTDOptions stance; return &stance;}bool CTDOptions::LoadSystemConfig(){ if (!PathFileExists(m_pPathName)) { return false; } TCHAR szTempBuffer[100] = {0}; GetPrivateProfileString(_T("DBParam"),_T("LastUpateTime"), _T("2015-09-01 12:00:00"), szTempBuffer,100, m_pPathName); m_strLastUpdataTime= szTempBuffer; m_nMaxDBIndex= GetPrivateProfileInt(_T("DBParam"), _T("MaxIndex"), 0, m_pPathName ); return true;}void CTDOptions::SetDBLastUpdateTime(CString strUpdateTime){ WritePrivateProfileString(_T("DBParam"), _T("LastUpateTime"), strUpdateTime, m_pPathName);}void CTDOptions::SetFPNum(int nFPNum){ // 将其值写入配置文件中 CString strTemp; strTemp.Format(_T("%d"), nFPNum); WritePrivateProfileString(_T("LocalDBNum"), _T("FPNum"), strTemp, m_pPathName);}
RegistVerySyConfig.ini
# 0 1 2 3 4 5 6 7 8 9
[DBParam]
#注释1
LastUpateTime=1
#注释2
MaxIndex=0
阅读全文
0 0
- 基于单例模式的配置文件读取方法
- JDOM读取XML配置文件--单例模式
- Java单例模式实例---读取配置文件
- Java单例模式实例---读取配置文件
- JAVA单例模式读取properties配置文件
- 单例模式之读取配置文件
- 全局变量的单例模式 从指定的配置文件中读取配置信息
- 单例模式读取配置文件到内存中
- 配置文件读取类conf.class.php 单例模式应用
- java单例读取配置文件
- 使用单例读取配置文件
- 单例模式的java配置文件读取器
- 读取配置文件的方法
- Sping2.5配置文件的单例共享模式与独立产生实例,同步方法使用
- 基于配置文件的工厂设计模式实现,并且做到对象的单例,类似于spring的ioc
- 单例模式取配置文件
- 单例模式加载配置文件
- 基于线程安全的单例模式
- 线程同步3 ------ 信号量在不同进程间同步的又一个实例
- TensorFlow识别图片数字
- Spring Bean 的5种作用域介绍
- Redundant_Connection_II
- git基本常识介绍
- 基于单例模式的配置文件读取方法
- 八种基本数据类型
- AndroidStudio项目配置一个重要概念:源集
- jQuery 操作 radio、select、checkbox
- 快速排序
- 根据帕斯卡三角的一行求帕斯卡三角的下一行
- hibernate常用配置
- 深入理解C++中public、protected及private用法
- ThinkPHP3.2 Ajax分页