diff --git a/ApplicationCode/Application/Tools/CMakeLists_files.cmake b/ApplicationCode/Application/Tools/CMakeLists_files.cmake index a1f686a108..5d1de192dc 100644 --- a/ApplicationCode/Application/Tools/CMakeLists_files.cmake +++ b/ApplicationCode/Application/Tools/CMakeLists_files.cmake @@ -19,6 +19,7 @@ ${CEE_CURRENT_LIST_DIR}RiaImportEclipseCaseTools.h ${CEE_CURRENT_LIST_DIR}RiaQDateTimeTools.h ${CEE_CURRENT_LIST_DIR}RiaSummaryTools.h ${CEE_CURRENT_LIST_DIR}RiaWellNameComparer.h +${CEE_CURRENT_LIST_DIR}RiaStdStringTools.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -35,6 +36,7 @@ ${CEE_CURRENT_LIST_DIR}RiaImportEclipseCaseTools.cpp ${CEE_CURRENT_LIST_DIR}RiaQDateTimeTools.cpp ${CEE_CURRENT_LIST_DIR}RiaSummaryTools.cpp ${CEE_CURRENT_LIST_DIR}RiaWellNameComparer.cpp +${CEE_CURRENT_LIST_DIR}RiaStdStringTools.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/Application/Tools/RiaStdStringTools.cpp b/ApplicationCode/Application/Tools/RiaStdStringTools.cpp new file mode 100644 index 0000000000..ad15cbd75e --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaStdStringTools.cpp @@ -0,0 +1,30 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaStdStringTools.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::string RiaStdStringTools::trimString(const std::string& s) +{ + auto sCopy = s.substr(0, s.find_last_not_of(' ') + 1); + sCopy = sCopy.substr(sCopy.find_first_not_of(' ')); + + return sCopy; +} diff --git a/ApplicationCode/Application/Tools/RiaStdStringTools.h b/ApplicationCode/Application/Tools/RiaStdStringTools.h new file mode 100644 index 0000000000..12c1daa1ee --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaStdStringTools.h @@ -0,0 +1,31 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +//================================================================================================== +// +//================================================================================================== +class RiaStdStringTools +{ +public: + static std::string trimString(const std::string& s); +}; +