Code update?

main
anulax1225 ago%!(EXTRA string=9 months)
parent 6e01d3b23d
commit db00552d84
  1. 10
      src/bakatools/json/fs_manager.cpp
  2. 4
      src/bakatools/json/fs_manager.h
  3. 2
      src/bakatools/json/lexer.cpp
  4. 2
      src/bakatools/json/lexer.h
  5. 48
      src/bakatools/json/node.cpp
  6. 4
      src/bakatools/json/node.h
  7. 2
      src/bakatools/logging/log.cpp
  8. 2
      src/bakatools/logging/log.h

@ -29,7 +29,7 @@ namespace Bk::Json
} }
} }
void FsManager::config_init(int page_size) void FsManager::config_Init(int page_size)
{ {
auto dir = Directory(path); auto dir = Directory(path);
std::string s_config = "\n" std::string s_config = "\n"
@ -42,7 +42,7 @@ namespace Bk::Json
write_config(); write_config();
} }
void FsManager::init(bool force, int page_size) void FsManager::Init(bool force, int page_size)
{ {
auto dir = Directory(path); auto dir = Directory(path);
@ -50,14 +50,14 @@ namespace Bk::Json
if (!dir.exists()) if (!dir.exists())
{ {
Directory::create(dir.path()); Directory::create(dir.path());
config_init(page_size); config_Init(page_size);
} }
else else
{ {
File f_conf(path + "/collection.json"); File f_conf(path + "/collection.json");
if (!f_conf.exists()) if (!f_conf.exists())
{ {
config_init(page_size); config_Init(page_size);
} }
} }
} }
@ -71,7 +71,7 @@ namespace Bk::Json
void FsManager::write(File file, Pointer& node) void FsManager::write(File file, Pointer& node)
{ {
Type::DataStream data; Type::DataStream data;
auto raw = node->to_string(); auto raw = node->ToString();
data.push<char>(raw.c_str(), raw.length()); data.push<char>(raw.c_str(), raw.length());
file.write(data); file.write(data);
} }

@ -13,8 +13,8 @@ namespace Bk::Json
public: public:
FsManager(std::string path); FsManager(std::string path);
void init(bool force = false, int page_size = 100); void Init(bool force = false, int page_size = 100);
void config_init(int page_size); void config_Init(int page_size);
bool exists() { return File(path + "/collection.json").exists(); } bool exists() { return File(path + "/collection.json").exists(); }
void erase() { Directory(path).remove(); } void erase() { Directory(path).remove(); }

@ -2,7 +2,7 @@
namespace Bk::Json namespace Bk::Json
{ {
std::string Token::to_string() std::string Token::ToString()
{ {
return Tools::string_format("%s %d", this->value, (int)this->type); return Tools::string_format("%s %d", this->value, (int)this->type);
} }

@ -27,7 +27,7 @@ namespace Bk::Json
std::string value; std::string value;
TokenType type = TokenType::NULL_TYPE; TokenType type = TokenType::NULL_TYPE;
std::string to_string(); std::string ToString();
}; };
class Lexer class Lexer

@ -1,29 +1,29 @@
#include "node.h" #include "node.h"
namespace Bk::Json namespace Bk::Json
{ {
// Node::~Node() Node::~Node()
// { {
// switch(type) switch(type)
// { {
// case Type::OBJECT: case Type::OBJECT:
// { {
// delete values.object; delete values.object;
// break; break;
// } }
// case Type::LIST: case Type::LIST:
// { {
// delete values.list; delete values.list;
// break; break;
// } }
// case Type::STRING: case Type::STRING:
// { {
// delete values.s; delete values.s;
// break; break;
// } }
// } }
// } }
std::string Node::to_string(int indent) std::string Node::ToString(int indent)
{ {
std::string space_string = std::string(indent, ' '); std::string space_string = std::string(indent, ' ');
std::string output_string = ""; std::string output_string = "";
@ -54,7 +54,7 @@ namespace Bk::Json
output_string += space_string + "[\n"; output_string += space_string + "[\n";
for (int i = 0; i < (*values.list).size(); i++) for (int i = 0; i < (*values.list).size(); i++)
{ {
output_string += get_list()[i]->to_string(indent + 4); output_string += get_list()[i]->ToString(indent + 4);
if (i < (*values.list).size() - 1) if (i < (*values.list).size() - 1)
{ {
output_string += ",\n"; output_string += ",\n";
@ -69,7 +69,7 @@ namespace Bk::Json
for (Object::iterator i = (*values.object).begin(); i != (*values.object).end(); i++) for (Object::iterator i = (*values.object).begin(); i != (*values.object).end(); i++)
{ {
output_string += space_string + " " + "\"" + i->first + "\"" + ": "; output_string += space_string + " " + "\"" + i->first + "\"" + ": ";
output_string += i->second->to_string(indent + 4); output_string += i->second->ToString(indent + 4);
Object::iterator next = i; Object::iterator next = i;
next++; next++;
if ((next) != (*values.object).end()) if ((next) != (*values.object).end())

@ -23,7 +23,7 @@ namespace Bk::Json
NULL_TYPE NULL_TYPE
}; };
//~Node(); ~Node();
Type get_type() { return type; } Type get_type() { return type; }
bool is_type(Type type) { return type == this->type; } bool is_type(Type type) { return type == this->type; }
@ -52,7 +52,7 @@ namespace Bk::Json
void set_null(); void set_null();
bool is_null(); bool is_null();
std::string to_string(int indent = 0); std::string ToString(int indent = 0);
private: private:
union Values { union Values {

@ -5,7 +5,7 @@ namespace Bk {
std::shared_ptr<spdlog::logger> Log::p_core_logger; std::shared_ptr<spdlog::logger> Log::p_core_logger;
std::shared_ptr<spdlog::logger> Log::p_app_logger; std::shared_ptr<spdlog::logger> Log::p_app_logger;
void Log::init(std::string core, bool file_log) void Log::Init(std::string core, bool file_log)
{ {
std::vector<spdlog::sink_ptr> log_sinks; std::vector<spdlog::sink_ptr> log_sinks;
log_sinks.emplace_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>()); log_sinks.emplace_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>());

@ -10,7 +10,7 @@ namespace Bk {
class Log class Log
{ {
public: public:
static void init(std::string core, bool file_log = false); static void Init(std::string core, bool file_log = false);
static std::shared_ptr<spdlog::logger>& get_core_logger() { return p_core_logger; } static std::shared_ptr<spdlog::logger>& get_core_logger() { return p_core_logger; }
static std::shared_ptr<spdlog::logger>& get_app_logger() { return p_app_logger; } static std::shared_ptr<spdlog::logger>& get_app_logger() { return p_app_logger; }

Loading…
Cancel
Save