url_config.h
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#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();
/*Only the protocol and server port can be modified.
TODO: review what should be modified.*/
void ModifyCfg(bool is_https, uint16_t port);
// Some interfaces followed as below return string object,
// don't worry about the cost because we have RVO & move semantics.
bool IsHttps() const;
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 MainPath() const; // /main
std::string LoginPath() const; // /login
std::string LogoutPath() const;
std::string MenuAuthPath() const;
std::string UserMsgCountPath() const;
std::string UserMsgPath() const;
std::string PwdModificationPath() const;
std::string GetCardNamePath() const;
std::string GetCommNamePath() const;
std::string GetSubmitOrdersPath() const;
std::string GetSellerCardPath() const;
std::string GetFinishStatementPath() const;
private:
URLConfig();
URLConfig(const URLConfig&);
URLConfig& operator=(const URLConfig&);
bool m_is_https;
std::string m_protocol;
std::string m_host;
uint16_t m_port;
std::string m_main_path;
std::string m_login_path;
std::string m_logout_path;
std::string m_menu_auth_path;
std::string m_user_msg_count_path;
std::string m_user_msg_path;
std::string m_modify_pwd_path;
std::string m_get_card_name_path;
std::string m_get_seller_card_path;
std::string m_get_product_path;
std::string m_submit_orders_path;
std::string m_finish_order_path;
};
#endif // ETRADECLIENT_UTILITY_URL_CONFIG_H_INCLUDED