]> git.sesse.net Git - vlc/blobdiff - include/vlc_sql.h
core: remove media library support
[vlc] / include / vlc_sql.h
index 3b123a94ab0d04756d77a4297f3b581ad597a54b..8dae6ef3440812990df767bcbf5b892c1fad9e25 100644 (file)
@@ -1,32 +1,28 @@
 /*****************************************************************************
  * vlc_sql.h: SQL abstraction layer
  *****************************************************************************
- * Copyright (C) 2009 the VideoLAN team
+ * Copyright (C) 2009 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Antoine Lejeune <phytos@videolan.org>
  *          Jean-Philippe AndrĂ© <jpeg@videolan.org>
  *          Srikanth Raju <srikiraju@gmail.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#if !defined( __LIBVLC__ )
-# error You are not libvlc or one of its plugins. You cannot include this file
-#endif
-
 #ifndef VLC_SQL_H
 # define VLC_SQL_H
 
@@ -110,7 +106,7 @@ struct sql_t
     int (*pf_commit) ( sql_t* );
 
     /** Rollback transaction */
-    int (*pf_rollback) ( sql_t* );
+    void (*pf_rollback) ( sql_t* );
 
     /** Create a statement object */
     sql_stmt_t* (*pf_prepare) ( sql_t* p_sql, const char* p_fmt,
@@ -136,6 +132,9 @@ struct sql_t
     /** Get the data from a specified column */
     int (*pf_getcolumn) ( sql_t* p_sql, sql_stmt_t* p_stmt, int i_col,
                           int type, sql_value_t *p_res );
+
+    /** Get column size of a specified column */
+    int (*pf_getcolumnsize) ( sql_t* p_sql, sql_stmt_t* p_stmt, int i_col );
 };
 
 /*****************************************************************************
@@ -151,9 +150,9 @@ struct sql_t
  * @param psz_pass Password for the database
  * @return The VLC SQL object, type sql_t.
  **/
-VLC_EXPORT( sql_t*, sql_Create, ( vlc_object_t *p_this, const char *psz_name,
+VLC_API sql_t *sql_Create( vlc_object_t *p_this, const char *psz_name,
             const char* psz_host, int i_port,
-            const char* psz_user, const char* psz_pass ) );
+            const char* psz_user, const char* psz_pass );
 #define sql_Create( a, b, c, d, e, f ) sql_Create( VLC_OBJECT(a), b, c, d, e, f )
 
 
@@ -162,7 +161,7 @@ VLC_EXPORT( sql_t*, sql_Create, ( vlc_object_t *p_this, const char *psz_name,
  * @param obj This p_sql object
  * @return Nothing
  */
-VLC_EXPORT( void, sql_Destroy, ( vlc_object_t *obj ) );
+VLC_API void sql_Destroy( vlc_object_t *obj );
 #define sql_Destroy( a ) sql_Destroy( VLC_OBJECT( a ) )
 
 
@@ -295,9 +294,9 @@ static inline int sql_CommitTransaction( sql_t *p_sql )
  * @return VLC error code or success
  * @note This function is threadsafe
  **/
-static inline int sql_RollbackTransaction( sql_t *p_sql )
+static inline void sql_RollbackTransaction( sql_t *p_sql )
 {
-    return p_sql->pf_rollback( p_sql );
+    p_sql->pf_rollback( p_sql );
 }
 
 /**
@@ -305,7 +304,7 @@ static inline int sql_RollbackTransaction( sql_t *p_sql )
  * @param p_sql The SQL object
  * @param p_fmt SQL query string
  * @param i_length length of the string. If negative, length will be
- * considered upto the first \0 character equivalent to strlen(p_fmt).
+ * considered up to the first \0 character equivalent to strlen(p_fmt).
  * Otherwise the first i_length bytes will be used
  * @return a sql_stmt_t pointer or NULL on failure
  */
@@ -385,7 +384,7 @@ static inline int sql_BindDouble( sql_t *p_sql, sql_stmt_t* p_stmt,
  * @param p_stmt Statement Object
  * @param i_pos Position at which the parameter should be bound
  * @param p_fmt Value to be bound
- * @param i_length Length of text. If -ve text upto the first null char
+ * @param i_length Length of text. If -ve text up to the first null char
  * will be selected.
  * @return VLC_SUCCESS or VLC_EGENERIC
  */
@@ -557,6 +556,19 @@ static inline int sql_GetColumnBlob( sql_t* p_sql, sql_stmt_t* p_stmt,
     return i_ret;
 }
 
+/**
+ * @brief Get the size of the column in bytes
+ * @param p_sql The SQL object
+ * @param p_stmt The sql statement object
+ * @param i_col The column
+ * @return Size of the column in bytes, excluding the zero terminator
+ */
+static inline int sql_GetColumnSize( sql_t* p_sql, sql_stmt_t* p_stmt,
+        int i_col )
+{
+    return p_sql->pf_getcolumnsize( p_sql, p_stmt, i_col );
+}
+
 # ifdef __cplusplus
 }
 # endif /* C++ extern "C" */