DynamicAny:operator [] fix (did not compile w/ VS 2003)

This commit is contained in:
Aleksandar Fabijanic 2008-02-02 21:55:14 +00:00
parent 9dde6fb1ef
commit be815af919
5 changed files with 46 additions and 186 deletions

View File

@ -345,13 +345,31 @@ public:
bool isStruct() const; bool isStruct() const;
/// Returns true if DynamicAny represents a struct /// Returns true if DynamicAny represents a struct
DynamicAny& operator [] (std::vector<DynamicAny>::size_type n); template <typename T>
DynamicAny& operator [] (T n)
/// Index operator, only use on DynamicAnys where isArray /// Index operator, only use on DynamicAnys where isArray
/// returns true! In all other cases a BadCastException is thrown! /// returns true! In all other cases a BadCastException is thrown!
{
DynamicAnyHolderImpl<std::vector<DynamicAny> >* pHolder =
dynamic_cast<DynamicAnyHolderImpl<std::vector<DynamicAny> > *>(_pHolder);
if (pHolder)
return pHolder->operator[](n);
else
throw BadCastException();
}
const DynamicAny& operator [] (std::vector<DynamicAny>::size_type n) const; template <typename T>
const DynamicAny& operator [] (T n) const
/// const Index operator, only use on DynamicAnys where isArray /// const Index operator, only use on DynamicAnys where isArray
/// returns true! In all other cases a BadCastException is thrown! /// returns true! In all other cases a BadCastException is thrown!
{
const DynamicAnyHolderImpl<std::vector<DynamicAny> >* pHolder =
dynamic_cast<const DynamicAnyHolderImpl<std::vector<DynamicAny> > *>(_pHolder);
if (pHolder)
return pHolder->operator[](n);
else
throw BadCastException();
}
DynamicAny& operator [] (const std::string& name); DynamicAny& operator [] (const std::string& name);
/// Index operator by name, only use on DynamicAnys where isStruct /// Index operator by name, only use on DynamicAnys where isStruct
@ -361,6 +379,14 @@ public:
/// Index operator by name, only use on DynamicAnys where isStruct /// Index operator by name, only use on DynamicAnys where isStruct
/// returns true! In all other cases a BadCastException is thrown! /// returns true! In all other cases a BadCastException is thrown!
DynamicAny& operator [] (const char* name);
/// Index operator by name, only use on DynamicAnys where isStruct
/// returns true! In all other cases a BadCastException is thrown!
const DynamicAny& operator [] (const char* name) const;
/// Index operator by name, only use on DynamicAnys where isStruct
/// returns true! In all other cases a BadCastException is thrown!
const std::type_info& type() const; const std::type_info& type() const;
/// Returns the type information of the stored content. /// Returns the type information of the stored content.
@ -442,6 +468,18 @@ inline const std::type_info& DynamicAny::type() const
} }
inline DynamicAny& DynamicAny::operator [] (const char* name)
{
return operator [] (std::string(name));
}
inline const DynamicAny& DynamicAny::operator [] (const char* name) const
{
return operator [] (std::string(name));
}
inline const DynamicAny DynamicAny::operator + (const char* other) const inline const DynamicAny DynamicAny::operator + (const char* other) const
{ {
return convert<std::string>() + other; return convert<std::string>() + other;

View File

@ -246,26 +246,6 @@ DynamicAny DynamicAny::operator -- (int)
} }
DynamicAny& DynamicAny::operator [] (std::vector<DynamicAny>::size_type n)
{
DynamicAnyHolderImpl<std::vector<DynamicAny> >* pHolder = dynamic_cast<DynamicAnyHolderImpl<std::vector<DynamicAny> > *>(_pHolder);
if (pHolder)
return pHolder->operator[](n);
else
throw BadCastException();
}
const DynamicAny& DynamicAny::operator [] (std::vector<DynamicAny>::size_type n) const
{
const DynamicAnyHolderImpl<std::vector<DynamicAny> >* pHolder = dynamic_cast<const DynamicAnyHolderImpl<std::vector<DynamicAny> > *>(_pHolder);
if (pHolder)
return pHolder->operator[](n);
else
throw BadCastException();
}
DynamicAny& DynamicAny::operator [] (const std::string& name) DynamicAny& DynamicAny::operator [] (const std::string& name)
{ {
DynamicAnyHolderImpl<DynamicStruct>* pHolder = dynamic_cast<DynamicAnyHolderImpl<DynamicStruct> *>(_pHolder); DynamicAnyHolderImpl<DynamicStruct>* pHolder = dynamic_cast<DynamicAnyHolderImpl<DynamicStruct> *>(_pHolder);

Binary file not shown.

View File

@ -1,158 +0,0 @@
//
// pocomsg.mc[.h]
//
// $Id: //poco/svn/Foundation/src/pocomsg.h#2 $
//
// The Poco message source/header file.
//
// NOTE: pocomsg.h is automatically generated from pocomsg.mc.
// Never edit pocomsg.h directly!
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
//
// Categories
//
//
// Values are 32 bit values layed out as follows:
//
// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
// +---+-+-+-----------------------+-------------------------------+
// |Sev|C|R| Facility | Code |
// +---+-+-+-----------------------+-------------------------------+
//
// where
//
// Sev - is the severity code
//
// 00 - Success
// 01 - Informational
// 10 - Warning
// 11 - Error
//
// C - is the Customer code flag
//
// R - is a reserved bit
//
// Facility - is the facility code
//
// Code - is the facility's status code
//
//
// Define the facility codes
//
//
// Define the severity codes
//
//
// MessageId: POCO_CTG_FATAL
//
// MessageText:
//
// Fatal
//
#define POCO_CTG_FATAL 0x00000001L
//
// MessageId: POCO_CTG_CRITICAL
//
// MessageText:
//
// Critical
//
#define POCO_CTG_CRITICAL 0x00000002L
//
// MessageId: POCO_CTG_ERROR
//
// MessageText:
//
// Error
//
#define POCO_CTG_ERROR 0x00000003L
//
// MessageId: POCO_CTG_WARNING
//
// MessageText:
//
// Warning
//
#define POCO_CTG_WARNING 0x00000004L
//
// MessageId: POCO_CTG_NOTICE
//
// MessageText:
//
// Notice
//
#define POCO_CTG_NOTICE 0x00000005L
//
// MessageId: POCO_CTG_INFORMATION
//
// MessageText:
//
// Information
//
#define POCO_CTG_INFORMATION 0x00000006L
//
// MessageId: POCO_CTG_DEBUG
//
// MessageText:
//
// Debug
//
#define POCO_CTG_DEBUG 0x00000007L
//
// MessageId: POCO_CTG_TRACE
//
// MessageText:
//
// Trace
//
#define POCO_CTG_TRACE 0x00000008L
//
// Event Identifiers
//
//
// MessageId: POCO_MSG_LOG
//
// MessageText:
//
// %1
//
#define POCO_MSG_LOG 0x00001000L

View File

@ -108,12 +108,12 @@ private:
{ {
TL iMin = std::numeric_limits<TS>::min(); TL iMin = std::numeric_limits<TS>::min();
Poco::DynamicAny da = iMin - 1; Poco::DynamicAny da = iMin - 1;
try { TS i; i = da; fail("must fail"); } try { TS i; i = da.convert<TS>(); fail("must fail"); }
catch (Poco::RangeException&) {} catch (Poco::RangeException&) {}
TL iMax = std::numeric_limits<TS>::max(); TL iMax = std::numeric_limits<TS>::max();
da = iMax + 1; da = iMax + 1;
try { TS i; i = da; fail("must fail"); } try { TS i; i = da.convert<TS>(); fail("must fail"); }
catch (Poco::RangeException&) {} catch (Poco::RangeException&) {}
} }
@ -126,13 +126,13 @@ private:
{ {
TL iMin = static_cast<TL>(std::numeric_limits<TS>::min()); TL iMin = static_cast<TL>(std::numeric_limits<TS>::min());
da = iMin * 10; da = iMin * 10;
try { TS i; i = da; fail("must fail"); } try { TS i; i = da.convert<TS>(); fail("must fail"); }
catch (Poco::RangeException&) {} catch (Poco::RangeException&) {}
} }
TL iMax = static_cast<TL>(std::numeric_limits<TS>::max()); TL iMax = static_cast<TL>(std::numeric_limits<TS>::max());
da = iMax * 10; da = iMax * 10;
try { TS i; i = da; fail("must fail"); } try { TS i; i = da.convert<TS>(); fail("must fail"); }
catch (Poco::RangeException&) {} catch (Poco::RangeException&) {}
} }
@ -144,7 +144,7 @@ private:
TS iMin = std::numeric_limits<TS>::min(); TS iMin = std::numeric_limits<TS>::min();
Poco::DynamicAny da = iMin; Poco::DynamicAny da = iMin;
try { TU i; i = da; fail("must fail"); } try { TU i; i = da.convert<TU>(); fail("must fail"); }
catch (Poco::RangeException&) {} catch (Poco::RangeException&) {}
} }
@ -153,7 +153,7 @@ private:
{ {
TL iMax = std::numeric_limits<TS>::max(); TL iMax = std::numeric_limits<TS>::max();
Poco::DynamicAny da = iMax + 1; Poco::DynamicAny da = iMax + 1;
try { TS i; i = da; fail("must fail"); } try { TS i; i = da.convert<TS>(); fail("must fail"); }
catch (Poco::RangeException&) {} catch (Poco::RangeException&) {}
} }
}; };