Click here to Skip to main content
15,895,084 members
Articles / Desktop Programming / MFC

Introduction to ACF (Another C++ Framework)

Rate me:
Please Sign up or sign in to vote.
4.86/5 (36 votes)
27 May 200411 min read 136.4K   739   49  
This article introduces ACF, a C++ framework which brings the .NET framework to standard C++.
//---------------------------------------------------------------------
//
// Copyright (C) 2004 Yingle Jia
//
// Permission to copy, use, modify, sell and distribute this software is 
// granted provided this copyright notice appears in all copies. 
// This software is provided "as is" without express or implied warranty, 
// and with no claim as to its suitability for any purpose.
//
// AcfExceptions.h - defines common exceptions
//

#ifndef __Acf_Exceptions__
#define __Acf_Exceptions__

namespace Acf {

//
// Classes definded in this file
//
class Exception;
    class SystemException;
        class OutOfMemoryException;
        class IndexOutOfRangeException;
        class InvalidCastException;
        class InvalidOperationException;
        class NotSupportedException;
        class NotImplementedException;
        class UnauthorizedAccessException;
        class ArgumentException;
            class ArgumentNullException;
            class ArgumentOutOfRangeException;
        class FormatException;

//---------------------------------------------------------------------
// class Exception

class Exception
{
// Fields
private:
    StringPtr _message;

// Constructors
public:
    Exception() : _message(String::Empty)
    {
    }
    explicit Exception(String* message)
    {
        if (message == null)
            message = String::Empty;

        this->_message = message;
    }

// Properties
public:
    // Message
    __declspec(property(get=get_Message)) StringPtr Message;
    /*virtual*/ StringPtr get_Message()
    {
        return this->_message;
    }
};

//---------------------------------------------------------------------
// class SystemException

class SystemException : public Exception
{
};

//---------------------------------------------------------------------
// class OutOfMemoryException

class OutOfMemoryException : public SystemException
{
};

//---------------------------------------------------------------------
// class IndexOutOfRangeException

class IndexOutOfRangeException : public SystemException
{
};

//---------------------------------------------------------------------
// class InvalidCastException

class InvalidCastException : public SystemException
{
};

//---------------------------------------------------------------------
// class InvalidOperationException

class InvalidOperationException : public Exception
{
};

//---------------------------------------------------------------------
// class NotSupportedException

class NotSupportedException : public SystemException
{
};

//---------------------------------------------------------------------
// class NotImplementedException

class NotImplementedException : public SystemException
{
};

//---------------------------------------------------------------------
// class UnauthorizedAccessException

class UnauthorizedAccessException : public SystemException
{
};

//---------------------------------------------------------------------
// class ArgumentException

class ArgumentException : public SystemException
{
};

//---------------------------------------------------------------------
// class ArgumentNullException

class ArgumentNullException : public ArgumentException
{
};

//---------------------------------------------------------------------
// class ArgumentOutOfRangeException

class ArgumentOutOfRangeException : public ArgumentException
{
};

//---------------------------------------------------------------------
// class FormatException

class FormatException : public SystemException
{
};

//---------------------------------------------------------------------
// VerifyStringRange
//---------------------------------------------------------------------
inline void VerifyStringRange(String* s, int index, int count)
{
    if (s == null)
        throw ArgumentNullException();
    if (index < 0 || count < 0)
        throw ArgumentOutOfRangeException();
    if (index + count > s->Length)
        throw ArgumentOutOfRangeException();
}

} // namespace Acf

#endif // #ifndef __Acf_Exceptions__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
China China
Yingle Jia is a software engineer located in Beijing, China. He currently works at IBM CSDL (China Software Development Lab). His interests include C++/COM/C#/.NET/XML, etc. He likes coding and writing.

He is the creator of ACF (Another C++ Framework) project. See http://acfproj.sourceforge.net/.

He also has a blog at http://blogs.wwwcoder.com/yljia/

Comments and Discussions