logplus/Workflow/WFCrystal/SysUtility/configuration/include/Configure.h

163 lines
3.1 KiB
C
Raw Permalink Normal View History

2026-01-16 17:18:41 +08:00
/*
* Configure.h
*
* Created on: 2011-11-16
*
* @file Configure.h
* @brief
*/
#ifndef PAI_FRAME_SYSUTILITY_CONFIGURE_H
#define PAI_FRAME_SYSUTILITY_CONFIGURE_H
#include <string>
#include <map>
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string.h>
#include "Turtle.h"
namespace pai {
namespace conf {
typedef std::map<std::string, std::string> map_type;
/**
* @class CConfigure
* @brief
*
*/
class PAI_CONFIGURE_EXPORT CConfigure
{
public:
/**
* @brief
*
*/
CConfigure();
/**
* @brief
*
* @param[in] path
*
*/
CConfigure(const std::string& configureFileName);
/**
* @brief
*
* @param[in] path
*
*/
CConfigure(const char* configureFileName);
/**
* @brief
*/
CConfigure(const CConfigure & lrh);
/**
* @brief
*/
CConfigure & operator = (const CConfigure & lrh);
/**
* @brief
*
*/
~CConfigure();
/**
* @brief
*
* @param[in] key
* @return
*/
std::string GetValueByKey(const std::string& key);
/**
* @brief
*
* @param[in] key
* @return
*/
std::string GetValueByKey(const char* key);
/**
* @brief
*
* @param[out] key
*/
void GetKeys(std::vector<std::string>& key) const;
/**
* @brief map
*/
std::map<std::string, std::string> GetKeys() const;
/**
* @brief
*
*/
void Print();
/**
* @brief
*
*/
int GetMapSize();
private:
/**
* @brief
*
* @param[in] configureFileName
*/
void SetFromFile(const std::string& path);
/**
* @brief PAI_HOME环境变量
*/
std::string GetPaiHomePath();
void SetFromLine(const char* configureLine);
std::string ParseRawKey(std::string& rawKey);
std::string ParseRawValue(std::string& rawValue);
/**
* @brief replace specific word
*
* @param[in] word to replace.
*
* @param[in] using env value to replace or not.
*
*/
std::string replaceWord(std::string& word,bool usingEnv);
std::string replaceWithEnvValue(const std::string& key);
//std::string FindEnvValue(std::string& str);
/**
* @brief get absolute file path.
*
* @param[in] relative path or absolute path.
*/
std::string GetConfigureFilePath(const std::string& str);
/**
* @brief check the file existence using absolute path
*
* @param[in] absolute path
*
*/
bool ExistFile(const char* path);
void replaceEnvromentValue();
int recount;
map_type m_configureValue;
protected:
};
}
}
#endif