C# Class Mono.Data.Sqlite.SqliteConvert

This base class provides datatype conversion services for the SQLite provider.
Show file Open project: rubenv/tripod Class Usage Examples

Public Methods

Method Description
Split ( string source, char separator ) : string[]

Smart method of splitting a string. Skips quoted elements, removes the quotes.

This split function works somewhat like the String.Split() function in that it breaks apart a string into pieces and returns the pieces as an array. The primary differences are: Only one character can be provided as a separator character Quoted text inside the string is skipped over when searching for the separator, and the quotes are removed. Thus, if splitting the following string looking for a comma:
One,Two, "Three, Four", Five

The resulting array would contain
[0] One
[1] Two
[2] Three, Four
[3] Five

Note that the leading and trailing spaces were removed from each item during the split.

ToDateTime ( string dateText ) : System.DateTime

Converts a string into a DateTime, using the current DateTimeFormat specified for the connection when it was opened.

Acceptable ISO8601 DateTime formats are: yyyy-MM-dd HH:mm:ss yyyyMMddHHmmss yyyyMMddTHHmmssfffffff yyyy-MM-dd yy-MM-dd yyyyMMdd HH:mm:ss THHmmss

ToString ( System.DateTime dateValue ) : string

Converts a DateTime to a string value, using the current DateTimeFormat specified for the connection when it was opened.

ToString ( IntPtr nativestring ) : string

Converts a UTF-8 encoded IntPtr of the specified length into a .NET string

ToUTF8 ( System.DateTime dateTimeValue ) : byte[]

Convert a DateTime to a UTF-8 encoded, zero-terminated byte array.

This function is a convenience function, which first calls ToString() on the DateTime, and then calls ToUTF8() with the string result.

ToUTF8 ( string sourceText ) : byte[]

Converts a string to a UTF-8 encoded byte array sized to include a null-terminating character.

UTF8ToString ( IntPtr nativestring ) : string

Converts a UTF-8 encoded IntPtr of the specified length into a .NET string

Private Methods

Method Description
ColumnToType ( SqliteStatement stmt, int i ) : SqliteType

Determines the data type of a column in a statement

DbTypeToColumnSize ( DbType typ ) : int

Returns the ColumnSize for the given DbType

DbTypeToType ( DbType typ ) : Type

Convert a DbType to a Type

SqliteConvert ( SqliteDateFormats fmt ) : System

Initializes the conversion class

SqliteTypeToType ( SqliteType t ) : Type

Converts a SqliteType to a .NET Type object

ToDateTime ( IntPtr ptr ) : System.DateTime

Internal function to convert a UTF-8 encoded IntPtr of the specified length to a DateTime.

This is a convenience function, which first calls ToString() on the IntPtr to convert it to a string, then calls ToDateTime() on the string to return a DateTime.

TypeNameToDbType ( string Name ) : DbType

For a given type name, return a closest-match .NET type

TypeToAffinity ( Type typ ) : TypeAffinity

For a given type, return the closest-match Sqlite TypeAffinity, which only understands a very limited subset of types.

TypeToDbType ( Type typ ) : DbType

For a given intrinsic type, return a DbType

Method Details

Split() public static method

Smart method of splitting a string. Skips quoted elements, removes the quotes.
This split function works somewhat like the String.Split() function in that it breaks apart a string into pieces and returns the pieces as an array. The primary differences are: Only one character can be provided as a separator character Quoted text inside the string is skipped over when searching for the separator, and the quotes are removed. Thus, if splitting the following string looking for a comma:
One,Two, "Three, Four", Five

The resulting array would contain
[0] One
[1] Two
[2] Three, Four
[3] Five

Note that the leading and trailing spaces were removed from each item during the split.
public static Split ( string source, char separator ) : string[]
source string Source string to split apart
separator char Separator character
return string[]

ToDateTime() public method

Converts a string into a DateTime, using the current DateTimeFormat specified for the connection when it was opened.
Acceptable ISO8601 DateTime formats are: yyyy-MM-dd HH:mm:ss yyyyMMddHHmmss yyyyMMddTHHmmssfffffff yyyy-MM-dd yy-MM-dd yyyyMMdd HH:mm:ss THHmmss
public ToDateTime ( string dateText ) : System.DateTime
dateText string The string containing either a Tick value or an ISO8601-format string
return System.DateTime

ToString() public method

Converts a DateTime to a string value, using the current DateTimeFormat specified for the connection when it was opened.
public ToString ( System.DateTime dateValue ) : string
dateValue System.DateTime The DateTime value to convert
return string

ToString() public method

Converts a UTF-8 encoded IntPtr of the specified length into a .NET string
public ToString ( IntPtr nativestring ) : string
nativestring System.IntPtr The pointer to the memory where the UTF-8 string is encoded
return string

ToUTF8() public method

Convert a DateTime to a UTF-8 encoded, zero-terminated byte array.
This function is a convenience function, which first calls ToString() on the DateTime, and then calls ToUTF8() with the string result.
public ToUTF8 ( System.DateTime dateTimeValue ) : byte[]
dateTimeValue System.DateTime The DateTime to convert.
return byte[]

ToUTF8() public method

Converts a string to a UTF-8 encoded byte array sized to include a null-terminating character.
public ToUTF8 ( string sourceText ) : byte[]
sourceText string The string to convert to UTF-8
return byte[]

UTF8ToString() public method

Converts a UTF-8 encoded IntPtr of the specified length into a .NET string
public UTF8ToString ( IntPtr nativestring ) : string
nativestring System.IntPtr The pointer to the memory where the UTF-8 string is encoded
return string