From 36df0e18096f46ab33528ba9a783b47e25eb28f5 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Tue, 19 Nov 2019 00:25:55 +0100 Subject: [PATCH] String library comments updated --- src/string/string.cpp | 6 +++--- src/string/string.h | 26 +++++++++----------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/string/string.cpp b/src/string/string.cpp index b1c73cd..027a3f3 100644 --- a/src/string/string.cpp +++ b/src/string/string.cpp @@ -175,10 +175,10 @@ namespace c0ding { return delim; } - void string::replace(const std::string& target, const std::string& replacement) { + void string::replace(const std::string& value, const std::string& replacement) { std::string::size_type found = 0; - while ((found = data.find(target, found + replacement.length())) != std::string::npos) { - data.replace(found, target.length(), replacement); + while ((found = data.find(value, found + replacement.length())) != std::string::npos) { + data.replace(found, value.length(), replacement); } } diff --git a/src/string/string.h b/src/string/string.h index 944ec75..7def2d0 100644 --- a/src/string/string.h +++ b/src/string/string.h @@ -247,7 +247,7 @@ namespace c0ding { friend std::ostream& operator<<(std::ostream& os, const string& str); /** - * Tries to erase the first line of the given string which contains the sequence. + * Tries to erase the first line of the string which contains {@param sequence}. * * @param sequence The sequence. */ @@ -268,52 +268,44 @@ namespace c0ding { [[nodiscard]] std::string get() const; /** - * Get a part of a given string after a delimiter. + * Get the part of the string after {@param delim} (exclusive). * - * @param string The given string. * @param delim The delimiter. * @return The partial string. */ std::string get_from(std::string delim); /** - * Get a part of a given string before a delimiter. + * Get the part of the string before {@param delim} (exclusive). * - * @param string The given string. * @param delim The delimiter. * @return The partial string. */ std::string get_until(std::string delim); /** - * Replace all targets found in a given string by a replacement. + * Replace all occurrences of {@param value} found in the string by {@param replacement} inplace. * - * @param string The given string. - * @param target The target. + * @param value The target. * @param replacement The replacement. */ - void replace(const std::string& target, const std::string& replacement); + void replace(const std::string& value, const std::string& replacement); /** - * Split a given string at a delimiter. + * Split the string at {@param delim}. * - * @param string The given string. * @param delim The delimiter. * @return The split parts. */ std::vector split(const std::string& delim); /** - * Transform all characters in a given string to lowercase. - * - * @param string The given string. + * Transform all characters in the string to lowercase. */ void to_lower(); /** - * Transform all characters in a given string to uppercase. - * - * @param string The given string. + * Transform all characters in the string to uppercase. */ void to_upper();