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

remove unused api types #268

Merged
merged 1 commit into from
Nov 16, 2023
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: 0 additions & 1 deletion include/faker-cxx/Git.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <string>

#include "faker-cxx/types/Country.h"
#include "faker-cxx/types/Language.h"

namespace faker
{
Expand Down
14 changes: 1 addition & 13 deletions include/faker-cxx/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@

#include "types/ImageCategory.h"

namespace
{
std::map<faker::ImageCategory, std::string> imageCategoryString = {
{faker::ImageCategory::animals, "animals"}, {faker::ImageCategory::business, "business"},
{faker::ImageCategory::cats, "cats"}, {faker::ImageCategory::city, "city"},
{faker::ImageCategory::food, "food"}, {faker::ImageCategory::nightlife, "nightlife"},
{faker::ImageCategory::fashion, "fashion"}, {faker::ImageCategory::people, "people"},
{faker::ImageCategory::nature, "nature"}, {faker::ImageCategory::sports, "sports"},
{faker::ImageCategory::technics, "technics"}, {faker::ImageCategory::transport, "transport"},
};
}

namespace faker
{
class Image
Expand Down Expand Up @@ -63,4 +51,4 @@ class Image
*/
static std::string dimensions();
};
}
}
3 changes: 1 addition & 2 deletions include/faker-cxx/Person.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#include <string>

#include "faker-cxx/types/Country.h"
#include "types/Language.h"
#include "types/Sex.h"
#include "faker-cxx/types/Sex.h"

namespace faker
{
Expand Down
2 changes: 1 addition & 1 deletion include/faker-cxx/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <string>

#include "types/Hex.h"
#include "types/RandomGenerator.hpp"
#include "types/RandomGenerator.h"

namespace faker
{
Expand Down
2 changes: 1 addition & 1 deletion include/faker-cxx/System.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include "types/CronOptions.h"
#include "types/DirectoryPath.h"
#include "types/FileOptions.h"
#include "types/FileType.h"
#include "types/MimeTypes.h"
#include "types/NetworkInterfaceOptions.h"

Expand Down
26 changes: 26 additions & 0 deletions include/faker-cxx/types/FileType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <map>
#include <string>

namespace faker
{
enum class FileType
{
Video,
Audio,
Image,
Text,
Application
};

inline std::string toString(FileType type)
{
std::map<FileType, std::string> enumToStringMapping{{FileType::Video, "video"},
{FileType::Audio, "audio"},
{FileType::Image, "image"},
{FileType::Text, "text"},
{FileType::Application, "application"}};
return enumToStringMapping.at(type);
}
}
26 changes: 13 additions & 13 deletions include/faker-cxx/types/ImageCategory.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ namespace faker
{
enum class ImageCategory
{
animals,
business,
cats,
city,
food,
nightlife,
fashion,
people,
nature,
sports,
technics,
transport
Animals,
Business,
Cats,
City,
Food,
Nightlife,
Fashion,
People,
Nature,
Sports,
Technics,
Transport
};
}
}
52 changes: 0 additions & 52 deletions include/faker-cxx/types/Language.h

This file was deleted.

136 changes: 0 additions & 136 deletions include/faker-cxx/types/MimeTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,141 +6,5 @@

namespace faker
{
const std::vector<std::string> mimeTypes = {"application/atom+xml",
"application/font-woff",
"application/gzip",
"application/java-archive",
"application/javascript",
"application/json",
"application/ld+json",
"application/msword",
"application/octet-stream",
"application/ogg",
"application/pdf",
"application/rdf+xml",
"application/rtf",
"application/vnd.apple.mpegurl",
"application/vnd.ms-excel",
"application/vnd.ms-fontobject",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/x-7z-compressed",
"application/x-font-ttf",
"application/x-javascript",
"application/x-mpegURL",
"application/x-rar-compressed",
"application/x-shockwave-flash",
"application/x-tar",
"application/x-www-form-urlencoded",
"application/xhtml+xml",
"application/xml",
"application/zip",
"audio/aac",
"audio/midi",
"audio/ogg",
"audio/wav",
"audio/webm",
"audio/mpeg",
"font/woff",
"font/woff2",
"image/apng",
"image/bmp",
"image/gif",
"image/jpeg",
"image/png",
"image/svg+xml",
"image/tiff",
"image/webp",
"image/x-icon",
"multipart/form-data",
"text/calendar",
"text/css",
"text/csv",
"text/html",
"text/javascript",
"text/plain",
"text/xml",
"video/mp4",
"video/3gpp",
"video/3gpp2",
"video/mp2t",
"video/mpeg",
"video/ogg",
"video/webm",
"video/x-msvideo",
"video/x-flv"};

// Only contains non obvious extensions.
const std::map<std::string, std::string> mimeTypesExtensions{
{"application/atom+xml", "xml"},
{"application/font-woff", "woff"},
{"application/gzip", "gz"},
{"application/java-archive", "jar"},
{"application/javascript", "js"},
{"application/ld+json", "jsonld"},
{"application/msword", "doc"},
{"application/octet-stream", "bin"},
{"application/ogg", "ogx"},
{"application/vnd.ms-excel", "xls"},
{"application/vnd.ms-fontobject", "eot"},
{"application/vnd.openxmlformats-officedocument.presentationml.presentation", "pptx"},
{"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlsx"},
{"application/vnd.openxmlformats-officedocument.wordprocessingml.document", "docx"},
{"application/x-7z-compressed", "7z"},
{"application/x-tar", "tart"},
{"application/xhtml+xml", "xhtml"},

{"audio/ogg", "oga"},
{"audio/webm", "weba"},
{"audio/mpeg", "mp3"},

{"image/svg+xml", "svg"},

{"text/calendar", "ics"},
{"text/javascript", "js"},
{"text/plain", "txt"},

{"video/3gpp", "3gp"},
{"video/3gpp2", "3g2"},
{"video/mp2t", "ts"},
{"video/ogg", "ogv"},
{"video/x-msvideo", "avi"}};

const std::vector<std::string> commonMimeTypes = {"application/pdf", "audio/mpeg", "audio/wav",
"image/png", "image/jpeg", "image/gif",
"video/mp4", "video/mpeg", "text/html"};

const std::vector<std::string> commonFileTypes = {"video", "audio", "image", "text", "application"};

enum class FileType
{
Video,
Audio,
Image,
Text,
Application
};
inline std::string toString(FileType type)
{
std::map<FileType, std::string> enumToStringMapping{{FileType::Video, "video"},
{FileType::Audio, "audio"},
{FileType::Image, "image"},
{FileType::Text, "text"},
{FileType::Application, "application"}};
return enumToStringMapping.at(type);
}
inline std::string extension(const std::string& mimeType)
{
const auto it = mimeTypesExtensions.find(mimeType);
if (it == mimeTypesExtensions.end())
{
auto pos = mimeType.find_last_of('/');
return mimeType.substr(pos + 1);
}
else
{
return it->second;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#pragma once

#include <random>

namespace faker
{
template <typename T>
requires std::uniform_random_bit_generator<T>
class RandomGenerator
Expand All @@ -22,3 +25,4 @@ class RandomGenerator
private:
T generator_;
};
}
2 changes: 1 addition & 1 deletion src/modules/git/Git.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "faker-cxx/Number.h"
#include "faker-cxx/Person.h"
#include "faker-cxx/String.h"
#include "faker-cxx/types/Language.h"
#include "faker-cxx/Word.h"
#include "fmt/format.h"

Expand Down Expand Up @@ -62,6 +61,7 @@ std::string Git::commitDate(unsigned years)
}

timeZoneString += std::to_string(timeZone * 100);

if (!timeZone)
{
timeZoneString += "00";
Expand Down
9 changes: 1 addition & 8 deletions src/modules/git/GitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@
#include "gtest/gtest.h"

#include "../../common/StringHelper.h"
#include "../date/data/MonthNames.h"
#include "faker-cxx/Date.h"
#include "faker-cxx/Internet.h"
#include "faker-cxx/Number.h"
#include "faker-cxx/Person.h"
#include "faker-cxx/String.h"
#include "faker-cxx/types/Language.h"
#include "faker-cxx/Word.h"

using namespace ::testing;
using namespace faker;
Expand Down Expand Up @@ -54,7 +47,7 @@ TEST_F(GitTest, shouldGenerateBranch)

TEST_F(GitTest, branchIssueNumTest)
{
unsigned testValue = unsigned(faker::Number::integer(2, 100));
auto testValue = unsigned(faker::Number::integer(2, 100));
std::vector<std::string> branch = faker::StringHelper::split(Git::branch(testValue), "-");
bool numberAtFront = false;
int number;
Expand Down
13 changes: 12 additions & 1 deletion src/modules/image/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,22 @@

namespace faker
{
namespace
{
std::map<faker::ImageCategory, std::string> imageCategoryToLoremFlickrStringMapping = {
{faker::ImageCategory::Animals, "animals"}, {faker::ImageCategory::Business, "business"},
{faker::ImageCategory::Cats, "cats"}, {faker::ImageCategory::City, "city"},
{faker::ImageCategory::Food, "food"}, {faker::ImageCategory::Nightlife, "nightlife"},
{faker::ImageCategory::Fashion, "fashion"}, {faker::ImageCategory::People, "people"},
{faker::ImageCategory::Nature, "nature"}, {faker::ImageCategory::Sports, "sports"},
{faker::ImageCategory::Technics, "technics"}, {faker::ImageCategory::Transport, "transport"},
};
}

std::string Image::imageUrl(unsigned int width, unsigned int height, std::optional<ImageCategory> category)
{
const std::string image_category =
category.has_value() ? fmt::format("/{}", imageCategoryString.at(category.value())) : "";
category.has_value() ? fmt::format("/{}", imageCategoryToLoremFlickrStringMapping.at(category.value())) : "";
return fmt::format("https://loremflickr.com/{}/{}{}", width, height, image_category);
}

Expand Down
Loading