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

Unified Diff: src/shared/Communication.h

Issue 11013110: Cleanup (Closed)
Patch Set: More beautification and addressing comments Created July 29, 2013, 12:13 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/plugin/Resource.h ('k') | src/shared/Communication.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/shared/Communication.h
===================================================================
--- a/src/shared/Communication.h
+++ b/src/shared/Communication.h
@@ -24,6 +24,8 @@
PROC_IS_WHITELISTED_URL,
PROC_ADD_FILTER,
PROC_REMOVE_FILTER,
+ PROC_SET_PREF,
+ PROC_GET_PREF
};
enum ValueType : uint32_t {
TYPE_PROC, TYPE_STRING, TYPE_WSTRING, TYPE_INT64, TYPE_INT32, TYPE_BOOL
@@ -33,13 +35,28 @@
class InputBuffer
{
public:
+ InputBuffer() : buffer(), hasType(false) {}
InputBuffer(const std::string& data) : buffer(data), hasType(false) {}
+ InputBuffer(const InputBuffer& copy)
+ {
+ hasType = copy.hasType;
+ buffer = std::istringstream(copy.buffer.str());
+ currentType = copy.currentType;
+ }
InputBuffer& operator>>(ProcType& value) { return Read(value, TYPE_PROC); }
InputBuffer& operator>>(std::string& value) { return ReadString(value, TYPE_STRING); }
InputBuffer& operator>>(std::wstring& value) { return ReadString(value, TYPE_WSTRING); }
InputBuffer& operator>>(int64_t& value) { return Read(value, TYPE_INT64); }
InputBuffer& operator>>(int32_t& value) { return Read(value, TYPE_INT32); }
InputBuffer& operator>>(bool& value) { return Read(value, TYPE_BOOL); }
+ InputBuffer& operator=(const InputBuffer& copy)
+ {
+ hasType = copy.hasType;
+ buffer = std::istringstream(copy.buffer.str());
+ currentType = copy.currentType;
+ return *this;
+ }
+ ValueType GetType();
private:
std::istringstream buffer;
ValueType currentType;
@@ -78,6 +95,7 @@
buffer.read(reinterpret_cast<char*>(&value), sizeof(T));
if (buffer.fail())
throw new std::runtime_error("Unexpected end of input buffer");
+ hasType = false;
}
};
« no previous file with comments | « src/plugin/Resource.h ('k') | src/shared/Communication.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld