source: tags/0.58/wrequest.h @ 9

Last change on this file since 9 was 9, checked in by willem, 11 years ago

willem

File size: 3.3 KB
Line 
1#ifndef WREQUEST_H
2#define WREQUEST_H
3#include <string>
4#include <iostream>
5#include <curl/curl.h>
6#include "wutils.h"
7
8class messageclass
9{
10  private:
11    std::string protocol;
12    std::string whoami;
13    std::string pool;
14    std::string command;
15    std::string multi;
16    std::string value;
17
18  public:
19  //constructor
20    messageclass()
21    {
22      this->protocol = " ";
23      this->whoami   = " ";
24      this->pool     = " ";
25      this->command  = " ";
26      this->multi    = " ";
27      this->value    = " ";
28    }
29    void set_protocol(const std::string &p){ this->protocol = p;    }
30    std::string get_protocol(void)         { return this->protocol; }
31
32    void set_whoami(const std::string &u)  { this->whoami = u;      }
33    std::string  get_whoami(void)          { return this->whoami;   }
34
35    void set_pool(const std::string &p)    { this->pool = p;        }
36    std::string  get_pool(void)            { return this->pool;     }
37
38    void set_command(const std::string &c) { this->command = c;     }
39    std::string  get_command(void)         { return this->command;  }
40
41    void set_multi(const std::string &m)   { this->multi = m;       }
42    std::string  get_multi(void)           { return this->multi;    }
43
44    void set_value(const std::string &v)   { this->value = v;       }
45    std::string  get_value(void)           { return this->value;    }
46
47};
48
49class wrequest
50{
51  private: 
52    CURL *curl;
53
54    std::string configfilename;
55    std::string configdirname;
56    std::string config;
57    void set_configfilename(void);
58
59    std::string serveraddress;
60    std::string serverurl;
61    int port;
62
63    messageclass message;
64    void compose_message(std::string &m);
65    int get_answer(void);
66    std::string data;
67    bool debugging;
68
69  public:
70    //constructor
71    wrequest(void);
72
73    //destructor
74    ~wrequest(void);
75
76    static const unsigned int config_size = 8;
77
78    std::string get_config(void)             { return this->config; };
79
80    int set_serverurl(const std::string &u);
81    std::string get_serverurl(void)          { return this->serverurl; }
82   
83    void set_port(int);
84    int  get_port(void);
85
86    int read_config(void);
87    int write_config(void);
88
89    void set_protocol(const std::string &p){ this->message.set_protocol(p);       }
90    std::string get_protocol(void)         { return this->message.get_protocol(); }
91
92    void set_whoami(const std::string &u)  { this->message.set_whoami(u);         }
93    std::string  get_whoami(void)          { return this->message.get_whoami();   }
94
95    void set_pool(const std::string &p)    { this->message.set_pool(p);           }
96    std::string  get_pool(void)            { return this->message.get_pool();     }
97
98    void set_command(const std::string &c) { this->message.set_command(c);        }
99    std::string  get_command(void)         { return this->message.get_command();  }
100
101    void set_multi(const std::string &m)   { this->message.set_multi(m);          }
102    std::string  get_multi(void)           { return this->message.get_multi();    }
103
104    void set_value(const std::string &v)   { this->message.set_value(v);          }
105    std::string  get_value(void)           { return this->message.get_value();    }
106
107    void set_debug(void)                   { this->debugging = 1; }
108    void unset_debug(void)                 { this->debugging = 0; }
109
110    int send_message(std::string &body,std::string &header);
111 
112};
113#endif
Note: See TracBrowser for help on using the repository browser.