-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 163-feature/addBarcodeFunctionalitiesToComme…
…rceModule
- Loading branch information
Showing
17 changed files
with
993 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
namespace faker { | ||
class Airline { | ||
public: | ||
enum class AircraftType | ||
{ | ||
Regional, | ||
Narrowbody, | ||
Widebody, | ||
}; | ||
|
||
/* | ||
* @brief Get a random aircraft type | ||
* | ||
* @return a random aircraft type | ||
* | ||
* @code | ||
* Airline::aircraftType // "narrowbody" | ||
*/ | ||
static std::string aircraftType(); | ||
|
||
struct Airplane | ||
{ | ||
std::string name; | ||
std::string iataTypeCode; | ||
}; | ||
|
||
/* | ||
* @brief Get a random airplane | ||
* | ||
* @return a random airplane and its iataTypeCode | ||
* | ||
* @code | ||
* Airline::airplane() // {"Boeing 737-800", "738"} | ||
* @endcode | ||
*/ | ||
static Airplane airplane(); | ||
|
||
struct AirlineStruct | ||
{ | ||
std::string name; | ||
std::string iataCode; | ||
}; | ||
|
||
/* | ||
* @brief Get a random airline | ||
* | ||
* @return a random airline and its iataCode | ||
* | ||
* @code | ||
* Airline::airline() // {"Air Canada", "AC"} | ||
* @endcode | ||
*/ | ||
static AirlineStruct airline(); | ||
|
||
struct Airport | ||
{ | ||
std::string name; | ||
std::string iataCode; | ||
}; | ||
|
||
/* | ||
* @brief Get a random airport | ||
* | ||
* @return a random airport and its iataCode | ||
* | ||
* @code | ||
* Airline::airport() // {"Toronto Pearson International Airport", "YYZ"} | ||
* @endcode | ||
*/ | ||
static Airport airport(); | ||
|
||
/* | ||
* @brief Get a random seat by aircraft type | ||
* | ||
* @param aircraftType the aircraft type | ||
* | ||
* @return a random seat | ||
* | ||
* @code | ||
* Airline::seat(AircraftType::Narrowbody) // "1A" | ||
* @endcode | ||
*/ | ||
static std::string seat(AircraftType aircraftType); | ||
|
||
/* | ||
* @brief Get a random record location | ||
* | ||
* @return a random record location | ||
* | ||
* @code | ||
* Airline::recordLocator() // "ABCDEF" | ||
* Airline::recordLocator(true) // "ABC123" | ||
* @endcode | ||
*/ | ||
static std::string recordLocator(bool allowNumerics = false); | ||
|
||
/* | ||
* @brief Get a random flight number from given length | ||
* | ||
* @param addLeadingZeros whether to add leading zeros | ||
* | ||
* @param length the length of the flight number | ||
* | ||
* @return a random flight number | ||
* | ||
* @code | ||
* Airline::flightNumber() // "1234" | ||
* Airline::flightNumber(true) // "0123" | ||
* Airline::flightNumber(false, 3) // "234" | ||
* @endcode | ||
*/ | ||
static std::string flightNumber(bool addLeadingZeros = false, unsigned int length = 4); | ||
|
||
struct Range { | ||
unsigned int min; | ||
unsigned int max; | ||
}; | ||
/* | ||
* @brief Get a random flight number from given length | ||
* | ||
* @param addLeadingZeros whether to add leading zeros | ||
* | ||
* @param length the length of the flight number | ||
* | ||
* @return a random flight number | ||
* | ||
* @code | ||
* Airline::flightNumber() // "1234" | ||
* Airline::flightNumber(true) // "0123" | ||
* Airline::flightNumber(false, {1, 4}) // "234" // "12" // "1234" | ||
* @endcode | ||
*/ | ||
static std::string flightNumber(bool addLeadingZeros = false, Range length = {1, 4}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "faker-cxx/Airline.h" | ||
#include "faker-cxx/Helper.h" | ||
#include "faker-cxx/Number.h" | ||
#include "faker-cxx/String.h" | ||
|
||
#include <string> | ||
|
||
#include "data/AircraftTypes.h" | ||
#include "data/Airplanes.h" | ||
#include "data/Airlines.h" | ||
#include "data/Airports.h" | ||
#include "data/Seat.h" | ||
|
||
namespace faker | ||
{ | ||
std::string Airline::aircraftType() | ||
{ | ||
return Helper::arrayElement<std::string>(aircraftTypes); | ||
} | ||
|
||
Airline::Airplane Airline::airplane() | ||
{ | ||
return Helper::arrayElement<Airline::Airplane>(airplanes); | ||
} | ||
|
||
Airline::AirlineStruct Airline::airline() | ||
{ | ||
return Helper::arrayElement<Airline::AirlineStruct>(airlines); | ||
} | ||
|
||
Airline::Airport Airline::airport() | ||
{ | ||
return Helper::arrayElement<Airline::Airport>(airports); | ||
} | ||
|
||
std::string Airline::seat(Airline::AircraftType aircraftType) { | ||
return std::to_string(Number::integer(1, aircraftTypeMaxRows.at(aircraftType))) + Helper::arrayElement<char>(aircraftTypeSeatLetters.at(aircraftType)); | ||
} | ||
|
||
std::string Airline::recordLocator(bool allowNumerics) | ||
{ | ||
if (allowNumerics) { | ||
return String::alphanumeric(6, StringCasing::Upper); | ||
} | ||
|
||
return String::alpha(6, StringCasing::Upper); | ||
} | ||
|
||
std::string Airline::flightNumber(bool addLeadingZeros, unsigned int length) { | ||
if (addLeadingZeros) { | ||
return String::numeric(length, true); | ||
} | ||
|
||
return String::numeric(length, false); | ||
} | ||
|
||
std::string Airline::flightNumber(bool addLeadingZeros, Airline::Range length) { | ||
if (addLeadingZeros) { | ||
return String::numeric(Number::integer(length.min, length.max), true); | ||
} | ||
|
||
return String::numeric(Number::integer(length.min, length.max), false); | ||
} | ||
} |
Oops, something went wrong.