From 423d90201edea704070b27d543069a4998e6ea66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blar?= Date: Mon, 4 Dec 2023 23:36:19 +0100 Subject: [PATCH] fix documentation comments (#377) --- include/faker-cxx/Computer.h | 37 ++++++++--- include/faker-cxx/Helper.h | 120 +++++++++++++++++------------------ src/common/BioHelper.cpp | 1 - 3 files changed, 86 insertions(+), 72 deletions(-) diff --git a/include/faker-cxx/Computer.h b/include/faker-cxx/Computer.h index 343681ce5..d29ea885a 100644 --- a/include/faker-cxx/Computer.h +++ b/include/faker-cxx/Computer.h @@ -7,87 +7,104 @@ namespace faker class Computer { public: - /* + /** * @brief Returns a random computer type. * * @returns computer type * * @code * Computer::type() // Laptop + * @endcode */ static std::string type(); - /* + + /** * @brief Returns a random computer manufacture name. * * @returns manufacture name * * @code * Computer::manufacture() // HP + * @endcode */ static std::string manufacture(); - /* + + /** * @brief Returns a random computer model. * * @returns computer model * * @code * Computer::model() // MacBook Air + * @endcode */ static std::string model(); - /* + + /** * @brief Returns a random CPU manufacture name. * * @returns CPU manufacture name * * @code * Computer::cpuManufacture() // Intel + * @endcode */ static std::string cpuManufacture(); - /* + + /** * @brief Returns a random CPU type. * * @returns CPU type * * @code * Computer::cpuType() // x86 + * @endcode */ static std::string cpuType(); - /* + + /** * @brief Returns a random CPU model. * * @returns computer CPU model * * @code * Computer::cpuModel() // Core i9-11900k + * @endcode */ static std::string cpuModel(); - /* + + /** * @brief Returns a random GPU manufacture name. * * @returns GPU manufacture name * * @code * Computer::gpuManufacture() // NVIDIA + * @endcode */ static std::string gpuManufacture(); - /* + + /** * @brief Returns a random GPU type. * * @returns GPU type * * @code * Computer::gpuType() // Integrated + * @endcode */ static std::string gpuType(); - /* + + /** * @brief Returns a random GPU model. * * @returns computer GPU model * * @code * Computer::gpuModel() // NVIDIA GeForce RTX 3080 + * @endcode */ static std::string gpuModel(); }; -} \ No newline at end of file +} diff --git a/include/faker-cxx/Helper.h b/include/faker-cxx/Helper.h index 4e761ac32..f986b3bcb 100644 --- a/include/faker-cxx/Helper.h +++ b/include/faker-cxx/Helper.h @@ -171,7 +171,7 @@ class Helper return data; } - /* + /** * @brief Returns shuffled std::string * * @param data String to be shuffled @@ -184,66 +184,6 @@ class Helper */ static std::string shuffleString(std::string data); - // TODO: remove methods below from helper API, move to src/common - - /** - * @brief Returns the given string parsed symbol by symbol and replaced the placeholders with digits ("0" - "9"). - * "!" will be replaced by digits >=2 ("2" - "9"). - * - * @param str The template to parse string. - * @param symbol The symbol to replace with digits. Defaults to '#'. - * - * @return The string replaced symbols with digits. - * - * @code - * Helper::replaceSymbolWithNumber() // "" - * Helper::replaceSymbolWithNumber("#####") // "04812" - * Helper::replaceSymbolWithNumber("!####") // "27378" - * Helper::replaceSymbolWithNumber("Your pin is: !####") // "29841" - * @endcode - */ - static std::string replaceSymbolWithNumber(std::string str, const char& symbol = '#'); - - /** - * @brief Returns credit card schema with replaced symbols and patterns in a credit card including Luhn checksum - * This method supports both range patterns `[4-9]` as well as the patterns used by `replaceSymbolWithNumber()`. - * `L` will be replaced with the appropriate Luhn checksum. - * - * @param inputString TThe credit card format pattern. Defaults to "6453-####-####-####-###L". - * @param symbol The symbol to replace with a digit. Defaults to '#'. - * - * @return The string replaced symbols with digits. - * - * @code - * Helper::replaceCreditCardSymbols() // "6453-4876-8626-8995-3771" - * Helper::replaceCreditCardSymbols("1234-[4-9]-##!!-L") // "1234-9-5298-2" - * @endcode - */ - static std::string replaceCreditCardSymbols(const std::string& inputString = "6453-####-####-####-###L", - char symbol = '#'); - - /** - * @brief Returns the replaced regex-like expression in the string with matching values. - * - * Supported patterns: - * - `.{times}` => Repeat the character exactly `times` times. - * - `.{min,max}` => Repeat the character `min` to `max` times. - * - `[min-max]` => Generate a number between min and max (inclusive). - * - * @param input The template string to to parse. - * - * @return The replaced regex-like expression in the string with matching values. - * - * @code - * Helper::regexpStyleStringParse() // "" - * Helper::regexpStyleStringParse("#{5}") // "#####" - * Helper::regexpStyleStringParse("#{2,9}") // "#######" - * Helper::regexpStyleStringParse("[500-15000]") // "8375" - * Helper::regexpStyleStringParse("#{3}test[1-5]") // "###test3" - * @endcode - */ - static std::string regexpStyleStringParse(const std::string& input); - /** * @brief Returns a random key from given object. * @@ -307,6 +247,64 @@ class Helper return TResult(); } + /** + * @brief Returns the given string parsed symbol by symbol and replaced the placeholders with digits ("0" - "9"). + * "!" will be replaced by digits >=2 ("2" - "9"). + * + * @param str The template to parse string. + * @param symbol The symbol to replace with digits. Defaults to '#'. + * + * @return The string replaced symbols with digits. + * + * @code + * Helper::replaceSymbolWithNumber() // "" + * Helper::replaceSymbolWithNumber("#####") // "04812" + * Helper::replaceSymbolWithNumber("!####") // "27378" + * Helper::replaceSymbolWithNumber("Your pin is: !####") // "29841" + * @endcode + */ + static std::string replaceSymbolWithNumber(std::string str, const char& symbol = '#'); + + /** + * @brief Returns credit card schema with replaced symbols and patterns in a credit card including Luhn checksum + * This method supports both range patterns `[4-9]` as well as the patterns used by `replaceSymbolWithNumber()`. + * `L` will be replaced with the appropriate Luhn checksum. + * + * @param inputString TThe credit card format pattern. Defaults to "6453-####-####-####-###L". + * @param symbol The symbol to replace with a digit. Defaults to '#'. + * + * @return The string replaced symbols with digits. + * + * @code + * Helper::replaceCreditCardSymbols() // "6453-4876-8626-8995-3771" + * Helper::replaceCreditCardSymbols("1234-[4-9]-##!!-L") // "1234-9-5298-2" + * @endcode + */ + static std::string replaceCreditCardSymbols(const std::string& inputString = "6453-####-####-####-###L", + char symbol = '#'); + + /** + * @brief Returns the replaced regex-like expression in the string with matching values. + * + * Supported patterns: + * - `.{times}` => Repeat the character exactly `times` times. + * - `.{min,max}` => Repeat the character `min` to `max` times. + * - `[min-max]` => Generate a number between min and max (inclusive). + * + * @param input The template string to to parse. + * + * @return The replaced regex-like expression in the string with matching values. + * + * @code + * Helper::regexpStyleStringParse() // "" + * Helper::regexpStyleStringParse("#{5}") // "#####" + * Helper::regexpStyleStringParse("#{2,9}") // "#######" + * Helper::regexpStyleStringParse("[500-15000]") // "8375" + * Helper::regexpStyleStringParse("#{3}test[1-5]") // "###test3" + * @endcode + */ + static std::string regexpStyleStringParse(const std::string& input); + private: static std::random_device randomDevice; static std::mt19937 pseudoRandomGenerator; diff --git a/src/common/BioHelper.cpp b/src/common/BioHelper.cpp index e1a734bb0..15ec5fc22 100644 --- a/src/common/BioHelper.cpp +++ b/src/common/BioHelper.cpp @@ -8,7 +8,6 @@ namespace faker { bool BioHelper::checkTokenFormat(const std::string& bio) { - const std::regex firstRegex{R"(^[a-zA-Z0-9_]+$)"}; const std::regex secondRegex{R"(^(\w+\s?\w+), (\w+\s?\w+)$)"}; const std::regex thirdRegex{R"(^(\w+\s?\w+), (\w+\s?\w+), (\w+\s?\w+)$)"};