diff options
author | Brian Silver <bsilver@us.ibm.com> | 2015-05-11 09:20:43 -0500 |
---|---|---|
committer | Derk Rembold <rembold@de.ibm.com> | 2015-09-03 07:29:10 -0500 |
commit | 07426939bc13c628331b5197e0b485ceab3e3d5a (patch) | |
tree | 8bc607b52c070d79a11737e705e4d0be9e403ece | |
parent | 36873af6aa640044e0c4240984913431d4019d2e (diff) | |
download | talos-sbe-07426939bc13c628331b5197e0b485ceab3e3d5a.tar.gz talos-sbe-07426939bc13c628331b5197e0b485ceab3e3d5a.zip |
Add variable_buffer get<OT>()
Change-Id: Iaf658f2d4a43703400ea016c37244f27524a73c0
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/17679
Tested-by: Jenkins Server
Reviewed-by: Richard J. Knight <rjknight@us.ibm.com>
Reviewed-by: Matt K. Light <mklight@us.ibm.com>
Reviewed-by: Brian Silver <bsilver@us.ibm.com>
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/20148
Reviewed-by: Derk Rembold <rembold@de.ibm.com>
-rw-r--r-- | import/hwpf/fapi2/include/buffer.H | 4 | ||||
-rw-r--r-- | import/hwpf/fapi2/include/variable_buffer.H | 21 |
2 files changed, 21 insertions, 4 deletions
diff --git a/import/hwpf/fapi2/include/buffer.H b/import/hwpf/fapi2/include/buffer.H index 6a3a2bdd..ec55fed4 100644 --- a/import/hwpf/fapi2/include/buffer.H +++ b/import/hwpf/fapi2/include/buffer.H @@ -615,7 +615,7 @@ namespace fapi2 /// @tparam OT the type of the outgoing (target) /// @param[out] o_out OT to copy into - data is placed left aligned /// @param[in] Start bit in source - /// @param[in] Length of bits to insert + /// @param[in] Length of bits to extract /// @param[in] Start bit to insert into (target start) /// @return FAPI2_RC_SUCCESS if ok /// @@ -638,7 +638,7 @@ namespace fapi2 /// /// @brief Copy data from this buffer into an OT and right justify /// @tparam SS Start bit to insert into (source start) - /// @tparam L Length of bits to insert + /// @tparam L Length of bits to extract /// @tparam OT the type of the outgoing (target) /// @param[out] o_out OT to copy into - data is placed right aligned /// @return buffer& Useful for method chaining diff --git a/import/hwpf/fapi2/include/variable_buffer.H b/import/hwpf/fapi2/include/variable_buffer.H index 2af09a83..b1739be9 100644 --- a/import/hwpf/fapi2/include/variable_buffer.H +++ b/import/hwpf/fapi2/include/variable_buffer.H @@ -288,8 +288,6 @@ namespace fapi2 /// @param[in] i_offset Start OT (start word, for example) in buffer /// - defaults to 0 (will by default write the left most element) /// @return FAPI2_RC_SUCCESS on success, FAPI2_RC_OVERFLOW otherwise - /// @note This is is only available for integral types. To set a - /// variable_buffer into a variable_buffer, use insert() /// template< typename OT> inline fapi2::ReturnCodes set(OT i_value, const bits_type i_offset = 0) @@ -318,6 +316,17 @@ namespace fapi2 return FAPI2_RC_SUCCESS; } + /// + /// @brief Get an OT of data from buffer + /// @tparam OT the type of the data to get + /// @param[in] i_offset Start OT (start word, for example) in buffer + /// - defaults to 0 (will by default write the left most element) + /// @return OT + /// @note uint8_t b = get<uint8_t>(N) <- gets the N'th left byte from the buffer + /// + template< typename OT> + inline OT get(const bits_type i_offset = 0); + /// @name Bit/Word Manipulation Functions ///@{ @@ -1177,5 +1186,13 @@ namespace fapi2 return rc; } + template< typename OT> + inline OT variable_buffer::get(const bits_type i_offset) + { + // Get is just an extract. + OT l_tmp; + extract(l_tmp, parameterTraits<OT>::bit_length() * i_offset, parameterTraits<OT>::bit_length()); + return l_tmp; + } } #endif |