Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
2a431f6
Added work-in-progress StorageFile class
EmmmaTech Mar 9, 2021
27331d7
Added method to get appname from i18n
EmmmaTech Mar 9, 2021
c68122a
Changed the config_folder variable slightly
EmmmaTech Mar 9, 2021
d460c04
Removed nlohmann json dependence
EmmmaTech Mar 9, 2021
55d6761
Added init function
EmmmaTech Mar 9, 2021
c9c9429
Added a macro and work-in-progress writeToFile function
EmmmaTech Mar 9, 2021
78a78f1
Added readToFile function
EmmmaTech Mar 9, 2021
c58f2bb
Starting to use tinyxml2 for the file writing and reading
EmmmaTech Mar 9, 2021
1e3a038
Added small examples to the documentation comments
EmmmaTech Mar 9, 2021
8682a6a
Finished the readToFile function
EmmmaTech Mar 10, 2021
3b7ecbc
Added more macros, changed function name
EmmmaTech Mar 10, 2021
01e92a7
Forgot the include for the class in borealis.hpp
EmmmaTech Mar 10, 2021
4a6098f
Added example of StorageFile (might be removed before merge)
EmmmaTech Mar 10, 2021
96373d7
Added an example save function to save changes
EmmmaTech Mar 10, 2021
a34bdbb
Finished the writeToFile function
EmmmaTech Mar 10, 2021
656031c
Added check if the type if std::string
EmmmaTech Mar 10, 2021
5778836
Added some error checking
EmmmaTech Mar 10, 2021
934f5a4
Fixed compiler errors
EmmmaTech Mar 10, 2021
7b7d7b3
Few adjustments
EmmmaTech Mar 10, 2021
ea8d4cc
Fixed segementation fault
EmmmaTech Mar 10, 2021
7f1e4c8
Sigh... another Segementation Fault
EmmmaTech Mar 10, 2021
bf6b8f4
Rewriting this idea with StorageObjects
EmmmaTech Mar 10, 2021
c85c6e8
Starting to work off a new idea
EmmmaTech Mar 10, 2021
47ae49a
Added new readFromFile function
EmmmaTech Mar 10, 2021
7d0c907
Starting to reimplement writeToFile
EmmmaTech Mar 10, 2021
c7bd651
writeToFile should work now
EmmmaTech Mar 10, 2021
0d9a20f
writeToFile finished and fixed compiler errors
EmmmaTech Mar 10, 2021
68ff3c5
New macro
EmmmaTech Mar 10, 2021
a3aeadd
Supported making blank StorageObjects
EmmmaTech Mar 10, 2021
d8c506d
Added isFileEmpty function
EmmmaTech Mar 10, 2021
56d70a1
Fixed a few more compiler errors
EmmmaTech Mar 10, 2021
72c7cae
Fixed what could've been a compiler error
EmmmaTech Mar 10, 2021
05beba3
Added parseXMLToVector function
EmmmaTech Mar 10, 2021
fc5b931
Found a way to convert char * to another type
EmmmaTech Mar 10, 2021
40c4dc8
Changing up the example
EmmmaTech Mar 10, 2021
a392c43
Reworked charToOther and otherToChar functions
EmmmaTech Mar 11, 2021
18d754d
Fixed up everything to remove runtime problems
EmmmaTech Mar 11, 2021
5680322
Starting to simpilfiy the whole StorageFile proccess
EmmmaTech Mar 12, 2021
322a6e8
writeToFile will now overwrite
EmmmaTech Mar 12, 2021
aa1f87d
Removed some debugging and unused code
EmmmaTech Mar 12, 2021
81f74d2
Added a new StorageFile Demo
EmmmaTech Mar 14, 2021
bf5cdb1
[UNTESTED] - Added a new way to detect an empty file
EmmmaTech Mar 15, 2021
7fcc22f
Demo - Added a second value to be added/read
EmmmaTech Mar 16, 2021
e9f23af
General - Added brls::ListStorageObject
EmmmaTech Mar 20, 2021
66abacd
Util - Added conversion method
EmmmaTech Mar 21, 2021
e560e91
Demo - Added example of the conversion functions
EmmmaTech Mar 21, 2021
9b5b28e
Storage_File.hpp - New formatting
EmmmaTech Mar 22, 2021
6472824
ListStorageObject - Support for Range-based for loops
EmmmaTech Mar 24, 2021
fbb9082
StorageFile - Added << and >> functions
EmmmaTech Mar 25, 2021
e13bd23
Storage_File.hpp - Moved source to Storage_File.cpp
EmmmaTech Mar 25, 2021
c74bf03
Merge remote-tracking branch 'upstream/main' into main
EmmmaTech Mar 26, 2021
9b31029
clang-format
EmmmaTech Mar 26, 2021
6baccb8
Storage File - Removed ifndef __SWITCH__
EmmmaTech Mar 30, 2021
e518717
BasicStorageFile - Added file exists check for reading functions
EmmmaTech Mar 31, 2021
9475b2a
BasicStorageFile - Fixed build on Switch
EmmmaTech Apr 3, 2021
26dff7c
Merge remote-tracking branch 'upstream/main' into main
EmmmaTech Apr 5, 2021
9a3b98b
Merge branch 'natinusala:main' into main
EmmmaTech Jul 19, 2021
30e0e68
Cleaning up code
EmmmaTech Aug 9, 2021
00791ad
Rewriting code
EmmmaTech Aug 10, 2021
ae9ce77
Added ListStorageObject
EmmmaTech Nov 6, 2021
ee18393
Fixed problem with demo of ListStorageObject
EmmmaTech Nov 6, 2021
251c1bf
Fixed up the demo
EmmmaTech Nov 6, 2021
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.*/
build/
build.nx/
config/
*~
*.bak
*.nro
Expand All @@ -9,3 +10,4 @@ build.nx/
.vscode
builddir
*.dksh
.DS_Store
2 changes: 2 additions & 0 deletions demo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "components_tab.hpp"
#include "main_activity.hpp"
#include "recycling_list_tab.hpp"
#include "storage_file_demo.hpp"

using namespace brls::literals; // for _i18n

Expand Down Expand Up @@ -60,6 +61,7 @@ int main(int argc, char* argv[])
brls::Application::registerXMLView("CaptionedImage", CaptionedImage::create);
brls::Application::registerXMLView("RecyclingListTab", RecyclingListTab::create);
brls::Application::registerXMLView("ComponentsTab", ComponentsTab::create);
brls::Application::registerXMLView("StorageFileDemo", StorageFileDemo::create);

// Add custom values to the theme
brls::getLightTheme().addColor("captioned_image/caption", nvgRGB(2, 176, 183));
Expand Down
29 changes: 29 additions & 0 deletions demo/settings_file.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2021 EmreTech

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#pragma once

#include <borealis.hpp>

struct SettingsFile : public brls::StorageFile
{
BRLS_STORAGE_FILE_INIT(SettingsFile, "settings", "borealis_demo")

BRLS_STORAGE_BOOL(boolTest, "boolTest");
BRLS_STORAGE_STRING(username, "username");

BRLS_STORAGE_STRING_LIST(favoriteWords, "favoriteWords");
BRLS_STORAGE_INT_LIST(coolNumbers, "coolNumbers");
};
82 changes: 82 additions & 0 deletions demo/storage_file_demo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
Copyright 2021 EmreTech

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Note: This file, it's header counterpart, and any other files relating to the Storage File Demo can be taken down at demand.
// They are only here for testing purposes.

#include "storage_file_demo.hpp"

StorageFileDemo::StorageFileDemo()
{
this->inflateFromXMLRes("xml/tabs/storage_file.xml");

BRLS_REGISTER_CLICK_BY_ID("writeData", this->onWriteDataButtonPressed);
BRLS_REGISTER_CLICK_BY_ID("readData", this->onReadDataButtonPressed);
}

bool StorageFileDemo::onWriteDataButtonPressed(brls::View* view)
{
// Clear data in ListStorageObjects to ensure we aren't writting multiple items into the file
settings->favoriteWords.getVector().clear();
settings->coolNumbers.getVector().clear();

// Set values
settings->boolTest = true;
settings->username = "EmreTech";
settings->favoriteWords.pushValue("Hello");
settings->favoriteWords.pushValue("Watermelon");

for (int i = 1; i < 11; i++)
settings->coolNumbers.pushValue(i);

// Save
settings->boolTest.save();
settings->username.save();
settings->favoriteWords.save();
settings->coolNumbers.save();

verboseText->setText("Sucessfully written data to the Storage File.");

return true;
}

bool StorageFileDemo::onReadDataButtonPressed(brls::View* view)
{
// Read data from the file
settings->readFromFile("boolTest", settings->boolTest);
settings->readFromFile("username", settings->username);
settings->readFromFile("favoriteWords", settings->favoriteWords);
settings->readFromFile("coolNumbers", settings->coolNumbers);

// Print out the values to the user
brls::Logger::info("Read from file: boolTest: {}", settings->boolTest.getValue());
brls::Logger::info("Read from file: username: {}", settings->username.getValue());

for (size_t i{0}; i < settings->favoriteWords.size(); i++)
brls::Logger::info("Read from file: favoriteWords index #{}: {}", i, settings->favoriteWords.getValue(i));

for (size_t i{0}; i < settings->coolNumbers.size(); i++)
brls::Logger::info("Read from file: coolNumbers index #{}: {}", i, settings->coolNumbers.getValue(i));

verboseText->setText("Please read the console log for the read data.");

return true;
}

brls::View* StorageFileDemo::create()
{
return new StorageFileDemo();
}
41 changes: 41 additions & 0 deletions demo/storage_file_demo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright 2021 EmreTech

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Note: This file, it's source counterpart, and any other files relating to the Storage File Demo can be taken down at demand.
// They are only here for testing purposes.

#pragma once

#include <borealis.hpp>
#include <iostream>
#include <string>

#include "settings_file.hpp"

struct StorageFileDemo : public brls::Box
{
StorageFileDemo();

static brls::View* create();

private:
bool onWriteDataButtonPressed(brls::View* view);
bool onReadDataButtonPressed(brls::View* view);

BRLS_BIND(brls::Label, verboseText, "verboseText");

SettingsFile *settings = new SettingsFile();
};
2 changes: 2 additions & 0 deletions library/include/borealis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@
#include <borealis/core/input.hpp>
#include <borealis/core/logger.hpp>
#include <borealis/core/platform.hpp>
#include <borealis/core/storage_file.hpp>
#include <borealis/core/style.hpp>
#include <borealis/core/task.hpp>
#include <borealis/core/theme.hpp>
#include <borealis/core/time.hpp>
#include <borealis/core/timer.hpp>
#include <borealis/core/util.hpp>
#include <borealis/core/video.hpp>
#include <borealis/core/view.hpp>

Expand Down
Loading