Skip to content

Commit

Permalink
Run clang format (#988)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank-Pareek authored Nov 20, 2024
1 parent e62cdec commit 9ffffaa
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 57 deletions.
4 changes: 2 additions & 2 deletions include/faker-cxx/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace faker::helper
{

template <typename T>
concept input_range_with_faster_size_compute_than_linear_rng = std::ranges::input_range<T> &&
(std::ranges::sized_range<T> || std::ranges::forward_range<T>);
concept input_range_with_faster_size_compute_than_linear_rng =
std::ranges::input_range<T> && (std::ranges::sized_range<T> || std::ranges::forward_range<T>);

template <input_range_with_faster_size_compute_than_linear_rng Range>
decltype(auto) randomElement(Range&& range)
Expand Down
3 changes: 1 addition & 2 deletions include/faker-cxx/location.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ FAKER_CXX_EXPORT std::string_view country();
* @code
* faker::location::continent("Poland") // Europe
* faker::location::continent() // Africa
*
*
* @endcode
*/
FAKER_CXX_EXPORT std::string_view continent(std::string_view country = "");


/**
* @brief Returns a random country code.
*
Expand Down
4 changes: 2 additions & 2 deletions include/faker-cxx/random_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace faker
{
template <typename T>
requires std::uniform_random_bit_generator<T>
requires std::uniform_random_bit_generator<T>

class RandomGenerator
{
Expand All @@ -21,7 +21,7 @@ class RandomGenerator
RandomGenerator& operator=(RandomGenerator&&) = default;

template <typename Dist>
requires std::is_invocable_r_v<int, Dist&, T&>
requires std::is_invocable_r_v<int, Dist&, T&>

int operator()(Dist&& dist)
{
Expand Down
13 changes: 5 additions & 8 deletions src/modules/location.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include "faker-cxx/location.h"


#include <stdexcept>
#include <string>
#include <string_view>
#include <unordered_map>
#include <unordered_set>
#include <stdexcept>
#include "faker-cxx/types/locale.h"

#include "common/algo_helper.h"
#include "common/format_helper.h"
#include "faker-cxx/helper.h"
#include "faker-cxx/number.h"
#include "faker-cxx/person.h"
#include "faker-cxx/types/locale.h"
#include "faker-cxx/types/precision.h"
#include "location_data.h"

Expand Down Expand Up @@ -92,8 +92,8 @@ CountryAddressesInfo getAddresses(const Locale& locale)

std::string_view continent(std::string_view country)
{
static const std::vector<std::string_view> continents = {
"Africa", "Antarctica", "Asia", "Europe", "North America", "Australia", "South America"};
static const std::vector<std::string_view> continents = {"Africa", "Antarctica", "Asia", "Europe",
"North America", "Australia", "South America"};

if (country.empty())
{
Expand All @@ -109,9 +109,6 @@ std::string_view continent(std::string_view country)
return "Unknown";
}




std::string_view country()
{
return helper::randomElement(allCountries);
Expand Down
49 changes: 10 additions & 39 deletions src/modules/location_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,11 @@ struct CountryAddressesInfo
std::span<const std::string_view> states;
};

const auto allContinents = std::to_array<std::string_view>({
"Africa",
"Antarctica",
"Asia",
"Europe",
"North America",
"Australia",
"South America"
});
const auto allContinents = std::to_array<std::string_view>(
{"Africa", "Antarctica", "Asia", "Europe", "North America", "Australia", "South America"});

const std::unordered_map<std::string_view, std::string_view> countryToContinent = {
{"Afghanistan", "Asia"},
{"Afghanistan", "Asia"},
{"Aland Islands", "Europe"},
{"Albania", "Europe"},
{"Algeria", "Africa"},
Expand Down Expand Up @@ -211,7 +204,7 @@ const std::unordered_map<std::string_view, std::string_view> countryToContinent
{"Portugal", "Europe"},
{"Puerto Rico", "North America"},
{"Qatar", "Asia"},
{"Republic of Korea", "Asia"},
{"Republic of Korea", "Asia"},
{"Reunion", "Africa"},
{"Romania", "Europe"},
{"Russian Federation", "Europe/Asia"},
Expand Down Expand Up @@ -279,8 +272,7 @@ const std::unordered_map<std::string_view, std::string_view> countryToContinent
{"Western Sahara", "Africa"},
{"Yemen", "Asia"},
{"Zambia", "Africa"},
{"Zimbabwe", "Africa"}
};
{"Zimbabwe", "Africa"}};

const auto allCountries = std::to_array<std::string_view>({
// clang-format off
Expand Down Expand Up @@ -7659,41 +7651,20 @@ const auto israelStreetNames = std::to_array<std::string_view>({
"תשבי",
});

const auto israelStreetPrefixes = std::to_array<std::string_view>({
"רחוב",
"שדרות",
"משעול",
"דרך",
"סמטת"
});
const auto israelStreetPrefixes = std::to_array<std::string_view>({"רחוב", "שדרות", "משעול", "דרך", "סמטת"});

const std::string_view israelZipCodeFormat{"#######"};

const auto israelAddressFormats =
std::to_array<std::string_view>({
const auto israelAddressFormats = std::to_array<std::string_view>({
"{street} {buildingNumber}",
"{street} {buildingNumber} {secondaryAddress}",
});

const auto israelSecondaryAddressFormats = std::to_array<std::string_view>({
"דירה #",
"דירה ##",
"חדר ##",
"חדר #"
});
const auto israelSecondaryAddressFormats = std::to_array<std::string_view>({"דירה #", "דירה ##", "חדר ##", "חדר #"});

const auto israelBuildingNumberFormats = std::to_array<std::string_view>({
"###",
"##",
"#",
"##ב",
"##א",
"#א",
"#ב"
});
const auto israelBuildingNumberFormats = std::to_array<std::string_view>({"###", "##", "#", "##ב", "##א", "#א", "#ב"});

const auto israelStreetFormats =
std::to_array<std::string_view>({
const auto israelStreetFormats = std::to_array<std::string_view>({
"{streetPrefix} {streetName}",
});

Expand Down
5 changes: 2 additions & 3 deletions src/modules/person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,8 @@ std::string fullName(Locale locale, std::optional<Sex> sex)
weightedElements.reserve(peopleNames.nameFormats.size());

std::transform(peopleNames.nameFormats.begin(), peopleNames.nameFormats.end(), std::back_inserter(weightedElements),
[](const NameFormat& nameFormat) {
return helper::WeightedElement<std::string_view>{nameFormat.weight, nameFormat.format};
});
[](const NameFormat& nameFormat)
{ return helper::WeightedElement<std::string_view>{nameFormat.weight, nameFormat.format}; });

const auto nameFormat = static_cast<std::string>(helper::weightedRandomElement<std::string_view>(weightedElements));

Expand Down
1 change: 0 additions & 1 deletion src/modules/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,5 +358,4 @@ std::string nanoId(int minLength, int maxLength)
return id;
}


}

0 comments on commit 9ffffaa

Please sign in to comment.