libiqxmlrpc  0.12.4
 All Classes Namespaces Files Functions Typedefs Enumerations
client_opts.h
1 // Libiqxmlrpc - an object-oriented XML-RPC solution.
2 // Copyright (C) 2011 Anton Dedov
3 
4 #ifndef _iqxmlrpc_client_opts_h_
5 #define _iqxmlrpc_client_opts_h_
6 
7 #include <string>
8 #include "inet_addr.h"
9 
10 namespace iqxmlrpc {
11 
12 class LIBIQXMLRPC_API Client_options {
13 public:
15  const iqnet::Inet_addr& addr,
16  const std::string& uri,
17  const std::string& vhost
18  ):
19  addr_(addr),
20  uri_(uri),
21  vhost_(vhost.empty() ? addr.get_host_name() : vhost),
22  keep_alive_(false),
23  timeout_(-1),
24  non_blocking_flag_(false)
25  {
26  }
27 
28  const iqnet::Inet_addr& addr() const { return addr_; }
29  const std::string& uri() const { return uri_; }
30  const std::string& vhost() const { return vhost_; }
31  int timeout() const { return timeout_; }
32  bool non_blocking() const { return non_blocking_flag_; }
33  bool keep_alive() const { return keep_alive_; }
34 
35  bool has_authinfo() const { return !auth_user_.empty(); }
36  const std::string& auth_user() const { return auth_user_; }
37  const std::string& auth_passwd() const { return auth_passwd_; }
38 
39  void set_timeout( int seconds )
40  {
41  if( (timeout_ = seconds) > 0 )
42  non_blocking_flag_ = true;
43  }
44 
45  void set_keep_alive( bool keep_alive )
46  {
47  keep_alive_ = keep_alive;
48  }
49 
50  void set_authinfo( const std::string& user, const std::string& password )
51  {
52  auth_user_ = user;
53  auth_passwd_ = password;
54  }
55 
56 private:
57  iqnet::Inet_addr addr_;
58  std::string uri_;
59  std::string vhost_;
60  bool keep_alive_;
61 
62  int timeout_;
63  bool non_blocking_flag_;
64 
65  std::string auth_user_;
66  std::string auth_passwd_;
67 };
68 
69 } // namespace iqxmlrpc
70 
71 #endif
72 // vim:ts=2:sw=2:et