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 Music module #590

Merged
merged 3 commits into from
May 26, 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 @@ -44,6 +44,7 @@ set(FAKER_SOURCES
src/modules/movie/Movie.cpp
src/modules/movie/MovieData.cpp
src/modules/music/Music.cpp
src/modules/music/MusicData.cpp
src/modules/number/Number.cpp
src/modules/person/Person.cpp
src/modules/phone/Phone.cpp
Expand Down
8 changes: 4 additions & 4 deletions include/faker-cxx/Music.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 Music
* Music::artist() // "Nirvana"
* @endcode
*/
static std::string artist();
static std::string_view artist();

/**
* @brief Returns a random music genre.
Expand All @@ -27,7 +27,7 @@ class Music
* Music::genre() // "Rock"
* @endcode
*/
static std::string genre();
static std::string_view genre();

/**
* @brief Returns a random song name.
Expand All @@ -38,6 +38,6 @@ class Music
* Music::songName() // "Light My Fire"
* @endcode
*/
static std::string songName();
static std::string_view songName();
};
}
16 changes: 7 additions & 9 deletions src/modules/music/Music.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
#include "faker-cxx/Music.h"

#include "data/Artists.h"
#include "data/Genres.h"
#include "data/SongNames.h"
#include "MusicData.h"
#include "faker-cxx/Helper.h"

namespace faker
{
std::string Music::artist()
std::string_view Music::artist()
{
return Helper::arrayElement<std::string>(artists);
return Helper::arrayElement(music::artists);
}

std::string Music::genre()
std::string_view Music::genre()
{
return Helper::arrayElement<std::string>(musicGenres);
return Helper::arrayElement(music::musicGenres);
}

std::string Music::songName()
std::string_view Music::songName()
{
return Helper::arrayElement<std::string>(songNames);
return Helper::arrayElement(music::songNames);
}
}
Loading
Loading