ftp.nice.ch/Attic/openStep/implementation/gnustep/sources/libFoundation.0.7.tgz#/libFoundation-0.7/FoundationExtensions/extensions/exceptions/NSCoderExceptions.m

This is NSCoderExceptions.m in view mode; [Download] [Up]

/* 
   Copyright (C) 1996 
	Ovidiu Predescu <ovidiu@bx.logicnet.ro>
	Mircea Oancea <mircea@jupiter.elcom.pub.ro>

   Author: Ovidiu Predescu <ovidiu@bx.logicnet.ro>

   This file is part of the FoundationExtensions 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.
*/

#include <Foundation/NSString.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSValue.h>
#include <extensions/exceptions/NSCoderExceptions.h>
#include "../MissingMethods.h"


@implementation NSCoderException
@end /* NSCoderExceptions */


@implementation InvalidSignatureForCoder
- init
{
    self = [self initWithName:NSInvalidArgumentException
	    reason:@"Invalid coder signature"
	    userInfo:nil];
    return self;
}
@end /* InvalidSignatureForCoder */


@implementation DifferentKindOfCodersException
- initForClassName:(NSString*)class1 andClassName:(NSString*)class2
{
    self = [self initWithName:NSInvalidArgumentException
	    reason:@"Invalid coder signature"
	    userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
					class1, @"first class",
					class2, @"second class", nil]];
    return self;
}
@end /* DifferentKindOfCodersException */


@implementation CoderHasAlreadyWrittenRootObjectException
- init
{
    self = [self initWithName:NSInvalidArgumentException
	    reason:@"Coder has already written root object"
	    userInfo:nil];
    return self;
}
@end /* CoderHasAlreadyWrittenRootObjectException */


@implementation RootObjectHasNotBeenWrittenException
- init
{
    self = [self initWithName:NSInvalidArgumentException
	    reason:@"Root object has not been written before"
	    userInfo:nil];
    return self;
}
@end /* RootObjectHasNotBeenWrittenException */

@implementation UnexpectedTypeException
+ allocForExpected:(NSString*)_expected andGot:(NSString*)_got
{
    UnexpectedTypeException* exception = [self alloc];
    exception->expected = _expected;
    exception->got = _got;

    exception = [exception initWithName:NSInvalidArgumentException
	    reason:@"Different type was written in archive"
	    userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
				    exception->expected, @"expected to read",
				    exception->got, @"got from archive", nil]];

    return exception;
}

+ allocForExpectedSize:(int)_expected andGotSize:(int)_got
{
    UnexpectedTypeException* exception = [self alloc];
    exception->expected = [[NSNumber numberWithInt:_expected] stringValue];
    exception->got = [[NSNumber numberWithInt:_got] stringValue];

    exception = [exception initWithName:NSInvalidArgumentException
	    reason:@"Different number of elements was written in archive"
	    userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
				exception->expected, @"expected to read",
				exception->got, @"got from archive", nil]];

    return exception;
}
@end /* UnexpectedTypeException */


@implementation ReadUnknownTagException
- initForTag:(char)_tag
{
    tag = _tag;
    self = [self initWithName:NSInvalidArgumentException
	    reason:@"Invalid tag read from archive"
	    userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
			[[NSNumber numberWithChar:tag] stringValue], @"tag",
			nil]];
    return self;
}
@end /* ReadUnknownTagException */

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.