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

Delta Between Two Patch Sets: src/shared/Communication.h

Issue 11013110: Cleanup (Closed)
Left Patch Set: SetPref/GetPref type safety. Comments addressed. Created July 22, 2013, 12:42 a.m.
Right Patch Set: More beautification and addressing comments Created July 29, 2013, 12:13 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/plugin/Resource.h ('k') | src/shared/Communication.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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) {}
39 InputBuffer(const InputBuffer& copy) { hasType = copy.hasType; buffer = std: :istringstream(copy.buffer.str()); currentType = copy.currentType; } 40 InputBuffer(const InputBuffer& copy)
41 {
42 hasType = copy.hasType;
43 buffer = std::istringstream(copy.buffer.str());
44 currentType = copy.currentType;
45 }
40 InputBuffer& operator>>(ProcType& value) { return Read(value, TYPE_PROC); } 46 InputBuffer& operator>>(ProcType& value) { return Read(value, TYPE_PROC); }
41 InputBuffer& operator>>(std::string& value) { return ReadString(value, TYPE_ STRING); } 47 InputBuffer& operator>>(std::string& value) { return ReadString(value, TYPE_ STRING); }
42 InputBuffer& operator>>(std::wstring& value) { return ReadString(value, TYPE _WSTRING); } 48 InputBuffer& operator>>(std::wstring& value) { return ReadString(value, TYPE _WSTRING); }
43 InputBuffer& operator>>(int64_t& value) { return Read(value, TYPE_INT64); } 49 InputBuffer& operator>>(int64_t& value) { return Read(value, TYPE_INT64); }
44 InputBuffer& operator>>(int32_t& value) { return Read(value, TYPE_INT32); } 50 InputBuffer& operator>>(int32_t& value) { return Read(value, TYPE_INT32); }
45 InputBuffer& operator>>(bool& value) { return Read(value, TYPE_BOOL); } 51 InputBuffer& operator>>(bool& value) { return Read(value, TYPE_BOOL); }
52 InputBuffer& operator=(const InputBuffer& copy)
53 {
54 hasType = copy.hasType;
55 buffer = std::istringstream(copy.buffer.str());
56 currentType = copy.currentType;
57 return *this;
58 }
46 ValueType GetType(); 59 ValueType GetType();
47 bool IsEmpty() { return buffer.eof(); }
Wladimir Palant 2013/07/22 06:43:11 This is just wrong :-( eof() doesn't mean that the
Oleksandr 2013/07/22 09:53:31 I guess the name was just wrong. Should've been Is
48 private: 60 private:
49 std::istringstream buffer; 61 std::istringstream buffer;
50 ValueType currentType; 62 ValueType currentType;
51 bool hasType; 63 bool hasType;
52 64
53 void CheckType(ValueType expectedType); 65 void CheckType(ValueType expectedType);
54 66
55 template<class T> 67 template<class T>
56 InputBuffer& ReadString(T& value, ValueType expectedType) 68 InputBuffer& ReadString(T& value, ValueType expectedType)
57 { 69 {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 177
166 InputBuffer ReadMessage(); 178 InputBuffer ReadMessage();
167 void WriteMessage(OutputBuffer& message); 179 void WriteMessage(OutputBuffer& message);
168 180
169 protected: 181 protected:
170 HANDLE pipe; 182 HANDLE pipe;
171 }; 183 };
172 } 184 }
173 185
174 #endif 186 #endif
LEFTRIGHT

Powered by Google App Engine
This is Rietveld