From b2901a51b6f033be07a22809bb8914d4ea7746a2 Mon Sep 17 00:00:00 2001 From: Serge Lamikhov-Center Date: Wed, 30 Nov 2022 08:25:01 +0200 Subject: [PATCH] Add missed implementation function for insert_data() --- .vscode/settings.json | 3 ++- elfio/elfio_section.hpp | 36 +++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 8992812..ef7c588 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -99,5 +99,6 @@ ] }, "gtest-adapter.debugConfig": "Run ELFIO Tests", - "gtest-adapter.supportLocation": true + "gtest-adapter.supportLocation": true, + "sonarlint.pathToCompileCommands": "${workspaceFolder}/build/compile_commands.json" } \ No newline at end of file diff --git a/elfio/elfio_section.hpp b/elfio/elfio_section.hpp index dc6e352..ed9281e 100644 --- a/elfio/elfio_section.hpp +++ b/elfio/elfio_section.hpp @@ -50,19 +50,16 @@ class section ELFIO_GET_SET_ACCESS_DECL( Elf_Word, name_string_offset ); ELFIO_GET_ACCESS_DECL( Elf64_Off, offset ); - virtual const char* get_data() const noexcept = 0; - virtual void set_data( const char* raw_data, Elf_Word size ) noexcept = 0; - virtual void set_data( const std::string& data ) noexcept = 0; - virtual void append_data( const char* raw_data, - Elf_Word size ) noexcept = 0; - virtual void append_data( const std::string& data ) noexcept = 0; - virtual void insert_data( Elf_Word pos, - const char* raw_data, - Elf_Word size ) noexcept = 0; - virtual void insert_data( Elf_Word pos, - const std::string& data ) noexcept = 0; - virtual size_t get_stream_size() const noexcept = 0; - virtual void set_stream_size( size_t value ) noexcept = 0; + virtual const char* get_data() const = 0; + virtual void set_data( const char* raw_data, Elf_Word size ) = 0; + virtual void set_data( const std::string& data ) = 0; + virtual void append_data( const char* raw_data, Elf_Word size ) = 0; + virtual void append_data( const std::string& data ) = 0; + virtual void + insert_data( Elf_Xword pos, const char* raw_data, Elf_Word size ) = 0; + virtual void insert_data( Elf_Xword pos, const std::string& data ) = 0; + virtual size_t get_stream_size() const = 0; + virtual void set_stream_size( size_t value ) = 0; protected: ELFIO_SET_ACCESS_DECL( Elf64_Off, offset ); @@ -171,9 +168,8 @@ template class section_impl : public section } //------------------------------------------------------------------------------ - void insert_data( Elf_Word pos, - const char* raw_data, - Elf_Word size ) noexcept override + void + insert_data( Elf_Xword pos, const char* raw_data, Elf_Word size ) override { if ( get_type() != SHT_NOBITS ) { if ( get_size() + size < data_size ) { @@ -207,7 +203,13 @@ template class section_impl : public section } } - size_t get_stream_size() const noexcept override { return stream_size; } + //------------------------------------------------------------------------------ + void insert_data( Elf_Xword pos, const std::string& str_data ) override + { + return insert_data( pos, str_data.c_str(), (Elf_Word)str_data.size() ); + } + + size_t get_stream_size() const override { return stream_size; } //------------------------------------------------------------------------------ void set_stream_size( size_t value ) override { stream_size = value; }