url_config.h 1017 Bytes
#ifndef ETRADECLIENT_UTILITY_URL_CONFIG_H_INCLUDED
#define ETRADECLIENT_UTILITY_URL_CONFIG_H_INCLUDED

/*A "singleton" class to provide a universal interface to access the configuration about URLs.*/

#include <string>
#include <cstdint>

class URLConfig
{
public:
	/*Exception will be thrown if config file path not correct.*/
	static URLConfig& Instance();

	// Some interfaces followed as below return string object,
	// don't worry about the cost because we have RVO & move semantics.
	std::string Host() const; // xxx.com
	uint16_t Port() const; // 443 or 80 or user configured port.
	std::string FullHost() const; // Helper function to get the full host path: protocol + host + port.
	std::string DownloadUrl() const;
	std::string DownloadFileUrl() const;

private:
	URLConfig();
	URLConfig(const URLConfig&);
	URLConfig& operator=(const URLConfig&);

	std::string m_host;
	uint16_t	m_port;
	std::string m_download_url;
	std::string m_download_file_url;

};
#endif // ETRADECLIENT_UTILITY_URL_CONFIG_H_INCLUDED