Skip to content

Commit

Permalink
fix a pointer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yudonglin committed Jan 26, 2024
1 parent 04bc15f commit 27b8171
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
18 changes: 18 additions & 0 deletions vns-cpp/naming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ std::unordered_set<std::string> Naming::GetTags() const
return tags_;
}

// If contains a tag
bool Naming::ContainsTag(const std::string& tag) const
{
return tags_.contains(tag);
}

// Insert a tag
void Naming::InsertTag(const std::string& tag)
{
tags_.insert(tag);
}

// Erase a tag
void Naming::EraseTag(const std::string& tag)
{
tags_.erase(tag);
}

// Check if two Naming objects or a Naming object and a string refer to the same character
bool Naming::Equal(const std::variant<Naming, std::string>& o, const bool must_be_the_same) const
{
Expand Down
3 changes: 3 additions & 0 deletions vns-cpp/naming.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Naming
[[nodiscard]] std::string ToString() const;
[[nodiscard]] std::string GetName() const;
[[nodiscard]] std::unordered_set<std::string> GetTags() const;
[[nodiscard]] bool ContainsTag(const std::string&) const;
void InsertTag(const std::string&);
void EraseTag(const std::string&);
// Class method to access the database
static std::unordered_map<std::string, std::vector<std::string>>& GetDatabase()
{
Expand Down
6 changes: 3 additions & 3 deletions vns-cpp/processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,14 @@ void Processor::convert(int starting_index)
if (std::find(narrator_possible_images.begin(), narrator_possible_images.end(), name_data.GetName()) !=
narrator_possible_images.end())
{
if (name_data.GetTags().contains("silent"))
if (name_data.ContainsTag("silent"))
{
name_data.GetTags().erase("silent");
name_data.EraseTag("silent");
}
}
else
{
name_data.GetTags().insert("silent");
name_data.InsertTag("silent");
}
current_data_.character_images[i] = name_data.ToString();
}
Expand Down

0 comments on commit 27b8171

Please sign in to comment.