|
Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
|
Formats database values for different backends. More...
#include <value_formatter.h>

Public Member Functions | |
| value_formatter (database_types db_type) | |
| Construct formatter for specific database type. | |
| std::string | format (const core::database_value &value) const |
| Format a database value. | |
| std::string | escape_string (const std::string &str) const |
| Escape a string value. | |
| std::string | escape_identifier (const std::string &identifier) const |
| Quote and escape an identifier (table/column name) | |
| std::string | null_literal () const |
| Get NULL literal for this database. | |
| std::string | bool_literal (bool val) const |
| Get boolean literal. | |
Private Member Functions | |
| std::string | format_string (const std::string &str) const |
| std::string | format_int (int64_t num) const |
| std::string | format_double (double num) const |
| std::string | format_bool (bool val) const |
| std::string | format_blob (const std::vector< uint8_t > &data) const |
| std::string | escape_postgresql_string (const std::string &str) const |
| std::string | escape_sqlite_string (const std::string &str) const |
Private Attributes | |
| database_types | db_type_ |
Formats database values for different backends.
Responsibilities:
Single Responsibility Principle:
Thread Safety:
Definition at line 32 of file value_formatter.h.
|
explicit |
Construct formatter for specific database type.
| db_type | Target database type |
Definition at line 13 of file value_formatter.cpp.
| std::string database::query::value_formatter::bool_literal | ( | bool | val | ) | const |
Get boolean literal.
| val | Boolean value |
Definition at line 80 of file value_formatter.cpp.
References db_type_, database::mongodb, database::postgres, database::redis, and database::sqlite.
Referenced by format_bool(), and TEST_F().

| std::string database::query::value_formatter::escape_identifier | ( | const std::string & | identifier | ) | const |
Quote and escape an identifier (table/column name)
| identifier | Identifier to escape |
Definition at line 62 of file value_formatter.cpp.
References db_type_, database::mongodb, database::postgres, database::redis, and database::sqlite.
Referenced by database::query::join_builder::build(), database::query::condition_builder::format_condition(), and TEST_F().

|
private |
Definition at line 154 of file value_formatter.cpp.
Referenced by escape_string().

|
private |
Definition at line 186 of file value_formatter.cpp.
Referenced by escape_string().

| std::string database::query::value_formatter::escape_string | ( | const std::string & | str | ) | const |
Escape a string value.
| str | String to escape |
Definition at line 47 of file value_formatter.cpp.
References db_type_, escape_postgresql_string(), escape_sqlite_string(), database::mongodb, database::postgres, database::redis, and database::sqlite.
Referenced by format_string(), TEST_F(), and TEST_F().


| std::string database::query::value_formatter::format | ( | const core::database_value & | value | ) | const |
Format a database value.
| value | Value to format |
Definition at line 16 of file value_formatter.cpp.
References format_blob(), format_bool(), format_double(), format_int(), format_string(), and null_literal().
Referenced by database::query::condition_builder::format_condition(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().


|
private |
Definition at line 123 of file value_formatter.cpp.
References db_type_, database::postgres, and database::sqlite.
Referenced by format().

|
private |
Definition at line 119 of file value_formatter.cpp.
References bool_literal().
Referenced by format().


|
private |
Definition at line 104 of file value_formatter.cpp.
Referenced by format().

|
private |
Definition at line 100 of file value_formatter.cpp.
Referenced by format().

|
private |
Definition at line 96 of file value_formatter.cpp.
References escape_string().
Referenced by format().


| std::string database::query::value_formatter::null_literal | ( | ) | const |
Get NULL literal for this database.
Definition at line 76 of file value_formatter.cpp.
Referenced by format(), and TEST_F().

|
private |
Definition at line 75 of file value_formatter.h.
Referenced by bool_literal(), escape_identifier(), escape_string(), and format_blob().