Skip to content

Commit

Permalink
fix documentation comments (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal authored Dec 4, 2023
1 parent 582ee87 commit 423d902
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 72 deletions.
37 changes: 27 additions & 10 deletions include/faker-cxx/Computer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

}
}
120 changes: 59 additions & 61 deletions include/faker-cxx/Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class Helper
return data;
}

/*
/**
* @brief Returns shuffled std::string
*
* @param data String to be shuffled
Expand All @@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/common/BioHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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+)$)"};
Expand Down

0 comments on commit 423d902

Please sign in to comment.