LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
config::FieldTranslator Class Reference

Manages field dictionary and conversions based on JSON configuration. More...

#include <FieldTranslator.hpp>

Collaboration diagram for config::FieldTranslator:
Collaboration graph

Public Member Functions

 FieldTranslator ()
 
 ~FieldTranslator ()=default
 
util::Result< void, error::Error > LoadFromFile (const std::string &filePath)
 Load dictionary from JSON file.
 
bool HasTranslation (std::string_view key) const
 Check if a field has a dictionary entry configured.
 
TranslationResult Translate (std::string_view key, std::string_view value) const
 Apply dictionary lookup/conversion to a field value.
 
const std::map< std::string, FieldDictionary > & GetAllTranslations () const
 Get all dictionary entries.
 
bool SaveToFile (const std::string &filePath) const
 Save dictionary to JSON file.
 
void SetTranslation (const FieldDictionary &translation)
 Add or update a dictionary entry.
 
void RemoveTranslation (const std::string &key)
 Remove a dictionary entry.
 

Private Member Functions

std::string FormatTooltip (const std::string &templateStr, std::string_view original, std::string_view converted) const
 
std::string ToLower (std::string_view str) const
 
void RebuildLowercaseCache () const
 

Private Attributes

std::map< std::string, std::string > m_lowercaseKeyCache
 
std::map< std::string, FieldDictionary > m_dictionary
 

Detailed Description

Manages field dictionary and conversions based on JSON configuration.

Constructor & Destructor Documentation

◆ FieldTranslator()

config::FieldTranslator::FieldTranslator ( )

◆ ~FieldTranslator()

config::FieldTranslator::~FieldTranslator ( )
default

Member Function Documentation

◆ FormatTooltip()

std::string config::FieldTranslator::FormatTooltip ( const std::string &  templateStr,
std::string_view  original,
std::string_view  converted 
) const
private
Here is the caller graph for this function:

◆ GetAllTranslations()

const std::map< std::string, FieldDictionary > & config::FieldTranslator::GetAllTranslations ( ) const

Get all dictionary entries.

Returns
Map of all field dictionary entries
Here is the caller graph for this function:

◆ HasTranslation()

bool config::FieldTranslator::HasTranslation ( std::string_view  key) const

Check if a field has a dictionary entry configured.

Parameters
keyThe field key name
Returns
true if dictionary entry exists for this key
Here is the call graph for this function:

◆ LoadFromFile()

util::Result< void, error::Error > config::FieldTranslator::LoadFromFile ( const std::string &  filePath)

Load dictionary from JSON file.

Parameters
filePathPath to the dictionary JSON file
Returns
Ok({}) on success, Err with details on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RebuildLowercaseCache()

void config::FieldTranslator::RebuildLowercaseCache ( ) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveTranslation()

void config::FieldTranslator::RemoveTranslation ( const std::string &  key)

Remove a dictionary entry.

Parameters
keyThe field key to remove
Here is the call graph for this function:

◆ SaveToFile()

bool config::FieldTranslator::SaveToFile ( const std::string &  filePath) const

Save dictionary to JSON file.

Parameters
filePathPath to save the dictionary JSON file
Returns
true if saved successfully
Here is the call graph for this function:

◆ SetTranslation()

void config::FieldTranslator::SetTranslation ( const FieldDictionary &  translation)

Add or update a dictionary entry.

Parameters
translationThe dictionary entry to add/update
Here is the call graph for this function:

◆ ToLower()

std::string config::FieldTranslator::ToLower ( std::string_view  str) const
private
Here is the caller graph for this function:

◆ Translate()

TranslationResult config::FieldTranslator::Translate ( std::string_view  key,
std::string_view  value 
) const

Apply dictionary lookup/conversion to a field value.

Parameters
keyThe field key name
valueThe original value
Returns
TranslationResult with converted value and tooltip
Here is the call graph for this function:

Member Data Documentation

◆ m_dictionary

std::map<std::string, FieldDictionary> config::FieldTranslator::m_dictionary
private

◆ m_lowercaseKeyCache

std::map<std::string, std::string> config::FieldTranslator::m_lowercaseKeyCache
mutableprivate

The documentation for this class was generated from the following files: