00001 /* 00002 ** ClanLib SDK 00003 ** Copyright (c) 1997-2005 The ClanLib Team 00004 ** 00005 ** This software is provided 'as-is', without any express or implied 00006 ** warranty. In no event will the authors be held liable for any damages 00007 ** arising from the use of this software. 00008 ** 00009 ** Permission is granted to anyone to use this software for any purpose, 00010 ** including commercial applications, and to alter it and redistribute it 00011 ** freely, subject to the following restrictions: 00012 ** 00013 ** 1. The origin of this software must not be misrepresented; you must not 00014 ** claim that you wrote the original software. If you use this software 00015 ** in a product, an acknowledgment in the product documentation would be 00016 ** appreciated but is not required. 00017 ** 2. Altered source versions must be plainly marked as such, and must not be 00018 ** misrepresented as being the original software. 00019 ** 3. This notice may not be removed or altered from any source distribution. 00020 ** 00021 ** Note: Some of the libraries ClanLib link to may have additional 00022 ** requirements or restrictions. 00023 ** 00024 ** File Author(s): 00025 ** 00026 ** Magnus Norddahl 00027 */ 00028 00029 #include "precomp.h" 00030 #include "db_return_value.h" 00031 #include "db_command.h" 00032 #include "bytearray.h" 00033 #include "string_help.h" 00034 00036 // CL_DBReturnValue Operations: 00037 00038 CL_ByteArray CL_DBReturnValue::get_blob() const 00039 { 00040 return query->get_blob(column); 00041 } 00042 00043 void CL_DBReturnValue::get_blob(CL_ByteArray &array) const 00044 { 00045 query->get_blob(column, array); 00046 } 00047 00048 const void *CL_DBReturnValue::get_blob_raw() const 00049 { 00050 return query->get_blob_raw(column); 00051 } 00052 00053 int CL_DBReturnValue::get_blob_size() const 00054 { 00055 return query->get_blob_size(column); 00056 } 00057 00058 double CL_DBReturnValue::get_double() const 00059 { 00060 return query->get_double(column); 00061 } 00062 00063 int CL_DBReturnValue::get_int() const 00064 { 00065 return query->get_int(column); 00066 } 00067 00068 const char *CL_DBReturnValue::get_text() const 00069 { 00070 return query->get_text(column); 00071 } 00072 00073 CL_DBReturnValue::operator CL_ByteArray() const 00074 { 00075 return get_blob(); 00076 } 00077 00078 CL_DBReturnValue::operator double() const 00079 { 00080 return get_double(); 00081 } 00082 00083 CL_DBReturnValue::operator int() const 00084 { 00085 return get_int(); 00086 } 00087 00088 CL_DBReturnValue::operator CL_StringA() const 00089 { 00090 const char *t = get_text(); 00091 if (t) 00092 return t; 00093 else 00094 return CL_StringA(); 00095 } 00096 00097 CL_DBReturnValue::operator CL_StringW() const 00098 { 00099 return CL_StringHelp::utf8_to_ucs2(get_text()); 00100 } 00101 00103 // CL_DBReturnValue Implementation: 00104 00105 CL_DBReturnValue::CL_DBReturnValue(const CL_DBCommand *query, int column) 00106 : query(query), column(column) 00107 { 00108 } 00109 00110 CL_DBReturnValue::CL_DBReturnValue(const CL_DBReturnValue ©) 00111 : query(copy.query), column(copy.column) 00112 { 00113 } 00114 00115 CL_DBReturnValue &CL_DBReturnValue::operator =(const CL_DBReturnValue ©) 00116 { 00117 query = copy.query; 00118 column = copy.column; 00119 return *this; 00120 }
1.4.1