Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/shared/Communication.h

Issue 11013110: Cleanup (Closed)
Patch Set: Refactoring CallAdblockPlusEngine Created July 24, 2013, 9:09 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/plugin/PluginSettings.cpp ('K') | « src/plugin/PluginSettings.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #ifndef COMMUNICATION_H 1 #ifndef COMMUNICATION_H
2 #define COMMUNICATION_H 2 #define COMMUNICATION_H
3 3
4 #include <memory> 4 #include <memory>
5 #include <sstream> 5 #include <sstream>
6 #include <stdexcept> 6 #include <stdexcept>
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include <Windows.h> 10 #include <Windows.h>
(...skipping 17 matching lines...) Expand all
28 PROC_GET_PREF 28 PROC_GET_PREF
29 }; 29 };
30 enum ValueType : uint32_t { 30 enum ValueType : uint32_t {
31 TYPE_PROC, TYPE_STRING, TYPE_WSTRING, TYPE_INT64, TYPE_INT32, TYPE_BOOL 31 TYPE_PROC, TYPE_STRING, TYPE_WSTRING, TYPE_INT64, TYPE_INT32, TYPE_BOOL
32 }; 32 };
33 typedef uint32_t SizeType; 33 typedef uint32_t SizeType;
34 34
35 class InputBuffer 35 class InputBuffer
36 { 36 {
37 public: 37 public:
38 InputBuffer() : buffer(), hasType(false) {}
38 InputBuffer(const std::string& data) : buffer(data), hasType(false) {} 39 InputBuffer(const std::string& data) : buffer(data), hasType(false) {}
40 InputBuffer(const InputBuffer& copy) { hasType = copy.hasType; buffer = std: :istringstream(copy.buffer.str()); currentType = copy.currentType; }
39 InputBuffer& operator>>(ProcType& value) { return Read(value, TYPE_PROC); } 41 InputBuffer& operator>>(ProcType& value) { return Read(value, TYPE_PROC); }
40 InputBuffer& operator>>(std::string& value) { return ReadString(value, TYPE_ STRING); } 42 InputBuffer& operator>>(std::string& value) { return ReadString(value, TYPE_ STRING); }
41 InputBuffer& operator>>(std::wstring& value) { return ReadString(value, TYPE _WSTRING); } 43 InputBuffer& operator>>(std::wstring& value) { return ReadString(value, TYPE _WSTRING); }
42 InputBuffer& operator>>(int64_t& value) { return Read(value, TYPE_INT64); } 44 InputBuffer& operator>>(int64_t& value) { return Read(value, TYPE_INT64); }
43 InputBuffer& operator>>(int32_t& value) { return Read(value, TYPE_INT32); } 45 InputBuffer& operator>>(int32_t& value) { return Read(value, TYPE_INT32); }
44 InputBuffer& operator>>(bool& value) { return Read(value, TYPE_BOOL); } 46 InputBuffer& operator>>(bool& value) { return Read(value, TYPE_BOOL); }
47 InputBuffer& operator=(const InputBuffer& copy) { hasType = copy.hasType; bu ffer = std::istringstream(copy.buffer.str());
48 currentType = copy.current Type; return *this; }
Wladimir Palant 2013/07/26 16:45:37 Weird indentation here - how about splitting this
45 ValueType GetType(); 49 ValueType GetType();
46 private: 50 private:
47 std::istringstream buffer; 51 std::istringstream buffer;
48 ValueType currentType; 52 ValueType currentType;
49 bool hasType; 53 bool hasType;
50 54
51 void CheckType(ValueType expectedType); 55 void CheckType(ValueType expectedType);
52 56
53 template<class T> 57 template<class T>
54 InputBuffer& ReadString(T& value, ValueType expectedType) 58 InputBuffer& ReadString(T& value, ValueType expectedType)
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 167
164 InputBuffer ReadMessage(); 168 InputBuffer ReadMessage();
165 void WriteMessage(OutputBuffer& message); 169 void WriteMessage(OutputBuffer& message);
166 170
167 protected: 171 protected:
168 HANDLE pipe; 172 HANDLE pipe;
169 }; 173 };
170 } 174 }
171 175
172 #endif 176 #endif
OLDNEW
« src/plugin/PluginSettings.cpp ('K') | « src/plugin/PluginSettings.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld