/* 
   SQLiteValues.m

   Copyright (C) 1999-2005 MDlink online service center GmbH and Helge Hess

   Author: Helge Hess (helge@mdlink.de)

   This file is part of the SQLite Adaptor Library

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; see the file COPYING.LIB.
   If not, write to the Free Software Foundation,
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#import "SQLiteValues.h"
#import "common.h"

@implementation SQLiteDataTypeMappingException

- (id)initWithObject:(id)_obj
  forAttribute:(EOAttribute *)_attr
  andSQLite3Type:(NSString *)_dt
  inChannel:(SQLiteChannel *)_channel;
{  
  NSDictionary *ui;
  NSString *typeName = nil;
  NSString *r;

  typeName = _dt;

  if (typeName == nil)
    typeName = [NSString stringWithFormat:@"Oid[%i]", _dt];

  r = [NSString stringWithFormat:
                              @"mapping between %@<Class:%@> and "
                              @"SQLite type %@ is not supported",
                              [_obj description],
                              NSStringFromClass([_obj class]),
		typeName];
  ui = [NSDictionary dictionaryWithObjectsAndKeys:
                                    _attr,    @"attribute",
                                    _channel, @"channel",
                                    _obj,     @"object",
		     nil];
  
  [self setName:@"DataTypeMappingNotSupported"];
  [self setReason:r];

  [self setUserInfo:ui];
  return self;
}

@end /* SQLiteDataTypeMappingException */

@implementation NSNull(SQLiteValues)

- (NSString *)stringValueForSQLite3Type:(NSString *)_type
  attribute:(EOAttribute *)_attribute
{
  return @"null";
}

@end /* NSNull(SQLiteValues) */


void __link_SQLiteValues() {
  // used to force linking of object file
  __link_SQLiteValues();
}
