Leosac  0.8.0
Open Source Access Control
Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName > Struct Template Reference

This is a templated class that perform case-insensitive database search against entities. More...

#include <SearchBase.hpp>

Classes

struct  DatabaseEntityComparator
 

Public Types

using Query = odb::query< DatabaseEntity >
 
using EntitySet = std::set< DatabaseEntity, DatabaseEntityComparator >
 

Public Member Functions

std::vector< DatabaseEntity > search (DBPtr db, const std::string &partial_name_or_alias)
 
json search_json (DBPtr db, const std::string &partial)
 Returns a JSON array with the result from the search. More...
 

Private Member Functions

template<typename T >
std::enable_if_t< std::is_same< T, use_alias_tag >::value, Querybuild_query (const std::string &partial)
 
template<typename T >
std::enable_if_t< std::is_same< T, use_name_tag >::value, Querybuild_query (const std::string &partial)
 
template<typename T >
std::enable_if_t< std::is_same< T, use_username_tag >::value, Querybuild_query (const std::string &partial)
 
void search_and_append (DBPtr db, EntitySet &entities, const std::string &partial)
 
template<typename T >
std::enable_if_t< std::is_same< T, use_alias_tag >::value, jsonbuild_json_entry (const DatabaseEntity entity)
 
template<typename T >
std::enable_if_t< std::is_same< T, use_name_tag >::value, jsonbuild_json_entry (const DatabaseEntity entity)
 
template<typename T >
std::enable_if_t< std::is_same< T, use_username_tag >::value, jsonbuild_json_entry (const DatabaseEntity entity)
 

Detailed Description

template<typename DatabaseEntity, typename AliasOrName>
struct Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >

This is a templated class that perform case-insensitive database search against entities.

It can be used to implemented the various search.* API endpoints.

Definition at line 61 of file SearchBase.hpp.

Member Typedef Documentation

◆ EntitySet

template<typename DatabaseEntity , typename AliasOrName >
using Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >::EntitySet = std::set<DatabaseEntity, DatabaseEntityComparator>

Definition at line 78 of file SearchBase.hpp.

◆ Query

template<typename DatabaseEntity , typename AliasOrName >
using Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >::Query = odb::query<DatabaseEntity>

Definition at line 64 of file SearchBase.hpp.

Member Function Documentation

◆ build_json_entry() [1/3]

template<typename DatabaseEntity , typename AliasOrName >
template<typename T >
std::enable_if_t<std::is_same<T, use_alias_tag>::value, json> Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >::build_json_entry ( const DatabaseEntity  entity)
inlineprivate

Definition at line 140 of file SearchBase.hpp.

◆ build_json_entry() [2/3]

template<typename DatabaseEntity , typename AliasOrName >
template<typename T >
std::enable_if_t<std::is_same<T, use_name_tag>::value, json> Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >::build_json_entry ( const DatabaseEntity  entity)
inlineprivate

Definition at line 148 of file SearchBase.hpp.

◆ build_json_entry() [3/3]

template<typename DatabaseEntity , typename AliasOrName >
template<typename T >
std::enable_if_t<std::is_same<T, use_username_tag>::value, json> Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >::build_json_entry ( const DatabaseEntity  entity)
inlineprivate

Definition at line 156 of file SearchBase.hpp.

◆ build_query() [1/3]

template<typename DatabaseEntity , typename AliasOrName >
template<typename T >
std::enable_if_t<std::is_same<T, use_alias_tag>::value, Query> Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >::build_query ( const std::string &  partial)
inlineprivate

Definition at line 83 of file SearchBase.hpp.

◆ build_query() [2/3]

template<typename DatabaseEntity , typename AliasOrName >
template<typename T >
std::enable_if_t<std::is_same<T, use_name_tag>::value, Query> Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >::build_query ( const std::string &  partial)
inlineprivate

Definition at line 91 of file SearchBase.hpp.

◆ build_query() [3/3]

template<typename DatabaseEntity , typename AliasOrName >
template<typename T >
std::enable_if_t<std::is_same<T, use_username_tag>::value, Query> Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >::build_query ( const std::string &  partial)
inlineprivate

Definition at line 99 of file SearchBase.hpp.

◆ search()

template<typename DatabaseEntity , typename AliasOrName >
std::vector<DatabaseEntity> Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >::search ( DBPtr  db,
const std::string &  partial_name_or_alias 
)
inline

Definition at line 116 of file SearchBase.hpp.

◆ search_and_append()

template<typename DatabaseEntity , typename AliasOrName >
void Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >::search_and_append ( DBPtr  db,
EntitySet entities,
const std::string &  partial 
)
inlineprivate

Definition at line 105 of file SearchBase.hpp.

◆ search_json()

template<typename DatabaseEntity , typename AliasOrName >
json Leosac::Module::WebSockAPI::EntitySearchTool< DatabaseEntity, AliasOrName >::search_json ( DBPtr  db,
const std::string &  partial 
)
inline

Returns a JSON array with the result from the search.

The JSON looks like this: [ {id: ${ENTITY_ID}}, {name|alias|username: ${ENTITY_NAME_OR_ALIAS}} ]

Definition at line 171 of file SearchBase.hpp.


The documentation for this struct was generated from the following file: