From be7f5b91aedda486a1ece003bd6793cdf891e0c9 Mon Sep 17 00:00:00 2001 From: 2bit Date: Sat, 16 Apr 2022 02:10:23 +0900 Subject: [PATCH 1/4] add ofJson.h and ofThreadChannel.h to project --- .../osx/openFrameworksLib.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj index 21222d9b322..d20055a6fd0 100644 --- a/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj +++ b/libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj/project.pbxproj @@ -48,6 +48,8 @@ 772BDF74146928600030F0EE /* ofOpenALSoundPlayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 772BDF72146928600030F0EE /* ofOpenALSoundPlayer.h */; }; 92C55F88132DA7DD00EC2631 /* ofPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 92C55F86132DA7DD00EC2631 /* ofPath.cpp */; }; 92C55F89132DA7DD00EC2631 /* ofPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 92C55F87132DA7DD00EC2631 /* ofPath.h */; }; + 959744752809DDF70091BACA /* ofJson.h in Headers */ = {isa = PBXBuildFile; fileRef = 959744742809DDF70091BACA /* ofJson.h */; }; + 959744782809DE340091BACA /* ofThreadChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 959744772809DE340091BACA /* ofThreadChannel.h */; }; 9979E8221A1CCC44007E55D1 /* ofWindowSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 9979E81F1A1CCC44007E55D1 /* ofWindowSettings.h */; }; 9979E8231A1CCC44007E55D1 /* ofMainLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9979E8201A1CCC44007E55D1 /* ofMainLoop.cpp */; }; 9979E8241A1CCC44007E55D1 /* ofMainLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 9979E8211A1CCC44007E55D1 /* ofMainLoop.h */; }; @@ -207,6 +209,8 @@ 772BDF72146928600030F0EE /* ofOpenALSoundPlayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofOpenALSoundPlayer.h; sourceTree = ""; }; 92C55F86132DA7DD00EC2631 /* ofPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofPath.cpp; sourceTree = ""; }; 92C55F87132DA7DD00EC2631 /* ofPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofPath.h; sourceTree = ""; }; + 959744742809DDF70091BACA /* ofJson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofJson.h; sourceTree = ""; }; + 959744772809DE340091BACA /* ofThreadChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofThreadChannel.h; sourceTree = ""; }; 9979E81F1A1CCC44007E55D1 /* ofWindowSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofWindowSettings.h; sourceTree = ""; }; 9979E8201A1CCC44007E55D1 /* ofMainLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofMainLoop.cpp; sourceTree = ""; }; 9979E8211A1CCC44007E55D1 /* ofMainLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofMainLoop.h; sourceTree = ""; }; @@ -588,6 +592,7 @@ E4F3BAE312F4C745002D19BB /* ofConstants.h */, E4F3BAE412F4C745002D19BB /* ofFileUtils.cpp */, E4F3BAE512F4C745002D19BB /* ofFileUtils.h */, + 959744742809DDF70091BACA /* ofJson.h */, E4F3BAE612F4C745002D19BB /* ofLog.cpp */, E4F3BAE712F4C745002D19BB /* ofLog.h */, E4F3BAE812F4C745002D19BB /* ofNoise.h */, @@ -595,6 +600,7 @@ E4F3BAEA12F4C745002D19BB /* ofSystemUtils.h */, E4F3BAEB12F4C745002D19BB /* ofThread.cpp */, E4F3BAEC12F4C745002D19BB /* ofThread.h */, + 959744772809DE340091BACA /* ofThreadChannel.h */, E4F3BAED12F4C745002D19BB /* ofURLFileLoader.cpp */, E4F3BAEE12F4C745002D19BB /* ofURLFileLoader.h */, E4F3BAEF12F4C745002D19BB /* ofUtils.cpp */, @@ -663,6 +669,7 @@ E4F3BAC812F4C72F002D19BB /* ofQuaternion.h in Headers */, E4F3BACA12F4C72F002D19BB /* ofVec2f.h in Headers */, E4F3BACB12F4C72F002D19BB /* ofVec3f.h in Headers */, + 959744752809DDF70091BACA /* ofJson.h in Headers */, E4F3BACD12F4C72F002D19BB /* ofVec4f.h in Headers */, 692C298C19DC5C5500C27C5D /* ofFpsCounter.h in Headers */, E4F3BACE12F4C72F002D19BB /* ofVectorMath.h in Headers */, @@ -702,6 +709,7 @@ DACFA8E4132D09E8008D4B7A /* ofShader.h in Headers */, 676672A51A749D1900400051 /* ofAVFoundationVideoPlayer.h in Headers */, DACFA8E6132D09E8008D4B7A /* ofTexture.h in Headers */, + 959744782809DE340091BACA /* ofThreadChannel.h in Headers */, DACFA8E8132D09E8008D4B7A /* ofVbo.h in Headers */, DACFA8EA132D09E8008D4B7A /* ofVboMesh.h in Headers */, 9979E8221A1CCC44007E55D1 /* ofWindowSettings.h in Headers */, From d8f34b23f8c18fe039faf97683ace0facb0b06a4 Mon Sep 17 00:00:00 2001 From: 2bit Date: Sat, 16 Apr 2022 02:16:08 +0900 Subject: [PATCH 2/4] fix order of arguments of ofSaveJson --- libs/openFrameworks/utils/ofJson.h | 32 +++++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/libs/openFrameworks/utils/ofJson.h b/libs/openFrameworks/utils/ofJson.h index 5ff36c5b7ab..34fb0411580 100644 --- a/libs/openFrameworks/utils/ofJson.h +++ b/libs/openFrameworks/utils/ofJson.h @@ -27,22 +27,30 @@ inline ofJson ofLoadJson(const std::filesystem::path& filename){ return json; } +/// \brief Save minified Json to the given path. +/// \param json The Json to save. +/// \param filename The destination path. +/// \returns true if the json was saved successfully. +inline bool ofSaveJson(const ofJson & json, const std::filesystem::path& filename){ + ofFile jsonFile(filename, ofFile::WriteOnly); + try{ + jsonFile << json; + }catch(std::exception & e){ + ofLogError("ofSaveJson") << "Error saving json to " << filename.string() << ": " << e.what(); + return false; + }catch(...){ + ofLogError("ofSaveJson") << "Error saving json to " << filename.string(); + return false; + } + return true; +} + /// \brief Save minified Json to the given path. /// \param filename The destination path. /// \param json The Json to save. /// \returns true if the json was saved successfully. -inline bool ofSaveJson(const std::filesystem::path& filename, const ofJson & json){ - ofFile jsonFile(filename, ofFile::WriteOnly); - try{ - jsonFile << json; - }catch(std::exception & e){ - ofLogError("ofSaveJson") << "Error saving json to " << filename.string() << ": " << e.what(); - return false; - }catch(...){ - ofLogError("ofSaveJson") << "Error saving json to " << filename.string(); - return false; - } - return true; +OF_DEPRECATED_MSG("Use ofSaveJson(json, path) instead.", inline bool ofSaveJson(const std::filesystem::path& filename, const ofJson & json)){ + return ofSaveJson(json, filename); } /// \brief Save "pretty" indented Json to the given path. From b2bb22632870ec9d5ac9c0afa4157d331c08934a Mon Sep 17 00:00:00 2001 From: 2bit Date: Sat, 16 Apr 2022 02:17:52 +0900 Subject: [PATCH 3/4] fix order of arguments of ofSavePrettyJson --- libs/openFrameworks/utils/ofJson.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/utils/ofJson.h b/libs/openFrameworks/utils/ofJson.h index 34fb0411580..c1dfbf0909c 100644 --- a/libs/openFrameworks/utils/ofJson.h +++ b/libs/openFrameworks/utils/ofJson.h @@ -54,10 +54,10 @@ OF_DEPRECATED_MSG("Use ofSaveJson(json, path) instead.", inline bool ofSaveJson( } /// \brief Save "pretty" indented Json to the given path. -/// \param filename The destination path. /// \param json The Json to save. +/// \param filename The destination path. /// \returns true if the json was saved successfully. -inline bool ofSavePrettyJson(const std::filesystem::path& filename, const ofJson & json){ +inline bool ofSavePrettyJson(const ofJson & json, const std::filesystem::path& filename){ ofFile jsonFile(filename, ofFile::WriteOnly); try{ jsonFile << json.dump(4); @@ -71,6 +71,14 @@ inline bool ofSavePrettyJson(const std::filesystem::path& filename, const ofJson return true; } +/// \brief Save "pretty" indented Json to the given path. +/// \param filename The destination path. +/// \param json The Json to save. +/// \returns true if the json was saved successfully. +OF_DEPRECATED_MSG("Use ofSavePrettyJson(json, path) instead.", inline bool ofSavePrettyJson(const std::filesystem::path& filename, const ofJson & json)){ + return ofSavePrettyJson(json, filename); +} + inline void ofSerialize(ofJson & js, const ofAbstractParameter & parameter){ if(!parameter.isSerializable()){ return; From 58ea9f8422c1b3d911dc2060d0d0e262aeadcb44 Mon Sep 17 00:00:00 2001 From: 2bit Date: Sat, 16 Apr 2022 02:34:27 +0900 Subject: [PATCH 4/4] fix about deprecation macro? --- libs/openFrameworks/utils/ofJson.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/openFrameworks/utils/ofJson.h b/libs/openFrameworks/utils/ofJson.h index c1dfbf0909c..830b68be56a 100644 --- a/libs/openFrameworks/utils/ofJson.h +++ b/libs/openFrameworks/utils/ofJson.h @@ -49,7 +49,8 @@ inline bool ofSaveJson(const ofJson & json, const std::filesystem::path& filenam /// \param filename The destination path. /// \param json The Json to save. /// \returns true if the json was saved successfully. -OF_DEPRECATED_MSG("Use ofSaveJson(json, path) instead.", inline bool ofSaveJson(const std::filesystem::path& filename, const ofJson & json)){ +OF_DEPRECATED_MSG("Use ofSaveJson(json, path) instead.", inline bool ofSaveJson(const std::filesystem::path& filename, const ofJson & json)); +inline bool ofSaveJson(const std::filesystem::path& filename, const ofJson & json){ return ofSaveJson(json, filename); } @@ -75,7 +76,8 @@ inline bool ofSavePrettyJson(const ofJson & json, const std::filesystem::path& f /// \param filename The destination path. /// \param json The Json to save. /// \returns true if the json was saved successfully. -OF_DEPRECATED_MSG("Use ofSavePrettyJson(json, path) instead.", inline bool ofSavePrettyJson(const std::filesystem::path& filename, const ofJson & json)){ +OF_DEPRECATED_MSG("Use ofSavePrettyJson(json, path) instead.", inline bool ofSavePrettyJson(const std::filesystem::path& filename, const ofJson & json)); +inline bool ofSavePrettyJson(const std::filesystem::path& filename, const ofJson & json){ return ofSavePrettyJson(json, filename); }