about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-08-30 19:28:02 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-08-30 19:28:02 -0400
commite42d8636f3aa15e0ea8f723133914d6dba22009c (patch)
tree897699a71c06ed156f6463e7d67c8aaefed017ad /src
parent62bb8a055fea0a1f3e25f757ca8201f54bae6012 (diff)
downloadlibtwittercpp-e42d8636f3aa15e0ea8f723133914d6dba22009c.tar.gz
libtwittercpp-e42d8636f3aa15e0ea8f723133914d6dba22009c.tar.bz2
libtwittercpp-e42d8636f3aa15e0ea8f723133914d6dba22009c.zip
Whitespace changes
Diffstat (limited to 'src')
-rw-r--r--src/codes.cpp6
-rw-r--r--src/codes.h108
-rw-r--r--src/configuration.cpp10
-rw-r--r--src/configuration.h28
4 files changed, 76 insertions, 76 deletions
diff --git a/src/codes.cpp b/src/codes.cpp index 7805c7a..560194c 100644 --- a/src/codes.cpp +++ b/src/codes.cpp
@@ -2,15 +2,15 @@
2#include <sstream> 2#include <sstream>
3 3
4namespace twitter { 4namespace twitter {
5 5
6 const char* invalid_response::WHAT_TEXT = "Invalid response data received from Twitter"; 6 const char* invalid_response::WHAT_TEXT = "Invalid response data received from Twitter";
7 const char* connection_error::WHAT_TEXT = "Error connecting to Twitter"; 7 const char* connection_error::WHAT_TEXT = "Error connecting to Twitter";
8 8
9 std::string unknown_error::generateMessage(int response_code) 9 std::string unknown_error::generateMessage(int response_code)
10 { 10 {
11 std::ostringstream msgbuilder; 11 std::ostringstream msgbuilder;
12 msgbuilder << "Unknown error (HTTP " << response_code << ")"; 12 msgbuilder << "Unknown error (HTTP " << response_code << ")";
13 13
14 return msgbuilder.str(); 14 return msgbuilder.str();
15 } 15 }
16 16
diff --git a/src/codes.h b/src/codes.h index baf4f8f..b8812df 100644 --- a/src/codes.h +++ b/src/codes.h
@@ -5,179 +5,179 @@
5#include <string> 5#include <string>
6 6
7namespace twitter { 7namespace twitter {
8 8
9 class twitter_error : public std::runtime_error { 9 class twitter_error : public std::runtime_error {
10 public: 10 public:
11 11
12 using std::runtime_error::runtime_error; 12 using std::runtime_error::runtime_error;
13 }; 13 };
14 14
15 class bad_auth : public twitter_error { 15 class bad_auth : public twitter_error {
16 public: 16 public:
17 17
18 using twitter_error::twitter_error; 18 using twitter_error::twitter_error;
19 }; 19 };
20 20
21 class invalid_response : public twitter_error { 21 class invalid_response : public twitter_error {
22 public: 22 public:
23 23
24 static const char* WHAT_TEXT; 24 static const char* WHAT_TEXT;
25 25
26 explicit invalid_response(std::string response) noexcept 26 explicit invalid_response(std::string response) noexcept
27 : twitter_error(WHAT_TEXT), _response(std::move(response)) 27 : twitter_error(WHAT_TEXT), _response(std::move(response))
28 { 28 {
29 } 29 }
30 30
31 const std::string& getResponse() const noexcept 31 const std::string& getResponse() const noexcept
32 { 32 {
33 return _response; 33 return _response;
34 } 34 }
35 35
36 private: 36 private:
37 37
38 std::string _response; 38 std::string _response;
39 }; 39 };
40 40
41 class account_suspended : public twitter_error { 41 class account_suspended : public twitter_error {
42 public: 42 public:
43 43
44 using twitter_error::twitter_error; 44 using twitter_error::twitter_error;
45 }; 45 };
46 46
47 class rate_limit_exceeded : public twitter_error { 47 class rate_limit_exceeded : public twitter_error {
48 public: 48 public:
49 49
50 using twitter_error::twitter_error; 50 using twitter_error::twitter_error;
51 }; 51 };
52 52
53 class update_limit_exceeded : public twitter_error { 53 class update_limit_exceeded : public twitter_error {
54 public: 54 public:
55 55
56 using twitter_error::twitter_error; 56 using twitter_error::twitter_error;
57 }; 57 };
58 58
59 class bad_token : public twitter_error { 59 class bad_token : public twitter_error {
60 public: 60 public:
61 61
62 using twitter_error::twitter_error; 62 using twitter_error::twitter_error;
63 }; 63 };
64 64
65 class server_overloaded : public twitter_error { 65 class server_overloaded : public twitter_error {
66 public: 66 public:
67 67
68 using twitter_error::twitter_error; 68 using twitter_error::twitter_error;
69 }; 69 };
70 70
71 class server_error : public twitter_error { 71 class server_error : public twitter_error {
72 public: 72 public:
73 73
74 using twitter_error::twitter_error; 74 using twitter_error::twitter_error;
75 }; 75 };
76 76
77 class bad_length : public twitter_error { 77 class bad_length : public twitter_error {
78 public: 78 public:
79 79
80 using twitter_error::twitter_error; 80 using twitter_error::twitter_error;
81 }; 81 };
82 82
83 class duplicate_status : public twitter_error { 83 class duplicate_status : public twitter_error {
84 public: 84 public:
85 85
86 using twitter_error::twitter_error; 86 using twitter_error::twitter_error;
87 }; 87 };
88 88
89 class suspected_spam : public twitter_error { 89 class suspected_spam : public twitter_error {
90 public: 90 public:
91 91
92 using twitter_error::twitter_error; 92 using twitter_error::twitter_error;
93 }; 93 };
94 94
95 class write_restricted : public twitter_error { 95 class write_restricted : public twitter_error {
96 public: 96 public:
97 97
98 using twitter_error::twitter_error; 98 using twitter_error::twitter_error;
99 }; 99 };
100 100
101 class invalid_media : public twitter_error { 101 class invalid_media : public twitter_error {
102 public: 102 public:
103 103
104 using twitter_error::twitter_error; 104 using twitter_error::twitter_error;
105 }; 105 };
106 106
107 class server_unavailable : public twitter_error { 107 class server_unavailable : public twitter_error {
108 public: 108 public:
109 109
110 using twitter_error::twitter_error; 110 using twitter_error::twitter_error;
111 }; 111 };
112 112
113 class server_timeout : public twitter_error { 113 class server_timeout : public twitter_error {
114 public: 114 public:
115 115
116 using twitter_error::twitter_error; 116 using twitter_error::twitter_error;
117 }; 117 };
118 118
119 class unknown_error : public twitter_error { 119 class unknown_error : public twitter_error {
120 public: 120 public:
121 121
122 unknown_error(int response_code, std::string response_data) 122 unknown_error(int response_code, std::string response_data)
123 : twitter_error(generateMessage(response_code)), 123 : twitter_error(generateMessage(response_code)),
124 _response_code(response_code), 124 _response_code(response_code),
125 _response_data(std::move(response_data)) 125 _response_data(std::move(response_data))
126 { 126 {
127 } 127 }
128 128
129 int getResponseCode() const noexcept 129 int getResponseCode() const noexcept
130 { 130 {
131 return _response_code; 131 return _response_code;
132 } 132 }
133 133
134 const std::string& getResponse() const noexcept 134 const std::string& getResponse() const noexcept
135 { 135 {
136 return _response_data; 136 return _response_data;
137 } 137 }
138 138
139 private: 139 private:
140 140
141 static std::string generateMessage(int response_code); 141 static std::string generateMessage(int response_code);
142 142
143 int _response_code; 143 int _response_code;
144 std::string _response_data; 144 std::string _response_data;
145 }; 145 };
146 146
147 class connection_error : public twitter_error { 147 class connection_error : public twitter_error {
148 public: 148 public:
149 149
150 static const char* WHAT_TEXT; 150 static const char* WHAT_TEXT;
151 151
152 connection_error() noexcept : twitter_error(WHAT_TEXT) 152 connection_error() noexcept : twitter_error(WHAT_TEXT)
153 { 153 {
154 } 154 }
155 }; 155 };
156 156
157 class invalid_member : public std::domain_error { 157 class invalid_member : public std::domain_error {
158 public: 158 public:
159 159
160 using std::domain_error::domain_error; 160 using std::domain_error::domain_error;
161 }; 161 };
162 162
163 class malformed_object : public invalid_response { 163 class malformed_object : public invalid_response {
164 public: 164 public:
165 165
166 malformed_object(std::string type, std::string data) noexcept 166 malformed_object(std::string type, std::string data) noexcept
167 : invalid_response(std::move(data)), _type(std::move(type)) 167 : invalid_response(std::move(data)), _type(std::move(type))
168 { 168 {
169 } 169 }
170 170
171 const std::string& getType() const noexcept 171 const std::string& getType() const noexcept
172 { 172 {
173 return _type; 173 return _type;
174 } 174 }
175 175
176 private: 176 private:
177 177
178 std::string _type; 178 std::string _type;
179 }; 179 };
180 180
181}; 181};
182 182
183#endif /* end of include guard: CODES_H_05838D39 */ 183#endif /* end of include guard: CODES_H_05838D39 */
diff --git a/src/configuration.cpp b/src/configuration.cpp index 0010a40..ed0ba8c 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp
@@ -4,18 +4,18 @@
4#include "codes.h" 4#include "codes.h"
5 5
6namespace twitter { 6namespace twitter {
7 7
8 configuration::configuration(std::string data) try 8 configuration::configuration(std::string data) try
9 { 9 {
10 auto json_data = nlohmann::json::parse(data); 10 auto json_data = nlohmann::json::parse(data);
11 11
12 _characters_reserved_per_media = json_data["characters_reserved_per_media"].get<size_t>(); 12 _characters_reserved_per_media = json_data["characters_reserved_per_media"].get<size_t>();
13 _dm_text_character_limit = json_data["dm_text_character_limit"].get<size_t>(); 13 _dm_text_character_limit = json_data["dm_text_character_limit"].get<size_t>();
14 _max_media_per_upload = json_data["max_media_per_upload"].get<size_t>(); 14 _max_media_per_upload = json_data["max_media_per_upload"].get<size_t>();
15 _photo_size_limit = json_data["photo_size_limit"].get<size_t>(); 15 _photo_size_limit = json_data["photo_size_limit"].get<size_t>();
16 _short_url_length = json_data["short_url_length"].get<size_t>(); 16 _short_url_length = json_data["short_url_length"].get<size_t>();
17 _short_https_url_length = json_data["short_url_length_https"].get<size_t>(); 17 _short_https_url_length = json_data["short_url_length_https"].get<size_t>();
18 18
19 for (auto sizedata = std::begin(json_data["photo_sizes"]); sizedata != std::end(json_data["photo_sizes"]); ++sizedata) 19 for (auto sizedata = std::begin(json_data["photo_sizes"]); sizedata != std::end(json_data["photo_sizes"]); ++sizedata)
20 { 20 {
21 photosize size; 21 photosize size;
@@ -27,10 +27,10 @@ namespace twitter {
27 } else { 27 } else {
28 size.resize = resizetype::crop; 28 size.resize = resizetype::crop;
29 } 29 }
30 30
31 _photo_sizes[sizedata.key()] = size; 31 _photo_sizes[sizedata.key()] = size;
32 } 32 }
33 33
34 for (auto path : json_data["non_username_paths"]) 34 for (auto path : json_data["non_username_paths"])
35 { 35 {
36 _non_username_paths.insert(path.get<std::string>()); 36 _non_username_paths.insert(path.get<std::string>());
diff --git a/src/configuration.h b/src/configuration.h index 543e306..e9c3be3 100644 --- a/src/configuration.h +++ b/src/configuration.h
@@ -6,64 +6,64 @@
6#include <set> 6#include <set>
7 7
8namespace twitter { 8namespace twitter {
9 9
10 class configuration { 10 class configuration {
11 public: 11 public:
12 enum class resizetype { 12 enum class resizetype {
13 fit, 13 fit,
14 crop 14 crop
15 }; 15 };
16 16
17 struct photosize { 17 struct photosize {
18 size_t height; 18 size_t height;
19 size_t width; 19 size_t width;
20 resizetype resize; 20 resizetype resize;
21 }; 21 };
22 22
23 explicit configuration(std::string data); 23 explicit configuration(std::string data);
24 24
25 size_t getCharactersReservedPerMedia() const 25 size_t getCharactersReservedPerMedia() const
26 { 26 {
27 return _characters_reserved_per_media; 27 return _characters_reserved_per_media;
28 } 28 }
29 29
30 size_t getDirectMessageCharacterLimit() const 30 size_t getDirectMessageCharacterLimit() const
31 { 31 {
32 return _dm_text_character_limit; 32 return _dm_text_character_limit;
33 } 33 }
34 34
35 size_t getMaxMediaPerUpload() const 35 size_t getMaxMediaPerUpload() const
36 { 36 {
37 return _max_media_per_upload; 37 return _max_media_per_upload;
38 } 38 }
39 39
40 size_t getPhotoSizeLimit() const 40 size_t getPhotoSizeLimit() const
41 { 41 {
42 return _photo_size_limit; 42 return _photo_size_limit;
43 } 43 }
44 44
45 const std::map<std::string, photosize>& getPhotoSizes() const 45 const std::map<std::string, photosize>& getPhotoSizes() const
46 { 46 {
47 return _photo_sizes; 47 return _photo_sizes;
48 } 48 }
49 49
50 size_t getShortUrlLength() const 50 size_t getShortUrlLength() const
51 { 51 {
52 return _short_url_length; 52 return _short_url_length;
53 } 53 }
54 54
55 size_t getShortHttpsUrlLength() const 55 size_t getShortHttpsUrlLength() const
56 { 56 {
57 return _short_https_url_length; 57 return _short_https_url_length;
58 } 58 }
59 59
60 const std::set<std::string>& getNonUsernamePaths() const 60 const std::set<std::string>& getNonUsernamePaths() const
61 { 61 {
62 return _non_username_paths; 62 return _non_username_paths;
63 } 63 }
64 64
65 private: 65 private:
66 66
67 size_t _characters_reserved_per_media; 67 size_t _characters_reserved_per_media;
68 size_t _dm_text_character_limit; 68 size_t _dm_text_character_limit;
69 size_t _max_media_per_upload; 69 size_t _max_media_per_upload;
@@ -73,7 +73,7 @@ namespace twitter {
73 size_t _short_https_url_length; 73 size_t _short_https_url_length;
74 std::set<std::string> _non_username_paths; 74 std::set<std::string> _non_username_paths;
75 }; 75 };
76 76
77}; 77};
78 78
79#endif /* end of include guard: CONFIGURATION_H_A7164D18 */ 79#endif /* end of include guard: CONFIGURATION_H_A7164D18 */