KiCad PCB EDA Suite
Loading...
Searching...
No Matches
database_connection.cpp File Reference
#include <algorithm>
#include <boost/algorithm/string.hpp>
#include <boost/locale.hpp>
#include <fmt/format.h>
#include <nanodbc/nanodbc.h>
#include <sql.h>
#include <wx/log.h>
#include <database/database_connection.h>
#include <database/database_cache.h>
#include <core/profile.h>

Go to the source code of this file.

Classes

struct  RESULT_COLUMN
 

Macros

#define INT64   int64_t
 
#define UINT64   uint64_t
 

Functions

nanodbc::string fromUTF8 (const std::string &aString)
 When Unicode support is enabled in nanodbc, string formats are used matching the appropriate character set of the platform.
 
std::string toUTF8 (const nanodbc::string &aString)
 Converts a string from nanodbc-native to KiCad-native.
 
static std::vector< RESULT_COLUMN > resultColumns (nanodbc::result &aResults)
 Column names and types are the same for every row, so read them once per result set.
 
static void decodeRow (nanodbc::result &aResults, const std::vector< RESULT_COLUMN > &aColumns, DATABASE_CONNECTION::ROW &aRow)
 Decodes the current row of a result set into strings keyed by column name.
 

Variables

const char *const traceDatabase = "KICAD_DATABASE"
 

Macro Definition Documentation

◆ INT64

#define INT64   int64_t

Definition at line 30 of file database_connection.cpp.

◆ UINT64

#define UINT64   uint64_t

Definition at line 31 of file database_connection.cpp.

Function Documentation

◆ decodeRow()

static void decodeRow ( nanodbc::result & aResults,
const std::vector< RESULT_COLUMN > & aColumns,
DATABASE_CONNECTION::ROW & aRow )
static

Decodes the current row of a result set into strings keyed by column name.

Floating-point columns are formatted with {:G} and nulls become empty strings.

Definition at line 108 of file database_connection.cpp.

References RESULT_COLUMN::name, toUTF8(), and RESULT_COLUMN::type.

Referenced by DATABASE_CONNECTION::selectAllAndCache(), DATABASE_CONNECTION::SelectOne(), and DATABASE_CONNECTION::SelectSample().

◆ fromUTF8()

nanodbc::string fromUTF8 ( const std::string & aString)

When Unicode support is enabled in nanodbc, string formats are used matching the appropriate character set of the platform.

KiCad uses UTF-8 encoded strings internally, but different platforms use different encodings for SQL strings. Unicode mode must be enabled for compilation on Windows, since Visual Studio forces the use of Unicode SQL headers if any part of the project has Unicode enabled. Converts a string from KiCad-native to nanodbc-native

Parameters
aStringis a UTF-8 encoded string
Returns
a string in nanodbc's platform-specific representation

Definition at line 68 of file database_connection.cpp.

Referenced by DATABASE_CONNECTION::CacheTableInfo(), DATABASE_CONNECTION::Connect(), DATABASE_CONNECTION::GetColumns(), DATABASE_CONNECTION::GetTables(), DATABASE_CONNECTION::selectAllAndCache(), DATABASE_CONNECTION::SelectOne(), and DATABASE_CONNECTION::SelectSample().

◆ resultColumns()

static std::vector< RESULT_COLUMN > resultColumns ( nanodbc::result & aResults)
static

Column names and types are the same for every row, so read them once per result set.

Definition at line 93 of file database_connection.cpp.

Referenced by DATABASE_CONNECTION::selectAllAndCache(), DATABASE_CONNECTION::SelectOne(), and DATABASE_CONNECTION::SelectSample().

◆ toUTF8()

std::string toUTF8 ( const nanodbc::string & aString)

Converts a string from nanodbc-native to KiCad-native.

Parameters
aStringis a string encoded in nanodbc's platform-specific way
Returns
a string with UTF-8 encoding

Definition at line 79 of file database_connection.cpp.

Referenced by DATABASE_CONNECTION::CacheTableInfo(), DATABASE_CONNECTION::Connect(), decodeRow(), DATABASE_CONNECTION::GetColumns(), DATABASE_CONNECTION::getQuoteChar(), DATABASE_CONNECTION::GetTables(), DATABASE_CONNECTION::ListDataSourceDetails(), DATABASE_CONNECTION::ListDrivers(), and DATABASE_CONNECTION::SelectOne().

Variable Documentation

◆ traceDatabase