KiCad PCB EDA Suite
Loading...
Searching...
No Matches
HTTP_LIB_CONNECTION Class Reference

#include <http_lib_connection.h>

Public Member Functions

 HTTP_LIB_CONNECTION (const HTTP_LIB_SOURCE &aSource, bool aTestConnectionNow)
 
virtual ~HTTP_LIB_CONNECTION ()=default
 
bool IsValidEndpoint () const
 
bool SelectOne (const std::string &aPartID, HTTP_LIB_PART &aFetchedPart)
 Retrieve a single part with full details from the HTTP library.
 
bool SelectAll (const HTTP_LIB_CATEGORY &aCategory, std::vector< HTTP_LIB_PART > &aParts)
 Retrieve all parts from a specific category from the HTTP library.
 
std::string GetLastError () const
 
std::vector< HTTP_LIB_CATEGORYgetCategories () const
 
std::string getCategoryDescription (const std::string &aCategoryName) const
 
auto & GetCachedParts ()
 

Static Public Attributes

static const long DEFAULT_TIMEOUT = 10
 

Private Member Functions

std::unique_ptr< KICAD_CURL_EASYcreateCurlEasyObject ()
 
bool validateHttpLibraryEndpoints ()
 
bool syncCategories ()
 
bool checkServerResponse (std::unique_ptr< KICAD_CURL_EASY > &aCurl)
 
bool boolFromString (const std::any &aVal, bool aDefaultValue=false)
 
wxString httpErrorCodeDescription (uint16_t aHttpCode)
 HTTP response status codes indicate whether a specific HTTP request has been successfully completed.
 

Private Attributes

HTTP_LIB_SOURCE m_source
 
bool m_endpointValid = false
 
std::string m_lastError
 
std::vector< HTTP_LIB_CATEGORYm_categories
 
std::map< std::string, std::string > m_categoryDescriptions
 
std::map< std::string, std::string > m_parts
 
std::map< std::string, HTTP_LIB_PARTm_cachedParts
 
std::map< std::string, std::tuple< std::string, std::string > > m_cache
 

Detailed Description

Definition at line 33 of file http_lib_connection.h.

Constructor & Destructor Documentation

◆ HTTP_LIB_CONNECTION()

HTTP_LIB_CONNECTION::HTTP_LIB_CONNECTION ( const HTTP_LIB_SOURCE & aSource,
bool aTestConnectionNow )

Definition at line 38 of file http_lib_connection.cpp.

References m_source, and validateHttpLibraryEndpoints().

◆ ~HTTP_LIB_CONNECTION()

virtual HTTP_LIB_CONNECTION::~HTTP_LIB_CONNECTION ( )
virtualdefault

Member Function Documentation

◆ boolFromString()

bool HTTP_LIB_CONNECTION::boolFromString ( const std::any & aVal,
bool aDefaultValue = false )
private

Definition at line 373 of file http_lib_connection.cpp.

Referenced by SelectOne().

◆ checkServerResponse()

bool HTTP_LIB_CONNECTION::checkServerResponse ( std::unique_ptr< KICAD_CURL_EASY > & aCurl)
private

◆ createCurlEasyObject()

std::unique_ptr< KICAD_CURL_EASY > HTTP_LIB_CONNECTION::createCurlEasyObject ( )
inlineprivate

Definition at line 79 of file http_lib_connection.h.

References m_source.

Referenced by SelectAll(), SelectOne(), syncCategories(), and validateHttpLibraryEndpoints().

◆ GetCachedParts()

auto & HTTP_LIB_CONNECTION::GetCachedParts ( )
inline

Definition at line 73 of file http_lib_connection.h.

References m_cache.

◆ getCategories()

std::vector< HTTP_LIB_CATEGORY > HTTP_LIB_CONNECTION::getCategories ( ) const
inline

Definition at line 63 of file http_lib_connection.h.

References m_categories.

◆ getCategoryDescription()

std::string HTTP_LIB_CONNECTION::getCategoryDescription ( const std::string & aCategoryName) const
inline

Definition at line 65 of file http_lib_connection.h.

References m_categoryDescriptions.

◆ GetLastError()

std::string HTTP_LIB_CONNECTION::GetLastError ( ) const
inline

Definition at line 61 of file http_lib_connection.h.

References m_lastError.

◆ httpErrorCodeDescription()

wxString HTTP_LIB_CONNECTION::httpErrorCodeDescription ( uint16_t aHttpCode)
private

HTTP response status codes indicate whether a specific HTTP request has been successfully completed.

Responses are grouped in five classes:

Definition at line 404 of file http_lib_connection.cpp.

Referenced by checkServerResponse().

◆ IsValidEndpoint()

bool HTTP_LIB_CONNECTION::IsValidEndpoint ( ) const
inline

Definition at line 41 of file http_lib_connection.h.

References m_endpointValid.

Referenced by SelectAll(), SelectOne(), and syncCategories().

◆ SelectAll()

bool HTTP_LIB_CONNECTION::SelectAll ( const HTTP_LIB_CATEGORY & aCategory,
std::vector< HTTP_LIB_PART > & aParts )

Retrieve all parts from a specific category from the HTTP library.

Parameters
aPkis the primary key of the category
aResultswill be filled with all parts in that category
Returns
true if the query succeeded and at least one part was found, false otherwise

Definition at line 296 of file http_lib_connection.cpp.

References _, createCurlEasyObject(), HTTP_LIB_PART::fields, HTTP_LIB_CATEGORY::id, HTTP_LIB_PART::id, IsValidEndpoint(), m_cache, m_lastError, m_source, HTTP_LIB_PART::name, res, and traceHTTPLib.

◆ SelectOne()

bool HTTP_LIB_CONNECTION::SelectOne ( const std::string & aPartID,
HTTP_LIB_PART & aFetchedPart )

Retrieve a single part with full details from the HTTP library.

Parameters
aPkis the primary key of the part
aResultwill contain the part if one was found
Returns
true if aResult was filled; false otherwise

Definition at line 153 of file http_lib_connection.cpp.

References _, boolFromString(), checkServerResponse(), createCurlEasyObject(), HTTP_LIB_PART::desc, HTTP_LIB_PART::exclude_from_board, HTTP_LIB_PART::exclude_from_bom, HTTP_LIB_PART::exclude_from_sim, HTTP_LIB_PART::fields, HTTP_LIB_PART::fp_filters, HTTP_LIB_PART::id, IsValidEndpoint(), HTTP_LIB_PART::keywords, HTTP_LIB_PART::lastCached, m_cachedParts, m_lastError, m_source, HTTP_LIB_PART::name, res, HTTP_LIB_PART::symbolIdStr, and traceHTTPLib.

◆ syncCategories()

◆ validateHttpLibraryEndpoints()

bool HTTP_LIB_CONNECTION::validateHttpLibraryEndpoints ( )
private

Member Data Documentation

◆ DEFAULT_TIMEOUT

const long HTTP_LIB_CONNECTION::DEFAULT_TIMEOUT = 10
static

Definition at line 36 of file http_lib_connection.h.

◆ m_cache

std::map<std::string, std::tuple<std::string, std::string> > HTTP_LIB_CONNECTION::m_cache
private

Definition at line 127 of file http_lib_connection.h.

Referenced by GetCachedParts(), and SelectAll().

◆ m_cachedParts

std::map<std::string, HTTP_LIB_PART> HTTP_LIB_CONNECTION::m_cachedParts
private

Definition at line 124 of file http_lib_connection.h.

Referenced by SelectOne().

◆ m_categories

std::vector<HTTP_LIB_CATEGORY> HTTP_LIB_CONNECTION::m_categories
private

Definition at line 119 of file http_lib_connection.h.

Referenced by getCategories(), and syncCategories().

◆ m_categoryDescriptions

std::map<std::string, std::string> HTTP_LIB_CONNECTION::m_categoryDescriptions
private

Definition at line 120 of file http_lib_connection.h.

Referenced by getCategoryDescription(), and syncCategories().

◆ m_endpointValid

bool HTTP_LIB_CONNECTION::m_endpointValid = false
private

Definition at line 116 of file http_lib_connection.h.

Referenced by IsValidEndpoint(), and validateHttpLibraryEndpoints().

◆ m_lastError

std::string HTTP_LIB_CONNECTION::m_lastError
private

◆ m_parts

std::map<std::string, std::string> HTTP_LIB_CONNECTION::m_parts
private

Definition at line 121 of file http_lib_connection.h.

◆ m_source

HTTP_LIB_SOURCE HTTP_LIB_CONNECTION::m_source
private

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