src: converted NodeType to a class
NodeType internally still uses the Type enum
This commit is contained in:
@@ -16,7 +16,7 @@ SearchIndex::~SearchIndex()
|
||||
{
|
||||
}
|
||||
|
||||
void SearchIndex::addNode(Id id, const std::string& name, Node::NodeTypeMask type)
|
||||
void SearchIndex::addNode(Id id, const std::string& name, NodeType::TypeMask type)
|
||||
{
|
||||
SearchNode* currentNode = m_root;
|
||||
|
||||
@@ -100,7 +100,7 @@ void SearchIndex::clear()
|
||||
}
|
||||
|
||||
std::vector<SearchResult> SearchIndex::search(
|
||||
const std::string& query, Node::NodeTypeMask filter, size_t maxResultCount, size_t maxBestScoredResultsLength) const
|
||||
const std::string& query, NodeType::TypeMask filter, size_t maxResultCount, size_t maxBestScoredResultsLength) const
|
||||
{
|
||||
// find paths containing query
|
||||
SearchPath startPath;
|
||||
@@ -147,7 +147,7 @@ void SearchIndex::populateEdgeGate(SearchEdge* e)
|
||||
}
|
||||
|
||||
void SearchIndex::searchRecursive(
|
||||
const SearchPath& path, const std::string& remainingQuery, Node::NodeTypeMask filter,
|
||||
const SearchPath& path, const std::string& remainingQuery, NodeType::TypeMask filter,
|
||||
std::vector<SearchIndex::SearchPath>* results) const
|
||||
{
|
||||
if (remainingQuery.size() == 0 && (!filter || (path.node->mask & filter)))
|
||||
@@ -197,7 +197,7 @@ void SearchIndex::searchRecursive(
|
||||
}
|
||||
|
||||
std::multiset<SearchResult> SearchIndex::createScoredResults(
|
||||
const std::vector<SearchPath>& paths, Node::NodeTypeMask filter, size_t maxResultCount) const
|
||||
const std::vector<SearchPath>& paths, NodeType::TypeMask filter, size_t maxResultCount) const
|
||||
{
|
||||
// score and order initial paths
|
||||
std::multimap<int, SearchPath, std::greater<int>> scoredPaths;
|
||||
|
||||
@@ -30,13 +30,13 @@ public:
|
||||
SearchIndex();
|
||||
virtual ~SearchIndex();
|
||||
|
||||
void addNode(Id id, const std::string& name, Node::NodeTypeMask type = 0);
|
||||
void addNode(Id id, const std::string& name, NodeType::TypeMask type = 0);
|
||||
void finishSetup();
|
||||
void clear();
|
||||
|
||||
// maxResultCount == 0 means "no restriction".
|
||||
std::vector<SearchResult> search(
|
||||
const std::string& query, Node::NodeTypeMask filter, size_t maxResultCount, size_t maxBestScoredResultsLength = 0) const;
|
||||
const std::string& query, NodeType::TypeMask filter, size_t maxResultCount, size_t maxBestScoredResultsLength = 0) const;
|
||||
|
||||
private:
|
||||
struct SearchEdge;
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
struct SearchNode
|
||||
{
|
||||
std::set<Id> elementIds;
|
||||
Node::NodeTypeMask mask = 0;
|
||||
NodeType::TypeMask mask = 0;
|
||||
std::map<char, SearchEdge*> edges;
|
||||
};
|
||||
|
||||
@@ -63,11 +63,11 @@ private:
|
||||
};
|
||||
|
||||
void populateEdgeGate(SearchEdge* e);
|
||||
void searchRecursive(const SearchPath& path, const std::string& remainingQuery, Node::NodeTypeMask filter,
|
||||
void searchRecursive(const SearchPath& path, const std::string& remainingQuery, NodeType::TypeMask filter,
|
||||
std::vector<SearchIndex::SearchPath>* results) const;
|
||||
|
||||
std::multiset<SearchResult> createScoredResults(
|
||||
const std::vector<SearchPath>& paths, Node::NodeTypeMask filter, size_t maxResultCount) const;
|
||||
const std::vector<SearchPath>& paths, NodeType::TypeMask filter, size_t maxResultCount) const;
|
||||
|
||||
static SearchResult bestScoredResult(
|
||||
SearchResult result, std::map<std::string, SearchResult>* scoresCache, size_t maxBestScoredResultsLength);
|
||||
|
||||
@@ -56,20 +56,20 @@ SearchMatch SearchMatch::createCommand(CommandType type)
|
||||
return match;
|
||||
}
|
||||
|
||||
std::vector<SearchMatch> SearchMatch::createCommandsForFilter(Node::NodeTypeMask filter)
|
||||
std::vector<SearchMatch> SearchMatch::createCommandsForFilter(NodeType::TypeMask filter)
|
||||
{
|
||||
std::vector<SearchMatch> matches;
|
||||
|
||||
for (Node::NodeTypeMask type = 1; type <= filter; type *= 2)
|
||||
for (NodeType::TypeMask type = 1; type <= filter; type *= 2)
|
||||
{
|
||||
if (type & filter)
|
||||
{
|
||||
SearchMatch match;
|
||||
match.name = Node::getReadableTypeString(Node::intToType(type));
|
||||
match.name = NodeType(utility::intToType(type)).getReadableTypeString();
|
||||
match.text = match.name;
|
||||
match.typeName = "filter";
|
||||
match.searchType = SEARCH_COMMAND;
|
||||
match.nodeType = Node::intToType(type);
|
||||
match.nodeType = NodeType(utility::intToType(type));
|
||||
matches.push_back(match);
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ std::string SearchMatch::getCommandName(CommandType type)
|
||||
|
||||
SearchMatch::SearchMatch()
|
||||
: typeName("")
|
||||
, nodeType(Node::NODE_NON_INDEXED)
|
||||
, nodeType(NodeType::NODE_NON_INDEXED)
|
||||
, searchType(SEARCH_NONE)
|
||||
, hasChildren(false)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ SearchMatch::SearchMatch(const std::string& query)
|
||||
: name(query)
|
||||
, text(query)
|
||||
, typeName("")
|
||||
, nodeType(Node::NODE_NON_INDEXED)
|
||||
, nodeType(NodeType::NODE_NON_INDEXED)
|
||||
, searchType(SEARCH_NONE)
|
||||
, hasChildren(false)
|
||||
{
|
||||
@@ -224,7 +224,7 @@ void SearchMatch::print(std::ostream& ostream) const
|
||||
|
||||
std::string SearchMatch::getFullName() const
|
||||
{
|
||||
if (searchType == SEARCH_TOKEN && nodeType == Node::NODE_FILE)
|
||||
if (searchType == SEARCH_TOKEN && nodeType.getType() == NodeType::NODE_FILE)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
@@ -234,7 +234,7 @@ std::string SearchMatch::getFullName() const
|
||||
|
||||
std::string SearchMatch::getNodeTypeAsUnderscoredString() const
|
||||
{
|
||||
return Node::getUnderscoredTypeString(nodeType);
|
||||
return nodeType.getUnderscoredTypeString();
|
||||
}
|
||||
|
||||
std::string SearchMatch::getSearchTypeName() const
|
||||
|
||||
@@ -34,7 +34,7 @@ struct SearchMatch
|
||||
static std::string searchMatchesToString(const std::vector<SearchMatch>& matches);
|
||||
|
||||
static SearchMatch createCommand(CommandType type);
|
||||
static std::vector<SearchMatch> createCommandsForFilter(Node::NodeTypeMask filter);
|
||||
static std::vector<SearchMatch> createCommandsForFilter(NodeType::TypeMask filter);
|
||||
static std::string getCommandName(CommandType type);
|
||||
|
||||
static const char FULLTEXT_SEARCH_CHARACTER = '?';
|
||||
@@ -67,7 +67,7 @@ struct SearchMatch
|
||||
|
||||
std::string typeName;
|
||||
|
||||
Node::NodeType nodeType;
|
||||
NodeType nodeType;
|
||||
SearchType searchType;
|
||||
std::vector<size_t> indices;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user