Skip to content

Commit 9332e47

Browse files
poco0317sukibaby
authored andcommitted
String removal - fix weird char to str cast
Correctly calculate frame counts when reading WAV files fixes fix Revert "fix" This reverts commit 96ac2e6. Revert "fixes" This reverts commit c431eb9. Revert "Correctly calculate frame counts when reading WAV files" This reverts commit 2af47ea. Remove String and StringRef this doesnt compile. effectively a replacement of: String -> std::string StringRef -> const std::string& Fix compilation issues after removing String/StringRef this includes some questionable includes of Core.h which seemed to be required to compile. this also includes some reimplementations of StringUtils functions and misc items String removal crash fix 1 String removal broken format string fix finish merge String removal crash fix 2 i was getting cant reference iterator past end over and over here for no reason no matter what i did even if i checked for end and then ran into 25 other errors so lets just rewrite it String removal warns reduction this doesnt solve as many as i would like but it begins to reach outside the scope as more get fixed. it would be more ideal to actually just change the argument types instead of doing all this casting String removal - for shader logging, clear and resize a string String removal - Str::create replaced by constructor template <class InputIterator> std::string (InputIterator first, InputIterator last); String removal - remove Str::assign String removal crash fix 3 typo String removal - replace stricmp
1 parent e68be73 commit 9332e47

File tree

117 files changed

+1669
-2026
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1669
-2026
lines changed

build/VisualStudio/ArrowVortex.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@
330330
<ClCompile Include="..\..\src\Core\Renderer.cpp" />
331331
<ClCompile Include="..\..\src\Core\Shader.cpp" />
332332
<ClCompile Include="..\..\src\Core\Slot.cpp" />
333-
<ClCompile Include="..\..\src\Core\String.cpp" />
334333
<ClCompile Include="..\..\src\Core\StringUtils.cpp" />
335334
<ClCompile Include="..\..\src\Core\Text.cpp" />
336335
<ClCompile Include="..\..\src\Core\TextDraw.cpp" />
@@ -440,7 +439,6 @@
440439
<ClInclude Include="..\..\src\Core\Renderer.h" />
441440
<ClInclude Include="..\..\src\Core\Shader.h" />
442441
<ClInclude Include="..\..\src\Core\Slot.h" />
443-
<ClInclude Include="..\..\src\Core\String.h" />
444442
<ClInclude Include="..\..\src\Core\StringUtils.h" />
445443
<ClInclude Include="..\..\src\Core\Text.h" />
446444
<ClInclude Include="..\..\src\Core\TextDraw.h" />

build/VisualStudio/ArrowVortex.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@
4848
<ClCompile Include="..\..\src\Core\Input.cpp">
4949
<Filter>Core</Filter>
5050
</ClCompile>
51-
<ClCompile Include="..\..\src\Core\String.cpp">
52-
<Filter>Core</Filter>
53-
</ClCompile>
5451
<ClCompile Include="..\..\src\Core\StringUtils.cpp">
5552
<Filter>Core</Filter>
5653
</ClCompile>
@@ -368,9 +365,6 @@
368365
<ClInclude Include="..\..\src\Core\Reference.h">
369366
<Filter>Core</Filter>
370367
</ClInclude>
371-
<ClInclude Include="..\..\src\Core\String.h">
372-
<Filter>Core</Filter>
373-
</ClInclude>
374368
<ClInclude Include="..\..\src\Core\StringUtils.h">
375369
<Filter>Core</Filter>
376370
</ClInclude>

src/Core/ByteStream.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <Core/ByteStream.h>
2-
#include <Core/String.h>
32
#include <Core/Utils.h>
43

54
#include <string.h>
@@ -159,10 +158,10 @@ void WriteStream::writeNum(uint32_t num)
159158
}
160159
}
161160

162-
void WriteStream::writeStr(StringRef str)
161+
void WriteStream::writeStr(const std::string& str)
163162
{
164-
writeNum(str.len());
165-
write(str.str(), str.len());
163+
writeNum(str.length());
164+
write(str.data(), str.length());
166165
}
167166

168167
// ================================================================================================
@@ -312,28 +311,27 @@ uint32_t ReadStream::readNum()
312311
return out;
313312
}
314313

315-
String ReadStream::readStr()
314+
std::string ReadStream::readStr()
316315
{
317-
String out;
318-
uint32_t len = readNum();
319-
auto newPos = read_position_ + len;
316+
std::string out;
317+
uint len = readNum();
320318
if(newPos <= end_position_)
321319
{
322320
auto str = read_position_;
323321
read_position_ = newPos;
324-
return String((const char*)str, len);
322+
return std::string((const char*)str, len);
325323
}
326324
read_position_ = end_position_;
327325
is_read_successful_ = false;
328-
return String();
326+
return std::string();
329327
}
330328

331329
void ReadStream::readNum(uint32_t& num)
332330
{
333331
num = readNum();
334332
}
335333

336-
void ReadStream::readStr(String& str)
334+
void ReadStream::readStr(std::string& str)
337335
{
338336
str = readStr();
339337
}

src/Core/ByteStream.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ struct WriteStream
1919
void write32(const void* val);
2020
void write64(const void* val);
2121

22-
void writeNum(uint32_t num);
23-
void writeStr(StringRef str);
22+
void writeNum(uint num);
23+
void writeStr(const std::string& str);
2424

2525
template <unsigned int S>
2626
inline void writeSz(const void* val)
@@ -89,10 +89,10 @@ struct ReadStream
8989
void read64(void* out);
9090

9191
uint32_t readNum();
92-
String readStr();
92+
std::string readStr();
9393

94-
void readNum(uint32_t& num);
95-
void readStr(String& str);
94+
void readNum(uint& num);
95+
void readStr(std::string& str);
9696

9797
template <size_t S>
9898
inline void readSz(void* out)

src/Core/Core.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <cstdint>
44
#include <chrono>
5+
#include <string>
56

67
namespace Vortex {
78

@@ -21,7 +22,6 @@ typedef areat<float> areaf;
2122

2223
struct colorf { float r, g, b, a; };
2324

24-
class String;
2525
struct TileBar;
2626
struct TileRect;
2727
struct TileRect2;
@@ -43,7 +43,6 @@ struct Noteskin;
4343
struct Simfile;
4444
struct TimingData;
4545

46-
typedef const String& StringRef;
4746
typedef uint64_t TextureHandle;
4847

4948
extern std::chrono::duration<double> deltaTime;

src/Core/FontData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct FontData
7070
GlyphCache* currentCache;
7171
int currentSize;
7272
void* ftface;
73-
String path;
73+
std::string path;
7474
FontData* next;
7575
int refs;
7676
int loadflags;

src/Core/FontManager.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace {
1717

1818
struct FontManagerInstance
1919
{
20-
typedef std::map<String, FontData*> FontMap;
21-
typedef std::map<String, Glyph> GlyphMap;
20+
typedef std::map<std::string, FontData*> FontMap;
21+
typedef std::map<std::string, Glyph> GlyphMap;
2222

2323
FontMap fonts;
2424
void* ftLib;
@@ -136,13 +136,13 @@ void FontManager::release(FontData* font)
136136
}
137137
}
138138

139-
FontData* FontManager::find(StringRef path)
139+
FontData* FontManager::find(const std::string& path)
140140
{
141141
auto it = Map::findVal(FM->fonts, path);
142142
return it ? *it : nullptr;
143143
}
144144

145-
FontData* FontManager::load(StringRef path, Text::Hinting hinting)
145+
FontData* FontManager::load(const std::string& path, Text::Hinting hinting)
146146
{
147147
// If fonts are created before goo is initialized, just return null.
148148
if(!FM) return nullptr;
@@ -158,17 +158,17 @@ FontData* FontManager::load(StringRef path, Text::Hinting hinting)
158158

159159
// If not, try to load the font.
160160
FT_Face face;
161-
int result = FT_New_Face((FT_Library)(FM->ftLib), path.str(), 0, &face);
161+
int result = FT_New_Face((FT_Library)(FM->ftLib), path.c_str(), 0, &face);
162162
if(result == FT_Err_Ok)
163163
{
164-
FontData* font = new FontData(face, path.str(), hinting);
164+
FontData* font = new FontData(face, path.c_str(), hinting);
165165
FM->fonts[path] = font;
166166
return font;
167167
}
168168
else
169169
{
170170
Debug::blockBegin(Debug::ERROR, "could not load font file");
171-
Debug::log("file: %s\n", path.str());
171+
Debug::log("file: %s\n", path.c_str());
172172
switch(result)
173173
{
174174
case FT_Err_Cannot_Open_Resource:
@@ -197,7 +197,7 @@ void FontManager::cache(FontData* font)
197197
}
198198
}
199199

200-
bool FontManager::loadGlyph(StringRef name, const Texture& texture, int dx, int dy, int advance)
200+
bool FontManager::loadGlyph(const std::string& name, const Texture& texture, int dx, int dy, int advance)
201201
{
202202
auto tex = (Texture::Data*)texture.data();
203203
if(tex)
@@ -221,7 +221,7 @@ bool FontManager::loadGlyph(StringRef name, const Texture& texture, int dx, int
221221
return false;
222222
}
223223

224-
Glyph* FontManager::getGlyph(StringRef name)
224+
Glyph* FontManager::getGlyph(const std::string& name)
225225
{
226226
return Map::findVal(FM->specialGlyphs, name);
227227
}
@@ -232,10 +232,10 @@ void FontManager::log()
232232
Debug::log("amount: %i\n", FM->fonts.size());
233233
for(auto& font : FM->fonts)
234234
{
235-
String path = font.second->path;
235+
auto& path = font.second->path;
236236
if(path.empty()) path = "-- no path --";
237237

238-
Debug::log("\npath: %s\n", path.str());
238+
Debug::log("\npath: %s\n", path.c_str());
239239
Debug::log("refs: %i\n", font.second->refs);
240240
Debug::log("cached: %i\n", font.second->cached);
241241
}

src/Core/FontManager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ struct FontManager {
99
static void create();
1010
static void destroy();
1111

12-
static FontData* load(StringRef path, Text::Hinting h);
13-
static FontData* find(StringRef path);
12+
static FontData* load(const std::string& path, Text::Hinting h);
13+
static FontData* find(const std::string& path);
1414
static void cache(FontData* font);
1515

16-
static bool loadGlyph(StringRef name, const Texture& texture, int dx, int dy, int advance);
17-
static Glyph* getGlyph(StringRef name);
16+
static bool loadGlyph(const std::string& name, const Texture& texture, int dx, int dy, int advance);
17+
static Glyph* getGlyph(const std::string& name);
1818
static void release(FontData* font);
1919

2020
static void log();

src/Core/Gui.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ struct GuiMainData
2929

3030
GuiMain::ClipboardSetFunction clipboardSet;
3131
GuiMain::ClipboardGetFunction clipboardGet;
32-
String clipboardText;
32+
std::string clipboardText;
3333

34-
String tooltipPreviousText;
35-
String tooltipText;
34+
std::string tooltipPreviousText;
35+
std::string tooltipText;
3636
vec2i tooltipPos;
3737
float tooltipTimer;
3838

@@ -87,7 +87,7 @@ static void handleTooltip()
8787
{
8888
if(GUI->tooltipPreviousText == GUI->tooltipText)
8989
{
90-
if(GUI->tooltipText.len() && GUI->tooltipTimer > 1.0f)
90+
if(GUI->tooltipText.length() && GUI->tooltipTimer > 1.0f)
9191
{
9292
TextStyle style;
9393

@@ -97,7 +97,7 @@ static void handleTooltip()
9797
style.shadowColor = Colors::blank;
9898
style.fontSize = 11;
9999

100-
Text::arrange(Text::TL, style, 256, GUI->tooltipText.str());
100+
Text::arrange(Text::TL, style, 256, GUI->tooltipText.c_str());
101101
vec2i textSize = Text::getSize();
102102

103103
vec2i& pos = GUI->tooltipPos;
@@ -126,7 +126,7 @@ static void handleTooltip()
126126
Text::draw(textBox);
127127
}
128128
}
129-
else if(GUI->tooltipText.len())
129+
else if(GUI->tooltipText.length())
130130
{
131131
GUI->tooltipPos = {INT_MAX, INT_MAX};
132132
GUI->tooltipTimer = 0.0f;
@@ -148,7 +148,7 @@ void GuiMain::frameStart(float dt, InputEvents& events)
148148
GUI->cursorIcon = Cursor::ARROW;
149149

150150
GUI->tooltipPreviousText = GUI->tooltipText;
151-
GUI->tooltipText = String();
151+
GUI->tooltipText = std::string();
152152
GUI->tooltipTimer += dt;
153153

154154
Renderer::startFrame();
@@ -185,13 +185,13 @@ void GuiMain::setClipboardFunctions(ClipboardGetFunction get, ClipboardSetFuncti
185185
GUI->clipboardSet = set;
186186
}
187187

188-
void GuiMain::setClipboardText(String text)
188+
void GuiMain::setClipboardText(std::string text)
189189
{
190190
GUI->clipboardText = text;
191191
if(GUI->clipboardSet) (*GUI->clipboardSet)(GUI->clipboardText);
192192
}
193193

194-
String GuiMain::getClipboardText()
194+
std::string GuiMain::getClipboardText()
195195
{
196196
if(GUI->clipboardGet) GUI->clipboardText = (*GUI->clipboardGet)();
197197
return GUI->clipboardText;
@@ -207,12 +207,12 @@ Cursor::Icon GuiMain::getCursorIcon()
207207
return GUI->cursorIcon;
208208
}
209209

210-
void GuiMain::setTooltip(String text)
210+
void GuiMain::setTooltip(std::string text)
211211
{
212212
GUI->tooltipText = text;
213213
}
214214

215-
String GuiMain::getTooltip()
215+
std::string GuiMain::getTooltip()
216216
{
217217
return GUI->tooltipText;
218218
}

0 commit comments

Comments
 (0)