Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor food module data #607

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ set(FAKER_SOURCES
src/modules/finance/Finance.cpp
src/modules/finance/FinanceData.cpp
src/modules/food/Food.cpp
src/modules/food/FoodData.cpp
src/modules/git/Git.cpp
src/modules/hacker/Hacker.cpp
src/modules/helper/Helper.cpp
Expand Down
30 changes: 15 additions & 15 deletions include/faker-cxx/Food.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 Food
* Food::alcoholicBeverage() // "champain"
* @endcode
*/
static std::string alcoholicBeverage();
static std::string_view alcoholicBeverage();

/**
* @brief Returns a random grain measurement.
Expand All @@ -27,7 +27,7 @@ class Food
* Food::grain() // "1 Lt"
* @endcode
*/
static std::string grain();
static std::string_view grain();

/**
* @brief Returns a random milk product's name.
Expand All @@ -38,7 +38,7 @@ class Food
* Food::milkProduct() // "mozzarella"
* @endcode
*/
static std::string milkProduct();
static std::string_view milkProduct();

/**
* @brief Returns a random fruit's name.
Expand All @@ -49,7 +49,7 @@ class Food
* Food::fruit() // "apple"
* @endcode
*/
static std::string fruit();
static std::string_view fruit();

/**
* @brief Returns a random meat's name.
Expand All @@ -60,7 +60,7 @@ class Food
* Food::meat() // "antrikot"
* @endcode
*/
static std::string meat();
static std::string_view meat();

/**
* @brief Returns a random seafood's name.
Expand All @@ -71,7 +71,7 @@ class Food
* Food::seafood() // "lobster"
* @endcode
*/
static std::string seafood();
static std::string_view seafood();

/**
* @brief Returns a random vegetable's name.
Expand All @@ -82,7 +82,7 @@ class Food
* Food::vegetable() // "watermelon"
* @endcode
*/
static std::string vegetable();
static std::string_view vegetable();

/**
* @brief Returns a random oil's name.
Expand All @@ -93,7 +93,7 @@ class Food
* Food::oil() // "olive oil"
* @endcode
*/
static std::string oil();
static std::string_view oil();

/**
* @brief Returns a random nut's name.
Expand All @@ -104,7 +104,7 @@ class Food
* Food::nut() // "walnut"
* @endcode
*/
static std::string nut();
static std::string_view nut();

/**
* @brief Returns a random seed's name.
Expand All @@ -115,7 +115,7 @@ class Food
* Food::seed() // "mozzarella"
* @endcode
*/
static std::string seed();
static std::string_view seed();

/**
* @brief Returns a random sugar product's name.
Expand All @@ -126,7 +126,7 @@ class Food
* Food::sugarProduct() // "honey harmony"
* @endcode
*/
static std::string sugarProduct();
static std::string_view sugarProduct();

/**
* @brief Returns a random non-alcoholic beverage's name.
Expand All @@ -137,7 +137,7 @@ class Food
* Food::nonalcoholicBeverage() // "water"
* @endcode
*/
static std::string nonalcoholicBeverage();
static std::string_view nonalcoholicBeverage();

/**
* @brief Returns a random dish's name.
Expand All @@ -148,7 +148,7 @@ class Food
* Food::dishName() // "beef wellington"
* @endcode
*/
static std::string dishName();
static std::string_view dishName();

/**
* @brief Returns a random food categories' name.
Expand All @@ -159,6 +159,6 @@ class Food
* Food::foodCategory() // "Dairy"
* @endcode
*/
static std::string foodCategory();
static std::string_view foodCategory();
};
}
71 changes: 29 additions & 42 deletions src/modules/food/Food.cpp
Original file line number Diff line number Diff line change
@@ -1,90 +1,77 @@
#include "faker-cxx/Food.h"

#include "data/AlcoholicBeverages.h"
#include "data/DishNames.h"
#include "data/FoodCategories.h"
#include "data/Fruits.h"
#include "data/Grains.h"
#include "data/Meats.h"
#include "data/MilkProducts.h"
#include "data/NonalcoholicBeverages.h"
#include "data/Nuts.h"
#include "data/Oils.h"
#include "data/Seafoods.h"
#include "data/Seeds.h"
#include "data/SugarProducts.h"
#include "data/Vegetables.h"
#include "faker-cxx/Helper.h"
#include "FoodData.h"

namespace faker
{
std::string Food::alcoholicBeverage()
std::string_view Food::alcoholicBeverage()
{
return Helper::arrayElement<std::string>(alcoholicBeverages);
return Helper::arrayElement(alcoholicBeverages);
}

std::string Food::dishName()
std::string_view Food::dishName()
{
return Helper::arrayElement<std::string>(dishNames);
return Helper::arrayElement(dishNames);
}

std::string Food::foodCategory()
std::string_view Food::foodCategory()
{
return Helper::arrayElement<std::string>(foodCategories);
return Helper::arrayElement(foodCategories);
}

std::string Food::fruit()
std::string_view Food::fruit()
{
return Helper::arrayElement<std::string>(fruits);
return Helper::arrayElement(fruits);
}

std::string Food::grain()
std::string_view Food::grain()
{
return Helper::arrayElement<std::string>(grains);
return Helper::arrayElement(grains);
}

std::string Food::meat()
std::string_view Food::meat()
{
return Helper::arrayElement<std::string>(meats);
return Helper::arrayElement(meats);
}

std::string Food::milkProduct()
std::string_view Food::milkProduct()
{
return Helper::arrayElement<std::string>(milkProducts);
return Helper::arrayElement(milkProducts);
}

std::string Food::nonalcoholicBeverage()
std::string_view Food::nonalcoholicBeverage()
{
return Helper::arrayElement<std::string>(nonalcoholicBeverages);
return Helper::arrayElement(nonalcoholicBeverages);
}

std::string Food::nut()
std::string_view Food::nut()
{
return Helper::arrayElement<std::string>(nuts);
return Helper::arrayElement(nuts);
}

std::string Food::oil()
std::string_view Food::oil()
{
return Helper::arrayElement<std::string>(oils);
return Helper::arrayElement(oils);
}

std::string Food::seafood()
std::string_view Food::seafood()
{
return Helper::arrayElement<std::string>(seafoods);
return Helper::arrayElement(seafoods);
}

std::string Food::seed()
std::string_view Food::seed()
{
return Helper::arrayElement<std::string>(seeds);
return Helper::arrayElement(seeds);
}

std::string Food::sugarProduct()
std::string_view Food::sugarProduct()
{
return Helper::arrayElement<std::string>(sugarProducts);
return Helper::arrayElement(sugarProducts);
}

std::string Food::vegetable()
std::string_view Food::vegetable()
{
return Helper::arrayElement<std::string>(vegetables);
return Helper::arrayElement(vegetables);
}
}
Loading
Loading