diff --git a/include/faker-cxx/Internet.h b/include/faker-cxx/Internet.h index c05bc0fa0..c9edb119b 100644 --- a/include/faker-cxx/Internet.h +++ b/include/faker-cxx/Internet.h @@ -4,8 +4,6 @@ #include #include "types/EmojiType.h" -#include "types/Ipv4Address.h" -#include "types/Ipv4Class.h" namespace faker { @@ -24,6 +22,13 @@ enum class WebProtocol Https }; +enum class IPv4Class +{ + A, + B, + C +}; + class Internet { public: @@ -210,7 +215,8 @@ class Internet * Internet::ipv4({255.255.128.0}, {129.168.255.0}) // "192.168.128.10" * @endcode */ - static std::string ipv4(const IPv4Address& baseIpv4Address, const IPv4Address& generationMask); + static std::string ipv4(const std::array& baseIpv4Address, + const std::array& generationMask); /** * @brief Returns a string containing randomized ipv6 address. diff --git a/include/faker-cxx/System.h b/include/faker-cxx/System.h index d96b2bc67..13d2b5047 100644 --- a/include/faker-cxx/System.h +++ b/include/faker-cxx/System.h @@ -1,13 +1,34 @@ #pragma once -#include "types/CronOptions.h" -#include "types/FileOptions.h" +#include + #include "types/FileType.h" -#include "types/MimeTypes.h" -#include "types/NetworkInterfaceOptions.h" namespace faker { +struct FileOptions +{ + int extensionCount = 1; + struct + { + int min = 1; + int max = 1; + } extensionRange; +}; + +struct CronOptions +{ + bool includeYear = false; + bool includeNonStandard = false; +}; + +// TODO: change to enums +struct NetworkInterfaceOptions +{ + std::optional interfaceType; + std::optional interfaceSchema; +}; + class System { public: diff --git a/include/faker-cxx/types/CronOptions.h b/include/faker-cxx/types/CronOptions.h deleted file mode 100644 index a18d442f8..000000000 --- a/include/faker-cxx/types/CronOptions.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include -#include - -namespace faker -{ -struct CronOptions -{ - bool includeYear = false; - bool includeNonStandard = false; -}; -} diff --git a/include/faker-cxx/types/FileOptions.h b/include/faker-cxx/types/FileOptions.h deleted file mode 100644 index 71a0be308..000000000 --- a/include/faker-cxx/types/FileOptions.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace faker -{ -struct FileOptions -{ - int extensionCount = 1; - struct - { - int min = 1; - int max = 1; - } extensionRange; -}; -} diff --git a/include/faker-cxx/types/Ipv4Address.h b/include/faker-cxx/types/Ipv4Address.h deleted file mode 100644 index 4273963ff..000000000 --- a/include/faker-cxx/types/Ipv4Address.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include - -namespace faker -{ -using IPv4Address = std::array; -} diff --git a/include/faker-cxx/types/Ipv4Class.h b/include/faker-cxx/types/Ipv4Class.h deleted file mode 100644 index 9303c7f58..000000000 --- a/include/faker-cxx/types/Ipv4Class.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -namespace faker -{ -enum class IPv4Class -{ - A, - B, - C -}; -} diff --git a/include/faker-cxx/types/MimeTypes.h b/include/faker-cxx/types/MimeTypes.h deleted file mode 100644 index d77d339fd..000000000 --- a/include/faker-cxx/types/MimeTypes.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace faker -{ - -} diff --git a/include/faker-cxx/types/NetworkInterfaceOptions.h b/include/faker-cxx/types/NetworkInterfaceOptions.h deleted file mode 100644 index e94f17a4b..000000000 --- a/include/faker-cxx/types/NetworkInterfaceOptions.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -namespace faker -{ -struct NetworkInterfaceOptions -{ - std::optional interfaceType; - std::optional interfaceSchema; -}; -} diff --git a/src/modules/internet/Internet.cpp b/src/modules/internet/Internet.cpp index d74179003..ede89d0b5 100644 --- a/src/modules/internet/Internet.cpp +++ b/src/modules/internet/Internet.cpp @@ -179,7 +179,7 @@ std::string Internet::httpMediaType() std::string Internet::ipv4(IPv4Class ipv4class) { - IPv4Address sectors; + std::array sectors{}; sectors[3] = Number::integer(ipv4SectorUpperBound); sectors[2] = Number::integer(ipv4SectorUpperBound); @@ -208,9 +208,10 @@ std::string Internet::ipv4(IPv4Class ipv4class) return fmt::format("{}.{}.{}.{}", sectors[0], sectors[1], sectors[2], sectors[3]); } -std::string Internet::ipv4(const IPv4Address& baseIpv4Address, const IPv4Address& generationMask) +std::string Internet::ipv4(const std::array& baseIpv4Address, + const std::array& generationMask) { - IPv4Address sectors; + std::array sectors{}; for (std::size_t i = 0; i < ipv4AddressSectors; i++) { diff --git a/src/modules/internet/InternetTest.cpp b/src/modules/internet/InternetTest.cpp index f29acee2f..311915b72 100644 --- a/src/modules/internet/InternetTest.cpp +++ b/src/modules/internet/InternetTest.cpp @@ -42,9 +42,9 @@ constexpr unsigned int classBSecondSectionUpperBound = 31; constexpr unsigned int classCFirstSection = 192u; constexpr unsigned int classCSecondSection = 168u; -IPv4Address deconstructIpv4String(const std::string& ipv4) +std::array deconstructIpv4String(const std::string& ipv4) { - IPv4Address result; + std::array result; std::istringstream ss(ipv4); @@ -604,8 +604,8 @@ TEST_F(InternetTest, shouldGenerateIpv4WithPrivateClassCAddress) TEST_F(InternetTest, shouldGenerateIpv4KeepingTheMaskedPart) { - const IPv4Address sampleAddress = {192, 168, 10, 12}; - const IPv4Address generationMask = {255, 128, 0, 0}; + const std::array sampleAddress = {192, 168, 10, 12}; + const std::array generationMask = {255, 128, 0, 0}; const auto generatedAddress = deconstructIpv4String(Internet::ipv4(sampleAddress, generationMask));