diff options
Diffstat (limited to 'import/hwpf')
-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 |