RIP tp::Strings

This commit is contained in:
IlyaShurupov 2024-03-22 14:44:26 +03:00
parent aa53a4addb
commit 893a07e924
90 changed files with 419 additions and 1475 deletions

View file

@ -11,7 +11,7 @@ file(GLOB HEADERS "./public/*.hpp" "./public/*/*.hpp" "./applications/*.hpp")
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
target_include_directories(${PROJECT_NAME} PUBLIC ./public/ ${BINDINGS_INCLUDE} ./ext/)
target_link_libraries(${PROJECT_NAME} PUBLIC Graphics Connection Widgets Strings)
target_link_libraries(${PROJECT_NAME} PUBLIC Graphics Connection Widgets)
target_link_libraries(${PROJECT_NAME} PUBLIC ${BINDINGS_LIBS})
file(COPY "library" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}")

View file

@ -13,11 +13,11 @@ using namespace tp;
#define AS_BOOL trackProperty.second.evaluate_as_boolean()
#define PROP(name) trackProperty.first == #name
tp::String getHome() {
std::string getHome() {
const char* envVarName = "LIB_VIEW_HOME";
char* envVarValue = std::getenv(envVarName);
if (envVarValue != nullptr) {
tp::String out;
std::string out;
out = (int1*) (std::string(envVarValue) + "/").c_str();
return out;
} else {
@ -25,11 +25,11 @@ tp::String getHome() {
}
}
tp::String getSongLocalPath(SongId id) { return getHome() + "tracks/" + tp::String((tp::alni) id); }
std::string getSongLocalPath(SongId id) { return getHome() + "tracks/" + std::to_string((tp::alni) id); }
SONG_FORMAT getSongFormat(const String& localPath) {
std::filesystem::path wavFormat((localPath + ".wav").read());
std::filesystem::path flacFormat((localPath + ".flac").read());
SONG_FORMAT getSongFormat(const std::string& localPath) {
std::filesystem::path wavFormat((localPath + ".wav").c_str());
std::filesystem::path flacFormat((localPath + ".flac").c_str());
if (std::filesystem::exists(flacFormat)) return SONG_FORMAT::FLAC;
if (std::filesystem::exists(wavFormat)) return SONG_FORMAT::WAV;
return SONG_FORMAT::NONE;
@ -42,11 +42,11 @@ void Library::checkExisting() {
}
}
bool Library::loadJson(const String& path) {
bool Library::loadJson(const std::string& path) {
LocalConnection libraryFile;
Buffer<int1> libraryFileMem;
if (!libraryFile.connect(LocalConnection::Location(path.read()), LocalConnection::Type(true))) return false;
if (!libraryFile.connect(LocalConnection::Location(path.c_str()), LocalConnection::Type(true))) return false;
libraryFileMem.reserve(libraryFile.size());
libraryFile.readBytes(libraryFileMem.getBuff(), libraryFile.size());
@ -56,8 +56,8 @@ bool Library::loadJson(const String& path) {
std::string err = picojson::parse(jsonNode, json);
if (!err.empty()) {
printf("Given path - %s\n", path.read());
printf("Home for library is - '%s'. Set it in the env as LIB_VIEW_HOME \n", getHome().read());
printf("Given path - %s\n", path.c_str());
printf("Home for library is - '%s'. Set it in the env as LIB_VIEW_HOME \n", getHome().c_str());
printf("Error parsing json library file - check your paths and files\n %s \n", err.c_str());
return false;
}

View file

@ -15,10 +15,10 @@ class Context {
public:
Context() = default;
bool preloadInfo(const tp::String& path, MusicStream* owner) {
bool preloadInfo(const std::string& path, MusicStream* owner) {
mOwner = owner;
pFlac = drflac_open_file((path + ".flac").read(), NULL);
pFlac = drflac_open_file((path + ".flac").c_str(), NULL);
if (pFlac == NULL) {
return false;

View file

@ -56,8 +56,8 @@ namespace tp {
const RectF textAreaName = { textArea.x, textArea.y, textArea.z, textArea.w * 0.5f };
const RectF textAreaAuthor = { textArea.x, textArea.y + textArea.w * 0.5f, textArea.z, textArea.w * 0.5f };
canvas.text(mTrack->mName.read(), textAreaName, 15.f, Canvas::LC, 4.f, { 0.9f, 0.9f, 0.9f, 1.f });
canvas.text(mTrack->mArtist.read(), textAreaAuthor, 12.f, Canvas::LC, 4.f, { 0.8f, 0.8f, 0.8f, 1.f });
canvas.text(mTrack->mName.c_str(), textAreaName, 15.f, Canvas::LC, 4.f, { 0.9f, 0.9f, 0.9f, 1.f });
canvas.text(mTrack->mArtist.c_str(), textAreaAuthor, 12.f, Canvas::LC, 4.f, { 0.8f, 0.8f, 0.8f, 1.f });
}
public:
@ -70,7 +70,7 @@ namespace tp {
template <typename Events, typename Canvas>
class TrackInfoWidget : public Widget<Events, Canvas> {
struct SortType {
String text;
std::string text;
bool dec = false;
bool inc = false;
};
@ -140,15 +140,15 @@ namespace tp {
ImGui::Text("Song Info:");
if (mTrack) {
ImGui::Text("Name : %s", mTrack->mName.read());
ImGui::Text("Author : %s", mTrack->mArtist.read());
ImGui::Text("Name : %s", mTrack->mName.c_str());
ImGui::Text("Author : %s", mTrack->mArtist.c_str());
ImGui::Text("Love : %s", mTrack->mLoved ? "true" : "false");
ImGui::Text("Id : %lli", mTrack->mId);
ImGui::Text("Total Time : %lli", mTrack->mTotalTime);
ImGui::Text("Play Count : %lli", mTrack->mPlayCount);
ImGui::Text("Skip Count : %lli", mTrack->mSkipCount);
ImGui::Text("Date Added : %s", mTrack->mDateAdded.read());
ImGui::Text("Album : %s", mTrack->mAlbum.read());
ImGui::Text("Date Added : %s", mTrack->mDateAdded.c_str());
ImGui::Text("Album : %s", mTrack->mAlbum.c_str());
} else {
ImGui::Text("Not Selected");
}
@ -168,7 +168,7 @@ namespace tp {
sortFilter.Draw("Sorting Type");
for (int i = 0; i < items.size(); ++i) {
if (!sortFilter.PassFilter(items[i].text.read())) continue;
if (!sortFilter.PassFilter(items[i].text.c_str())) continue;
ImGui::PushID(i);
@ -182,7 +182,7 @@ namespace tp {
ImGui::AlignTextToFramePadding();
ImGui::SameLine();
ImGui::Text("%s", items[i].text.read());
ImGui::Text("%s", items[i].text.c_str());
ImGui::PopID();
}
@ -258,7 +258,8 @@ namespace tp {
mSongList.mContents.clear();
for (auto track : mTracks) {
if (!mCurrentTrackInfo.songFilter.PassFilter(track->mTrack->mName.read()) && !mCurrentTrackInfo.songFilter.PassFilter(track->mTrack->mArtist.read())) {
if (!mCurrentTrackInfo.songFilter.PassFilter(track->mTrack->mName.c_str()) &&
!mCurrentTrackInfo.songFilter.PassFilter(track->mTrack->mArtist.c_str())) {
continue;
}

View file

@ -1,14 +1,13 @@
#pragma once
#include "Window.hpp"
#include "Strings.hpp"
typedef tp::ualni SongId;
enum class SONG_FORMAT { WAV, FLAC, NONE };
tp::String getHome();
tp::String getSongLocalPath(SongId id);
SONG_FORMAT getSongFormat(const tp::String& path);
std::string getHome();
std::string getSongLocalPath(SongId id);
SONG_FORMAT getSongFormat(const std::string& path);
class Track {
public:
@ -16,23 +15,23 @@ public:
public:
SongId mId = 0;
tp::String mName = "undef";
tp::String mArtist = "undef";
tp::String mAlbumArtist = "undef";
tp::String mComposer = "undef";
tp::String mAlbum = "undef";
tp::String mGenre = "undef";
std::string mName = "undef";
std::string mArtist = "undef";
std::string mAlbumArtist = "undef";
std::string mComposer = "undef";
std::string mAlbum = "undef";
std::string mGenre = "undef";
tp::ualni mSize = 0;
tp::ualni mTotalTime = 0;
tp::ualni mYear = 0;
tp::String mDateModified = "undef";
tp::String mDateAdded = "undef";
std::string mDateModified = "undef";
std::string mDateAdded = "undef";
tp::ualni mPlayCount = 0;
tp::String mPlayDate = "undef";
tp::String mPlayDateUTC = "undef";
std::string mPlayDate = "undef";
std::string mPlayDateUTC = "undef";
tp::ualni mSkipCount = 0;
tp::String mSkipDate = "undef";
tp::String mReleaseDate = "undef";
std::string mSkipDate = "undef";
std::string mReleaseDate = "undef";
tp::ualni mAlbumRating = 0;
bool mAlbumRatingComputed = false;
bool mLoved = false;
@ -46,7 +45,7 @@ public:
Library() = default;
public:
bool loadJson(const tp::String& path);
bool loadJson(const std::string& path);
void checkExisting();
public: