Skip to content

Commit

Permalink
allow empty naming database
Browse files Browse the repository at this point in the history
  • Loading branch information
yudonglin committed Feb 5, 2024
1 parent 3f61b80 commit e62ae97
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vns-cpp/naming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ std::string Naming::get_database_as_json()
return json_map.dump();
}

bool Naming::empty_database()
{
return DATABASE_.empty();
}

// update database
void Naming::update_database(std::string &database_str)
{
Expand Down
2 changes: 2 additions & 0 deletions vns-cpp/naming.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Naming

static std::string get_database_as_json();

static bool empty_database();

static void update_database(std::string &);

static void update_database(const std::unordered_map<std::string, std::unordered_set<std::string>> &);
Expand Down
6 changes: 6 additions & 0 deletions vns-python/pyvns/naming.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ cdef extern from "vns-cpp/naming.h":
@staticmethod
string get_database_as_json()
@staticmethod
bool empty_database()
@staticmethod
void update_database(string &)

# Wrapper class for Naming
Expand Down Expand Up @@ -74,6 +76,10 @@ cdef class PyNaming:
def get_database_as_json() -> str:
return Naming.get_database_as_json().decode('utf-8')

@staticmethod
def clear_database(dict data):
Naming.empty_database()

@staticmethod
def update_database(dict data):
Naming.update_database(json.dumps(data).encode('utf-8', errors='strict'))

0 comments on commit e62ae97

Please sign in to comment.