Skip to content

Commit

Permalink
refactor company module data
Browse files Browse the repository at this point in the history
  • Loading branch information
cieslarmichal committed May 26, 2024
1 parent 6705a8e commit 90a69d0
Show file tree
Hide file tree
Showing 15 changed files with 650 additions and 708 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(FAKER_SOURCES
src/modules/commerce/Commerce.cpp
src/modules/commerce/CommerceData.cpp
src/modules/company/Company.cpp
src/modules/company/CompanyData.cpp
src/modules/computer/Computer.cpp
src/modules/crypto/Crypto.cpp
src/modules/database/Database.cpp
Expand Down
18 changes: 9 additions & 9 deletions include/faker-cxx/Company.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 @@ -27,7 +27,7 @@ class Company
* Company::type() // "Nonprofit"
* @endcode
*/
static std::string type();
static std::string_view type();

/**
* @brief Returns a random company industry.
Expand All @@ -38,7 +38,7 @@ class Company
* Company::industry() // "Biotechnology"
* @endcode
*/
static std::string industry();
static std::string_view industry();

/**
* @brief Returns a random buzz phrase.
Expand All @@ -60,7 +60,7 @@ class Company
* Company::buzzAdjective() // "one-to-one"
* @endcode
*/
static std::string buzzAdjective();
static std::string_view buzzAdjective();

/**
* @brief Returns a random buzz noun.
Expand All @@ -71,7 +71,7 @@ class Company
* Company::buzzNoun() // "paradigms"
* @endcode
*/
static std::string buzzNoun();
static std::string_view buzzNoun();

/**
* @brief Returns a random buzz verb.
Expand All @@ -82,7 +82,7 @@ class Company
* Company::buzzVerb() // "empower"
* @endcode
*/
static std::string buzzVerb();
static std::string_view buzzVerb();

/**
* @brief Returns a random catch phrase.
Expand All @@ -104,7 +104,7 @@ class Company
* Company::catchPhraseAdjective() // "Multi-tiered"
* @endcode
*/
static std::string catchPhraseAdjective();
static std::string_view catchPhraseAdjective();

/**
* @brief Returns a random catch phrase descriptor.
Expand All @@ -115,7 +115,7 @@ class Company
* Company::catchPhraseDescriptor() // "composite"
* @endcode
*/
static std::string catchPhraseDescriptor();
static std::string_view catchPhraseDescriptor();

/**
* @brief Returns a random catch phrase noun.
Expand All @@ -126,6 +126,6 @@ class Company
* Company::catchPhraseNoun() // "leverage"
* @endcode
*/
static std::string catchPhraseNoun();
static std::string_view catchPhraseNoun();
};
}
47 changes: 19 additions & 28 deletions src/modules/company/Company.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
#include "faker-cxx/Company.h"

#include "../../common/FormatHelper.h"
#include "data/BuzzAdjectives.h"
#include "data/BuzzNouns.h"
#include "data/BuzzVerbs.h"
#include "data/CatchPhraseAdjectives.h"
#include "data/CatchPhraseDescriptors.h"
#include "data/CatchPhraseNouns.h"
#include "data/CompanyTypes.h"
#include "data/Industries.h"
#include "data/Suffixes.h"
#include "CompanyData.h"
#include "faker-cxx/Helper.h"
#include "faker-cxx/Person.h"

Expand All @@ -22,8 +14,7 @@ std::string Company::name()
switch (Number::integer<int>(3))
{
case 0:
companyName =
FormatHelper::format("{} {}", Person::lastName(), Helper::arrayElement<std::string>(companySuffixes));
companyName = FormatHelper::format("{} {}", Person::lastName(), Helper::arrayElement(companySuffixes));
break;
case 1:
companyName = FormatHelper::format("{} {} {}", Person::firstName(), Person::lastName(), Person::jobArea());
Expand All @@ -34,60 +25,60 @@ std::string Company::name()
break;
case 3:
companyName = FormatHelper::format("{} {} {} {}", Person::firstName(), Person::lastName(), Person::jobArea(),
Helper::arrayElement<std::string>(companySuffixes));
Helper::arrayElement(companySuffixes));
break;
}

return companyName;
}

std::string Company::type()
std::string_view Company::type()
{
return Helper::arrayElement<std::string>(companyTypes);
return Helper::arrayElement(companyTypes);
}

std::string Company::industry()
std::string_view Company::industry()
{
return Helper::arrayElement<std::string>(companyIndustries);
return Helper::arrayElement(companyIndustries);
}

std::string Company::buzzPhrase()
{
return FormatHelper::format("{} {} {}", buzzVerb(), buzzAdjective(), buzzNoun());
}

std::string Company::buzzAdjective()
std::string_view Company::buzzAdjective()
{
return Helper::arrayElement<std::string>(buzzAdjectives);
return Helper::arrayElement(buzzAdjectives);
}

std::string Company::buzzNoun()
std::string_view Company::buzzNoun()
{
return Helper::arrayElement<std::string>(buzzNouns);
return Helper::arrayElement(buzzNouns);
}

std::string Company::buzzVerb()
std::string_view Company::buzzVerb()
{
return Helper::arrayElement<std::string>(buzzVerbs);
return Helper::arrayElement(buzzVerbs);
}

std::string Company::catchPhrase()
{
return FormatHelper::format("{} {} {}", catchPhraseAdjective(), catchPhraseDescriptor(), catchPhraseNoun());
}

std::string Company::catchPhraseAdjective()
std::string_view Company::catchPhraseAdjective()
{
return Helper::arrayElement<std::string>(catchPhraseAdjectives);
return Helper::arrayElement(catchPhraseAdjectives);
}

std::string Company::catchPhraseDescriptor()
std::string_view Company::catchPhraseDescriptor()
{
return Helper::arrayElement<std::string>(catchPhraseDescriptors);
return Helper::arrayElement(catchPhraseDescriptors);
}

std::string Company::catchPhraseNoun()
std::string_view Company::catchPhraseNoun()
{
return Helper::arrayElement<std::string>(catchPhraseNouns);
return Helper::arrayElement(catchPhraseNouns);
}
}
Loading

0 comments on commit 90a69d0

Please sign in to comment.