Skip to content

Commit 696abb9

Browse files
committed
Set methods to inline to prevent duplicate symbols.
1 parent 252082a commit 696abb9

File tree

10 files changed

+48
-47
lines changed

10 files changed

+48
-47
lines changed

include/RhythmGameUtilities/Audio.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ extern "C"
2323
* @public
2424
*/
2525

26-
PACKAGE_API int **ConvertSamplesToWaveform(float *samples, int size,
27-
int width, int height)
26+
PACKAGE_API inline int **ConvertSamplesToWaveform(float *samples, int size,
27+
int width, int height)
2828
{
2929
auto waveform = new int *[width];
3030

@@ -75,7 +75,7 @@ extern "C"
7575
* @public
7676
*/
7777

78-
PACKAGE_API void FreeWaveform(int **waveform, int width)
78+
PACKAGE_API inline void FreeWaveform(int **waveform, int width)
7979
{
8080
if (waveform != nullptr)
8181
{

include/RhythmGameUtilities/Common.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extern "C"
2424
* @public
2525
*/
2626

27-
PACKAGE_API float Lerp(float a, float b, float t)
27+
PACKAGE_API inline float Lerp(float a, float b, float t)
2828
{
2929
return (1 - t) * a + b * t;
3030
}
@@ -38,7 +38,7 @@ extern "C"
3838
* @public
3939
*/
4040

41-
PACKAGE_API float InverseLerp(float a, float b, float v)
41+
PACKAGE_API inline float InverseLerp(float a, float b, float v)
4242
{
4343
return std::clamp(((v - a) / (b - a)), 0.0f, 1.0f);
4444
}
@@ -51,7 +51,7 @@ extern "C"
5151
* @private
5252
*/
5353

54-
std::string Trim(const char *contents)
54+
inline std::string Trim(const char *contents)
5555
{
5656
return std::regex_replace(contents, std::regex("^\\s+|\\s+$"), "");
5757
}
@@ -64,7 +64,8 @@ std::string Trim(const char *contents)
6464
* @private
6565
*/
6666

67-
std::vector<std::string> Split(const char *contents, const char delimiter)
67+
inline std::vector<std::string> Split(const char *contents,
68+
const char delimiter)
6869
{
6970
auto parts = std::vector<std::string>();
7071

@@ -80,8 +81,8 @@ std::vector<std::string> Split(const char *contents, const char delimiter)
8081
return parts;
8182
}
8283

83-
std::vector<std::string> FindAllMatches(const char *contents,
84-
std::regex pattern)
84+
inline std::vector<std::string> FindAllMatches(const char *contents,
85+
std::regex pattern)
8586
{
8687
auto currentMatch =
8788
std::cregex_iterator(contents, contents + strlen(contents), pattern);
@@ -101,8 +102,8 @@ std::vector<std::string> FindAllMatches(const char *contents,
101102
return matches;
102103
}
103104

104-
std::vector<std::string> FindMatchGroups(const char *contents,
105-
std::regex pattern)
105+
inline std::vector<std::string> FindMatchGroups(const char *contents,
106+
std::regex pattern)
106107
{
107108
auto currentMatch =
108109
std::cregex_iterator(contents, contents + strlen(contents), pattern);

include/RhythmGameUtilities/Enums/Difficulty.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ typedef enum Difficulty
2222

2323
} DifficultyType;
2424

25-
std::string ToString(Difficulty difficulty)
25+
inline std::string ToString(Difficulty difficulty)
2626
{
2727
switch (difficulty)
2828
{

include/RhythmGameUtilities/Enums/NamedSection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef enum NamedSection
1717
Events
1818
} NamedSectionType;
1919

20-
std::string ToString(NamedSection namedSection)
20+
inline std::string ToString(NamedSection namedSection)
2121
{
2222
switch (namedSection)
2323
{

include/RhythmGameUtilities/Enums/TypeCode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ typedef enum TypeCode
2222

2323
} TypeCodeType;
2424

25-
std::string ToString(TypeCode typeCode)
25+
inline std::string ToString(TypeCode typeCode)
2626
{
2727
switch (typeCode)
2828
{

include/RhythmGameUtilities/File.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace RhythmGameUtilities
1616
* @public
1717
*/
1818

19-
std::vector<uint8_t> ReadBytesFromFile(const char *path)
19+
inline std::vector<uint8_t> ReadBytesFromFile(const char *path)
2020
{
2121
std::ifstream file(path, std::ios::binary | std::ios::ate);
2222

@@ -43,7 +43,7 @@ std::vector<uint8_t> ReadBytesFromFile(const char *path)
4343
* @public
4444
*/
4545

46-
std::string ReadStringFromFile(const char *path)
46+
inline std::string ReadStringFromFile(const char *path)
4747
{
4848
std::ifstream file(path);
4949

include/RhythmGameUtilities/Parsers.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ std::regex CHART_SECTION_LINE_PATTERN("([^=]+)\\s*=([^\\r\\n]+)");
4545

4646
std::regex JSON_VALUE_PATTERN("(\"[^\"]+\"|\\S+)");
4747

48-
std::map<std::string,
49-
std::vector<std::pair<std::string, std::vector<std::string>>>>
48+
inline std::map<std::string,
49+
std::vector<std::pair<std::string, std::vector<std::string>>>>
5050
ParseSectionsFromChart(const char *contents)
5151
{
5252
auto matches = FindAllMatches(contents, CHART_SECTION_PATTERN);
@@ -93,7 +93,7 @@ ParseSectionsFromChart(const char *contents)
9393
return sections;
9494
}
9595

96-
std::map<std::string, std::string> ParseMetaDataFromChartSection(
96+
inline std::map<std::string, std::string> ParseMetaDataFromChartSection(
9797
std::vector<std::pair<std::string, std::vector<std::string>>> section)
9898
{
9999
auto data = std::map<std::string, std::string>();
@@ -106,7 +106,7 @@ std::map<std::string, std::string> ParseMetaDataFromChartSection(
106106
return data;
107107
}
108108

109-
std::vector<TimeSignature> ParseTimeSignatureChangesFromChartSection(
109+
inline std::vector<TimeSignature> ParseTimeSignatureChangesFromChartSection(
110110
std::vector<std::pair<std::string, std::vector<std::string>>> section)
111111
{
112112
auto timeSignaturesChanges = std::vector<TimeSignature>();
@@ -127,7 +127,7 @@ std::vector<TimeSignature> ParseTimeSignatureChangesFromChartSection(
127127
return timeSignaturesChanges;
128128
}
129129

130-
std::vector<Tempo> ParseTempoChangesFromChartSection(
130+
inline std::vector<Tempo> ParseTempoChangesFromChartSection(
131131
std::vector<std::pair<std::string, std::vector<std::string>>> section)
132132
{
133133
auto tempoChanges = std::vector<Tempo>();
@@ -146,7 +146,7 @@ std::vector<Tempo> ParseTempoChangesFromChartSection(
146146
return tempoChanges;
147147
}
148148

149-
std::vector<Note> ParseNotesFromChartSection(
149+
inline std::vector<Note> ParseNotesFromChartSection(
150150
std::vector<std::pair<std::string, std::vector<std::string>>> section)
151151
{
152152
auto notes = std::vector<Note>();
@@ -164,7 +164,7 @@ std::vector<Note> ParseNotesFromChartSection(
164164
return notes;
165165
}
166166

167-
std::map<int, std::string> ParseLyricsFromChartSection(
167+
inline std::map<int, std::string> ParseLyricsFromChartSection(
168168
std::vector<std::pair<std::string, std::vector<std::string>>> section)
169169
{
170170
auto lyrics = std::map<int, std::string>();

include/RhythmGameUtilities/ParsersInternal.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ namespace RhythmGameUtilities
1515

1616
extern "C"
1717
{
18-
PACKAGE_API
19-
ChartSectionInternal *ParseSectionsFromChartInternal(const char *contents,
20-
int *outSize)
18+
PACKAGE_API inline ChartSectionInternal *
19+
ParseSectionsFromChartInternal(const char *contents, int *outSize)
2120
{
2221
auto internalSections = ParseSectionsFromChart(contents);
2322

include/RhythmGameUtilities/Utilities.hpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ const float SECONDS_PER_MINUTE = 60.0f;
3434
* @public
3535
*/
3636

37-
int ConvertSecondsToTicks(float seconds, int resolution,
38-
std::vector<Tempo> tempoChanges,
39-
std::vector<TimeSignature> timeSignatureChanges)
37+
inline int
38+
ConvertSecondsToTicks(float seconds, int resolution,
39+
std::vector<Tempo> tempoChanges,
40+
std::vector<TimeSignature> timeSignatureChanges)
4041
{
4142
auto tempoChangesIterator = tempoChanges.begin();
4243
auto timeSignatureIterator = timeSignatureChanges.begin();
@@ -99,7 +100,7 @@ int ConvertSecondsToTicks(float seconds, int resolution,
99100
* @public
100101
*/
101102

102-
std::vector<std::tuple<int, int>>
103+
inline std::vector<std::tuple<int, int>>
103104
GenerateAdjacentKeyPairs(std::map<int, int> keyValuePairs)
104105
{
105106
auto adjacentKeyPairs = std::vector<std::tuple<int, int>>();
@@ -122,9 +123,9 @@ GenerateAdjacentKeyPairs(std::map<int, int> keyValuePairs)
122123
return adjacentKeyPairs;
123124
}
124125

125-
std::vector<BeatBar> CalculateBeatBars(std::vector<Tempo> tempoChanges,
126-
int resolution, int ts,
127-
bool includeHalfNotes)
126+
inline std::vector<BeatBar> CalculateBeatBars(std::vector<Tempo> tempoChanges,
127+
int resolution, int ts,
128+
bool includeHalfNotes)
128129
{
129130
std::vector<BeatBar> beatBars;
130131

@@ -159,8 +160,8 @@ std::vector<BeatBar> CalculateBeatBars(std::vector<Tempo> tempoChanges,
159160
return beatBars;
160161
}
161162

162-
std::optional<Note> FindPositionNearGivenTick(std::vector<Note> notes, int tick,
163-
int delta = 50)
163+
inline std::optional<Note> FindPositionNearGivenTick(std::vector<Note> notes,
164+
int tick, int delta = 50)
164165
{
165166
auto left = 0;
166167
auto right = static_cast<int>(notes.size()) - 1;
@@ -198,7 +199,7 @@ extern "C"
198199
* @public
199200
*/
200201

201-
PACKAGE_API float ConvertTickToPosition(int tick, int resolution)
202+
PACKAGE_API inline float ConvertTickToPosition(int tick, int resolution)
202203
{
203204
return tick / static_cast<float>(resolution);
204205
}
@@ -212,8 +213,8 @@ extern "C"
212213
* @public
213214
*/
214215

215-
PACKAGE_API bool IsOnTheBeat(int bpm, float currentTime,
216-
float delta = 0.05f)
216+
PACKAGE_API inline bool IsOnTheBeat(int bpm, float currentTime,
217+
float delta = 0.05f)
217218
{
218219
auto beatInterval = SECONDS_PER_MINUTE / static_cast<float>(bpm);
219220

@@ -234,7 +235,8 @@ extern "C"
234235
* @public
235236
*/
236237

237-
PACKAGE_API int RoundUpToTheNearestMultiplier(int value, int multiplier)
238+
PACKAGE_API inline int RoundUpToTheNearestMultiplier(int value,
239+
int multiplier)
238240
{
239241
return static_cast<int>(
240242
std::ceil(static_cast<float>(value) / multiplier) * multiplier);
@@ -250,8 +252,8 @@ extern "C"
250252
* @public
251253
*/
252254

253-
PACKAGE_API float CalculateAccuracyRatio(int position, int currentPosition,
254-
int delta = 50)
255+
PACKAGE_API inline float
256+
CalculateAccuracyRatio(int position, int currentPosition, int delta = 50)
255257
{
256258
auto diff = position - currentPosition;
257259

include/RhythmGameUtilities/UtilitiesInternal.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace RhythmGameUtilities
1919

2020
extern "C"
2121
{
22-
PACKAGE_API int
22+
PACKAGE_API inline int
2323
ConvertSecondsToTicksInternal(float seconds, int resolution,
2424
Tempo *tempoChanges, int tempoChangesSize,
2525
TimeSignature *timeSignaturesChanges,
@@ -43,11 +43,10 @@ extern "C"
4343
timeSignatureChangesVector);
4444
}
4545

46-
PACKAGE_API BeatBar *CalculateBeatBarsInternal(Tempo *tempoChanges,
47-
int tempoChangesSize,
48-
int resolution, int ts,
49-
bool includeHalfNotes,
50-
int *outSize)
46+
PACKAGE_API inline BeatBar *
47+
CalculateBeatBarsInternal(Tempo *tempoChanges, int tempoChangesSize,
48+
int resolution, int ts, bool includeHalfNotes,
49+
int *outSize)
5150
{
5251
std::vector<Tempo> tempoChangesVector;
5352

0 commit comments

Comments
 (0)