summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2019-10-08 14:01:06 -0500
committerMatt Spinler <spinler@us.ibm.com>2019-10-22 14:09:56 +0000
commitced1a2185f3d38ab153cb4050dd074dcdc6a478d (patch)
tree2be07184f605723fc84bd62176f733a0976bd92a
parent4b59f7ad8462bea683ac93048395e5e9f41d40e5 (diff)
downloadphosphor-logging-ced1a2185f3d38ab153cb4050dd074dcdc6a478d.tar.gz
phosphor-logging-ced1a2185f3d38ab153cb4050dd074dcdc6a478d.zip
PEL: Add Stream ops for std::vector<char>
Add << and >> operators to the Stream class for use with a std::vector<char>. Signed-off-by: Matt Spinler <spinler@us.ibm.com> Change-Id: I22a08bb6518f9aed2385bcdce446a67ea9ea386d
-rw-r--r--extensions/openpower-pels/stream.hpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/extensions/openpower-pels/stream.hpp b/extensions/openpower-pels/stream.hpp
index 5c813b2..4922bc7 100644
--- a/extensions/openpower-pels/stream.hpp
+++ b/extensions/openpower-pels/stream.hpp
@@ -160,6 +160,23 @@ class Stream
}
/**
+ * @brief Extraction operator for a std::vector<char>
+ *
+ * The vector's size is the amount extracted.
+ *
+ * @param[out] value - filled in with the value
+ * @return Stream&
+ */
+ Stream& operator>>(std::vector<char>& value)
+ {
+ if (!value.empty())
+ {
+ read(value.data(), value.size());
+ }
+ return *this;
+ }
+
+ /**
* @brief Insert operator for a uint8_t
*
* @param[in] value - the value to write to the stream
@@ -240,6 +257,23 @@ class Stream
}
/**
+ * @brief Insert operator for a std::vector<char>
+ *
+ * The full vector is written to the stream.
+ *
+ * @param[in] value - the value to write to the stream
+ * @return Stream&
+ */
+ Stream& operator<<(const std::vector<char>& value)
+ {
+ if (!value.empty())
+ {
+ write(value.data(), value.size());
+ }
+ return *this;
+ }
+
+ /**
* @brief Sets the offset of the stream
*
* @param[in] newOffset - the new offset
OpenPOWER on IntegriCloud