Skip to content

Commit

Permalink
refactor animal module data
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal committed May 24, 2024
1 parent 13d3e1a commit 2d6cc62
Show file tree
Hide file tree
Showing 21 changed files with 3,537 additions and 3,637 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(FAKER_SOURCES
src/modules/airline/Airline.cpp
src/modules/airline/AirlineData.cpp
src/modules/animal/Animal.cpp
src/modules/animal/AnimalData.cpp
src/modules/book/Book.cpp
src/modules/color/Color.cpp
src/modules/commerce/Commerce.cpp
Expand Down
32 changes: 16 additions & 16 deletions include/faker-cxx/Animal.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <string>
#include <string_view>

namespace faker
{
Expand All @@ -16,7 +16,7 @@ class Animal
* Animal::bear() // "Polar bear"
* @endcode
*/
static std::string bear();
static std::string_view bear();

/**
* @brief Returns a random species of bird.
Expand All @@ -27,7 +27,7 @@ class Animal
* Animal::bird() // "Black-bellied Whistling-Duck"
* @endcode
*/
static std::string bird();
static std::string_view bird();

/**
* @brief Returns a random species of cat.
Expand All @@ -38,7 +38,7 @@ class Animal
* Animal::cat() // "Chartreux"
* @endcode
*/
static std::string cat();
static std::string_view cat();

/**
* @brief Returns a random species of cetacean.
Expand All @@ -49,7 +49,7 @@ class Animal
* Animal::cetacean() // "Blue Whale"
* @endcode
*/
static std::string cetacean();
static std::string_view cetacean();

/**
* @brief Returns a random species of cow.
Expand All @@ -60,7 +60,7 @@ class Animal
* Animal::cow() // "American Angus"
* @endcode
*/
static std::string cow();
static std::string_view cow();

/**
* @brief Returns a random species of crocodilia.
Expand All @@ -71,7 +71,7 @@ class Animal
* Animal::crocodile() // "Dwarf Crocodile"
* @endcode
*/
static std::string crocodile();
static std::string_view crocodile();

/**
* @brief Returns a random species of dog.
Expand All @@ -82,7 +82,7 @@ class Animal
* Animal::dog() // "Shiba Inu"
* @endcode
*/
static std::string dog();
static std::string_view dog();

/**
* @brief Returns a random species of fish.
Expand All @@ -93,7 +93,7 @@ class Animal
* Animal::fish() // "Silver carp"
* @endcode
*/
static std::string fish();
static std::string_view fish();

/**
* @brief Returns a random species of horse.
Expand All @@ -104,7 +104,7 @@ class Animal
* Animal::horse() // "Fjord Horse"
* @endcode
*/
static std::string horse();
static std::string_view horse();

/**
* @brief Returns a random species of insect.
Expand All @@ -115,7 +115,7 @@ class Animal
* Animal::insect() // "Bee"
* @endcode
*/
static std::string insect();
static std::string_view insect();

/**
* @brief Returns a random species of lion.
Expand All @@ -126,7 +126,7 @@ class Animal
* Animal::lion() // "West African Lion"
* @endcode
*/
static std::string lion();
static std::string_view lion();

/**
* @brief Returns a random species of rabbit.
Expand All @@ -137,7 +137,7 @@ class Animal
* Animal::rabbit() // "Californian"
* @endcode
*/
static std::string rabbit();
static std::string_view rabbit();

/**
* @brief Returns a random species of rodent.
Expand All @@ -148,7 +148,7 @@ class Animal
* Animal::rodent() // "Chinchilla"
* @endcode
*/
static std::string rodent();
static std::string_view rodent();

/**
* @brief Returns a random species of snake.
Expand All @@ -159,7 +159,7 @@ class Animal
* Animal::snake() // "Boa constrictor"
* @endcode
*/
static std::string snake();
static std::string_view snake();

/**
* @brief Returns a random type of animal.
Expand All @@ -170,6 +170,6 @@ class Animal
* Animal::type() // "dog"
* @endcode
*/
static std::string type();
static std::string_view type();
};
}
76 changes: 31 additions & 45 deletions src/modules/animal/Animal.cpp
Original file line number Diff line number Diff line change
@@ -1,96 +1,82 @@
#include "faker-cxx/Animal.h"

#include "data/Bears.h"
#include "data/Birds.h"
#include "data/Cats.h"
#include "data/Cetaceans.h"
#include "data/Cows.h"
#include "data/Crocodiles.h"
#include "data/Dogs.h"
#include "data/Fishes.h"
#include "data/Horses.h"
#include "data/Insects.h"
#include "data/Lions.h"
#include "data/Rabbits.h"
#include "data/Rodents.h"
#include "data/Snakes.h"
#include "data/Types.h"
#include "AnimalData.h"
#include "faker-cxx/Helper.h"

namespace faker
{
std::string Animal::bear()
std::string_view Animal::bear()
{
return Helper::arrayElement<std::string>(bears);
return Helper::arrayElement(bears);
}

std::string Animal::bird()
std::string_view Animal::bird()
{
return Helper::arrayElement<std::string>(birds);
return Helper::arrayElement(birds);
}

std::string Animal::cat()
std::string_view Animal::cat()
{
return Helper::arrayElement<std::string>(cats);
return Helper::arrayElement(cats);
}

std::string Animal::cetacean()
std::string_view Animal::cetacean()
{
return Helper::arrayElement<std::string>(cetaceans);
return Helper::arrayElement(cetaceans);
}

std::string Animal::cow()
std::string_view Animal::cow()
{
return Helper::arrayElement<std::string>(cows);
return Helper::arrayElement(cows);
}

std::string Animal::crocodile()
std::string_view Animal::crocodile()
{
return Helper::arrayElement<std::string>(faker::crocodiles);
return Helper::arrayElement(faker::crocodiles);
}

std::string Animal::dog()
std::string_view Animal::dog()
{
return Helper::arrayElement<std::string>(dogs);
return Helper::arrayElement(dogs);
}

std::string Animal::fish()
std::string_view Animal::fish()
{
return Helper::arrayElement<std::string>(fishes);
return Helper::arrayElement(fishes);
}

std::string Animal::horse()
std::string_view Animal::horse()
{
return Helper::arrayElement<std::string>(horses);
return Helper::arrayElement(horses);
}

std::string Animal::insect()
std::string_view Animal::insect()
{
return Helper::arrayElement<std::string>(insects);
return Helper::arrayElement(insects);
}

std::string Animal::lion()
std::string_view Animal::lion()
{
return Helper::arrayElement<std::string>(lions);
return Helper::arrayElement(lions);
}

std::string Animal::rabbit()
std::string_view Animal::rabbit()
{
return Helper::arrayElement<std::string>(rabbits);
return Helper::arrayElement(rabbits);
}

std::string Animal::rodent()
std::string_view Animal::rodent()
{
return Helper::arrayElement<std::string>(rodents);
return Helper::arrayElement(rodents);
}

std::string Animal::snake()
std::string_view Animal::snake()
{
return Helper::arrayElement<std::string>(snakes);
return Helper::arrayElement(snakes);
}

std::string Animal::type()
std::string_view Animal::type()
{
return Helper::arrayElement<std::string>(types);
return Helper::arrayElement(types);
}
}
Loading

0 comments on commit 2d6cc62

Please sign in to comment.