Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
206 changes: 103 additions & 103 deletions COLLADABaseUtils/include/COLLADABUException.h
Original file line number Diff line number Diff line change
@@ -1,104 +1,104 @@
/*
Copyright (c) 2008-2009 NetAllied Systems GmbH
This file is part of COLLADABaseUtils.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/
#ifndef __COLLADABU_EXCEPTION_H__
#define __COLLADABU_EXCEPTION_H__
#include "COLLADABUPrerequisites.h"
/*
Copyright (c) 2008-2009 NetAllied Systems GmbH

This file is part of COLLADABaseUtils.

Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/

#ifndef __COLLADABU_EXCEPTION_H__
#define __COLLADABU_EXCEPTION_H__

#include "COLLADABUPrerequisites.h"
#include "COLLADABUStableHeaders.h"
#include <iostream>
namespace COLLADABU
{
/** Class that is thrown by the base utils classes if something goes wrong. */
class Exception
{
public:
enum Type
{
ERROR_TYPE_UNKNOWN,
ERROR_FILE_OPEN,
ERROR_SET_BUFFER,
ERROR_UTF8_2_WIDE,
ERROR_WIDE_2_UTF8,
ERROR_NATIVE_2_WIDE,
ERROR_WIDE_2_NATIVE
};
protected:
/** The type of the exception. */
Type mExceptionType;
/** The error message for output. */
String mMessage;
public:
/** Constructor. Creates an exception of unknown type with the given message. */
Exception ( const String& message )
: mExceptionType ( ERROR_TYPE_UNKNOWN )
, mMessage ( message )
{}
/** Constructor. Creates an exception of type @a type with the given message. */
Exception ( Type exceptionType, const String& message )
: mExceptionType ( exceptionType )
, mMessage ( message )
{}
/** Constructor. */
Exception ( Type exceptionType, const String file, const long line, const String message )
: mExceptionType ( exceptionType )
{
std::ostringstream stream;
stream << file << ":" << line << ": " << message;
mMessage = stream.str ().c_str ();
}
/** Constructor. */
Exception ( const String file, const long line, const String message )
: mExceptionType ( ERROR_TYPE_UNKNOWN )
{
std::ostringstream stream;
stream << file << ":" << line << ": " << message;
mMessage = stream.str ().c_str ();
}
/** Destructor. */
virtual ~Exception () {}
/** Returns the type of the exception*/
Type getType()const {return mExceptionType;}
/** Returns the text, describing the exception.*/
String getMessage()const {return mMessage;};
/** Print the massage in the standard error output. */
void printMessage ()
{
if ( mExceptionType == ERROR_TYPE_UNKNOWN )
std::cerr << "MainException: " << mMessage << std::endl;
else
std::cerr << "MainException: " << mMessage << ", Error type " << mExceptionType << std::endl;
}
};
} //namespace COLLADABU
#endif //__COLLADABU_EXCEPTION_H__

#include <iostream>


namespace COLLADABU
{

/** Class that is thrown by the base utils classes if something goes wrong. */
class Exception
{

public:

enum Type
{
ERROR_TYPE_UNKNOWN,
ERROR_FILE_OPEN,
ERROR_SET_BUFFER,
ERROR_UTF8_2_WIDE,
ERROR_WIDE_2_UTF8,
ERROR_NATIVE_2_WIDE,
ERROR_WIDE_2_NATIVE
};

protected:

/** The type of the exception. */
Type mExceptionType;

/** The error message for output. */
String mMessage;

public:

/** Constructor. Creates an exception of unknown type with the given message. */
Exception ( const String& message )
: mExceptionType ( ERROR_TYPE_UNKNOWN )
, mMessage ( message )
{}

/** Constructor. Creates an exception of type @a type with the given message. */
Exception ( Type exceptionType, const String& message )
: mExceptionType ( exceptionType )
, mMessage ( message )
{}

/** Constructor. */
Exception ( Type exceptionType, const String file, const long line, const String message )
: mExceptionType ( exceptionType )
{
std::ostringstream stream;
stream << file << ":" << line << ": " << message;
mMessage = stream.str ().c_str ();
}

/** Constructor. */
Exception ( const String file, const long line, const String message )
: mExceptionType ( ERROR_TYPE_UNKNOWN )
{
std::ostringstream stream;
stream << file << ":" << line << ": " << message;
mMessage = stream.str ().c_str ();
}

/** Destructor. */
virtual ~Exception () {}

/** Returns the type of the exception*/
Type getType()const {return mExceptionType;}

/** Returns the text, describing the exception.*/
String getMessage()const {return mMessage;};

/** Print the massage in the standard error output. */
void printMessage ()
{
if ( mExceptionType == ERROR_TYPE_UNKNOWN )
std::cerr << "MainException: " << mMessage << std::endl;
else
std::cerr << "MainException: " << mMessage << ", Error type " << mExceptionType << std::endl;
}


};

} //namespace COLLADABU


#endif //__COLLADABU_EXCEPTION_H__
140 changes: 70 additions & 70 deletions COLLADABaseUtils/include/COLLADABUNativeString.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Copyright (c) 2008-2009 NetAllied Systems GmbH
This file is part of COLLADABaseUtils.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
/*
Copyright (c) 2008-2009 NetAllied Systems GmbH

This file is part of COLLADABaseUtils.

Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/

#ifndef __COLLADABU_NATIVESTRING_H__
Expand All @@ -18,68 +18,68 @@ namespace COLLADABU
{

/** A string class to store strings encoded in the systems native encoding.*/
class NativeString : public String
{
public:
enum Encoding
{
ENCODING_NATIVE,
ENCODING_UTF8
};
public:
/**Content is initialized to a copy of the string object str.
If @a encoding is ENCODING_NATIVE, @a str is assumed to be encoded in the platform native encoding.
If @a encoding is ENCODING_UTF8, @a str is assumed to be encoded in UTF8.*/
explicit NativeString(const String& str, Encoding encoding = ENCODING_NATIVE);
NativeString(const WideString& wstr) : String()
{
fromWideString(wstr);
}
/** Content is initialized to an empty NativeString. */
explicit NativeString ( );
/** Content is initialized to a copy of a substring of str. The substring is the portion of
str that begins at the character position pos and takes up to n characters (it takes less than
n if the end of str is reached before).*/
// NativeString ( const String& str, size_t pos, size_t n = npos ) : String(str, pos, n){}
/* Content is initialized to a copy of the string formed by the first n characters in the array
of characters pointed by s.*/
// NativeString ( const char * s, size_t n ) : String(s, n){}
/** Content is initialized to a copy of the string formed by the null-terminated character sequence
(C string) pointed by s. The length of the character sequence is determined by the first occurrence
of a null character (as determined by traits.length(s)). This version can be used to initialize a
string object using a string literal constant.*/
explicit NativeString ( const char * s, Encoding encoding = ENCODING_NATIVE);
/** Content is initialized as a string formed by a repetition of character c, n times.*/
// NativeString ( size_t n, char c ) : String(n, c){}
/**If InputIterator is an integral type, behaves as the sixth constructor version (the one right above
this) by typecasting begin and end to call it:
string(static_cast<size_t>(begin),static_cast<char>(end));
In any other case, the parameters are taken as iterators, and the content is initialized with the values
of the elements that go from the element referred by iterator begin to the element right before the one
referred by iterator end.
*/
template<class InputIterator>
NativeString (InputIterator begin, InputIterator end) : String(begin, end) {}
/** Returns the string as unicode encoded wide string.*/
WideString toWideString()const;
/** Returns the string as utf encoded string.*/
String toUtf8String() const;
private:
void fromWideString(const WideString& wstr);
};

class NativeString : public String
{
public:
enum Encoding
{
ENCODING_NATIVE,
ENCODING_UTF8
};
public:
/**Content is initialized to a copy of the string object str.
If @a encoding is ENCODING_NATIVE, @a str is assumed to be encoded in the platform native encoding.
If @a encoding is ENCODING_UTF8, @a str is assumed to be encoded in UTF8.*/
explicit NativeString(const String& str, Encoding encoding = ENCODING_NATIVE);

NativeString(const WideString& wstr) : String()
{
fromWideString(wstr);
}


/** Content is initialized to an empty NativeString. */
explicit NativeString ( );

/** Content is initialized to a copy of a substring of str. The substring is the portion of
str that begins at the character position pos and takes up to n characters (it takes less than
n if the end of str is reached before).*/
// NativeString ( const String& str, size_t pos, size_t n = npos ) : String(str, pos, n){}

/* Content is initialized to a copy of the string formed by the first n characters in the array
of characters pointed by s.*/
// NativeString ( const char * s, size_t n ) : String(s, n){}

/** Content is initialized to a copy of the string formed by the null-terminated character sequence
(C string) pointed by s. The length of the character sequence is determined by the first occurrence
of a null character (as determined by traits.length(s)). This version can be used to initialize a
string object using a string literal constant.*/
explicit NativeString ( const char * s, Encoding encoding = ENCODING_NATIVE);

/** Content is initialized as a string formed by a repetition of character c, n times.*/
// NativeString ( size_t n, char c ) : String(n, c){}

/**If InputIterator is an integral type, behaves as the sixth constructor version (the one right above
this) by typecasting begin and end to call it:
string(static_cast<size_t>(begin),static_cast<char>(end));
In any other case, the parameters are taken as iterators, and the content is initialized with the values
of the elements that go from the element referred by iterator begin to the element right before the one
referred by iterator end.
*/
template<class InputIterator>
NativeString (InputIterator begin, InputIterator end) : String(begin, end) {}

/** Returns the string as unicode encoded wide string.*/
WideString toWideString()const;

/** Returns the string as utf encoded string.*/
String toUtf8String() const;


private:
void fromWideString(const WideString& wstr);
};

}

Expand Down
Loading