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

Unified Diff: src/shared/Communication.h

Issue 10786016: Moved all pipe functionality into a self-containing Communication::Pipe class (Closed)
Patch Set: Created June 3, 2013, 2:07 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 | « no previous file | 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
@@ -7,17 +7,16 @@
#include <stdint.h>
#include <string>
#include <vector>
#include <Windows.h>
namespace Communication
{
extern const std::wstring pipeName;
- const int bufferSize = 1024;
enum ProcType : uint32_t {
PROC_MATCHES,
PROC_GET_ELEMHIDE_SELECTORS,
PROC_AVAILABLE_SUBSCRIPTIONS,
PROC_LISTED_SUBSCRIPTIONS,
PROC_SET_SUBSCRIPTION,
PROC_UPDATE_ALL_SUBSCRIPTIONS,
@@ -39,30 +38,17 @@ namespace Communication
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); }
private:
std::istringstream buffer;
ValueType currentType;
bool hasType;
- void CheckType(ValueType expectedType)
- {
- if (!hasType)
- ReadBinary(currentType);
-
- if (currentType != expectedType)
- {
- // Make sure we don't attempt to read the type again
- hasType = true;
- throw new std::runtime_error("Unexpected type found in input buffer");
- }
- else
- hasType = false;
- }
+ void CheckType(ValueType expectedType);
template<class T>
InputBuffer& ReadString(T& value, ValueType expectedType)
{
CheckType(expectedType);
SizeType length;
ReadBinary(length);
« no previous file with comments | « no previous file | src/shared/Communication.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld