Gnome::Gda::SqlParser Class Reference

SQL parser. More...

Inheritance diagram for Gnome::Gda::SqlParser:
[legend]
Collaboration diagram for Gnome::Gda::SqlParser:
[legend]

## Public Member Functions

| SqlParser (SqlParser&& src) noexcept
SqlParser& | operator= (SqlParser&& src) noexcept
virtual | ~SqlParser () noexcept
GdaSqlParser* | gobj ()
| Provides access to the underlying C GObject. More...
const GdaSqlParser* | gobj () const
| Provides access to the underlying C GObject. More...
GdaSqlParser* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
Glib::RefPtr< Statement > | parse_string (const Glib::ustring& sql, Glib::ustring& remain)
| Parses sql and creates a Gda::Statement statement from the first SQL statement contained in sql: if sql contains more than one statement, then the remaining part of the string is not parsed at all, and remain (if not `0`) will point at the first non parsed character. More...
Glib::RefPtr< Statement > | parse_string (const Glib::ustring& sql)
Glib::RefPtr< Batch > | parse_string_as_batch (const Glib::ustring& sql, Glib::ustring& remain)
| Parse sql and creates a Gda::Batch object which contains all the Gda::Statement objects created while parsing (one object per SQL statement). More...
Glib::RefPtr< Batch > | parse_string_as_batch (const Glib::ustring& sql)
Glib::RefPtr< Batch > | parse_file_as_batch (const std::string& filename)
| Parse filename's contents and creates a Gda::Batch object which contains all the Gda::Statement objects created while parsing (one object per SQL statement). More...
Glib::PropertyProxy_ReadOnly< int > | property_column_error () const
Glib::PropertyProxy_ReadOnly< int > | property_line_error () const
Glib::PropertyProxy< int > | property_mode ()
Glib::PropertyProxy_ReadOnly< int > | property_mode () const
Glib::PropertyProxy< int > | property_tokenizer_flavour ()
Glib::PropertyProxy_ReadOnly< int > | property_tokenizer_flavour () const
Public Member Functions inherited from Glib::Object
| Object (const Object &)=delete
Object & | operator= (const Object &)=delete
| Object (Object &&src) noexcept
Object & | operator= (Object &&src) noexcept
void * | get_data (const QueryQuark &key)
void | set_data (const Quark &key, void *data)
void | set_data (const Quark &key, void *data, DestroyNotify notify)
void | remove_data (const QueryQuark &quark)
void * | steal_data (const QueryQuark &quark)
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase &)=delete
ObjectBase & | operator= (const ObjectBase &)=delete
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
void | set_property (const Glib::ustring &property_name, const PropertyType &value)
void | get_property (const Glib::ustring &property_name, PropertyType &value) const
void | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void > &slot)
sigc::connection | connect_property_changed_with_return (const Glib::ustring &property_name, const sigc::slot< void > &slot)
void | freeze_notify ()
void | thaw_notify ()
virtual void | reference () const
virtual void | unreference () const
GObject * | gobj ()
const GObject * | gobj () const
GObject * | gobj_copy () const
Public Member Functions inherited from sigc::trackable
| trackable ()
| trackable (const trackable &src)
| trackable (trackable &&src) noexcept
| ~trackable ()
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src) noexcept
void | remove_destroy_notify_callback (void *data) const

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
static Glib::RefPtr< SqlParser > | create ()

## Protected Member Functions

| SqlParser ()
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams &construct_params)
| Object (GObject *castitem)
virtual | ~Object () noexcept
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| ObjectBase (const char *custom_type_name)
| ObjectBase (const std::type_info &custom_type_info)
| ObjectBase (ObjectBase &&src) noexcept
ObjectBase & | operator= (ObjectBase &&src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject *castitem)
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gnome::Gda::SqlParser > | wrap (GdaSqlParser* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Additional Inherited Members

Public Types inherited from Glib::Object
typedef void(* | DestroyNotify) (gpointer data)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify

## Detailed Description

SQL parser.

The Gda::SqlParser is an object dedicated to creating Gda::Statement and Gda::Batch objects from SQL strings. The actual contents of the parsed statements is represented as Gda::SqlStatement structures (which can be obtained from any Gda::Statement through the "structure" property).

Gda::SqlParser parsers can be created by calling Gda::ServerProvider::create_parser() for a provider adapted SQL parser, or using create() for a general purpose SQL parser.

The Gda::SqlParser can either work in "parse" mode where it will try to parse the SQL string, or in "delimiter" mode where it will only attempt at delimiting SQL statements in a string which may contain several SQL statements (usually separated by a semi column). If operating in "parser" mode, and the parser can't correctly parse the string, then it will switch to the "delimiter" mode for the next statement in the string to parse (and create a STATEMENT_UNKNOWN statement).

The Gda::SqlParser object parses and analyses SQL statements and reports the following statement types:

- SELECT (and COMPOUND select), INSERT, UPDATE and DELETE SQL statements should be completely parsed.
- Transaction related statements (corresponding to the BEGIN, COMMIT, ROLLBACK, SAVEPOINT, ROLLBACK SAVEPOINT and DELETE SAVEPOINT) are parsed and a minimalist structure is created to extract some information (that structure is not enough per-se to re-create the complete SQL statement).

Any other type of SQL statement (CREATE TABLE, ...) creates a GdaStatement of type STATEMENT_UNKNOWN, and it only able to locate place holders (variables) and end of statement marks.

NOTE: Any SQL of a type which should be parsed which but which creates a Gda::Statement of type GDA_SQL_STATEMENT_UNKNOWN (check with Gda::Statement::get_statement_type()) should be reported as a bug.

The Gda::SqlParser object recognizes place holders (variables), which can later be queried and valued using Gda::Statement::get_parameters(). See the syntax description for the underlying GdaSqlParser.

## Constructor & Destructor Documentation

Gnome::Gda::SqlParser::SqlParser | ( | SqlParser&& | src | ) |

noexcept

virtual Gnome::Gda::SqlParser::~SqlParser | ( |  | ) |

virtual noexcept

Gnome::Gda::SqlParser::SqlParser | ( |  | ) |

protected

## Member Function Documentation

static Glib::RefPtr<SqlParser> Gnome::Gda::SqlParser::create | ( |  | ) |

static

static GType Gnome::Gda::SqlParser::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

GdaSqlParser* Gnome::Gda::SqlParser::gobj | ( |  | ) |

inline

Provides access to the underlying C GObject.

const GdaSqlParser* Gnome::Gda::SqlParser::gobj | ( |  | ) | const

inline

Provides access to the underlying C GObject.

GdaSqlParser* Gnome::Gda::SqlParser::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

SqlParser& Gnome::Gda::SqlParser::operator= | ( | SqlParser&& | src | ) |

noexcept

Glib::RefPtr<Batch> Gnome::Gda::SqlParser::parse_file_as_batch | ( | const std::string & | filename | ) |

Parse filename's contents and creates a Gda::Batch object which contains all the Gda::Statement objects created while parsing (one object per SQL statement).

filename's contents are parsed and Gda::Statement objects are created as long as no error is found. If an error is found at some point, then the parsing stops, error may be set and `0` is returned

if sql is `0`, then the returned Gda::Batch object will contain no statement.

Parameters

  filename | Name of the file to parse.

Returns
  A new Gda::Batch object, or `0` if an error occurred.

Glib::RefPtr<Statement> Gnome::Gda::SqlParser::parse_string | ( | const Glib::ustring & | sql,
|  | Glib::ustring & | remain
| ) |  |

Parses sql and creates a Gda::Statement statement from the first SQL statement contained in sql: if sql contains more than one statement, then the remaining part of the string is not parsed at all, and remain (if not `0`) will point at the first non parsed character.

To include variables in the sql string, see the GdaSqlParser's object description.

Parameters

  sql | The SQL string to parse.
  remain | Location to store a pointer to remaining part of sql in case sql has multiple statement, or `0`.

Returns
  A new Gda::Statement object, or `0` if an error occurred.

Glib::RefPtr<Statement> Gnome::Gda::SqlParser::parse_string | ( | const Glib::ustring & | sql | ) |

Glib::RefPtr<Batch> Gnome::Gda::SqlParser::parse_string_as_batch | ( | const Glib::ustring & | sql,
|  | Glib::ustring & | remain
| ) |  |

Parse sql and creates a Gda::Batch object which contains all the Gda::Statement objects created while parsing (one object per SQL statement).

Empty statements (composed of spaces only) do not appear in the resulting object.

sql is parsed and Gda::Statement objects are created as long as no error is found in sql. If an error is found at some point, then the parsing stops and remain may contain a non `0` pointer, error may be set, and `0` is returned.

if sql is `0`, then the returned Gda::Batch object will contain no statement.

To include variables in the sql string, see the GdaSqlParser's object description.

Parameters

  sql | The SQL string to parse.
  remain | Location to store a pointer to remaining part of sql in case an error occurred while parsing sql, or `0`.

Returns
  A new Gda::Batch object, or `0` if an error occurred.

Glib::RefPtr<Batch> Gnome::Gda::SqlParser::parse_string_as_batch | ( | const Glib::ustring & | sql | ) |

Glib::PropertyProxy_ReadOnly< int > Gnome::Gda::SqlParser::property_column_error | ( |  | ) | const

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< int > Gnome::Gda::SqlParser::property_line_error | ( |  | ) | const

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy< int > Gnome::Gda::SqlParser::property_mode | ( |  | ) |

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< int > Gnome::Gda::SqlParser::property_mode | ( |  | ) | const

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy< int > Gnome::Gda::SqlParser::property_tokenizer_flavour | ( |  | ) |

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< int > Gnome::Gda::SqlParser::property_tokenizer_flavour | ( |  | ) | const

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## Friends And Related Function Documentation

Glib::RefPtr< Gnome::Gda::SqlParser > wrap | ( | GdaSqlParser * | object,
|  | bool | take_copy = `false`
| ) |  |

related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.

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

- libgdamm/sqlparser.h