ValueInternal.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 Palmsource, Inc.
00003  * 
00004  * This software is licensed as described in the file LICENSE, which
00005  * you should have received as part of this distribution. The terms
00006  * are also available at http://www.openbinder.org/license.html.
00007  * 
00008  * This software consists of voluntary contributions made by many
00009  * individuals. For the exact contribution history, see the revision
00010  * history and logs, available at http://www.openbinder.org
00011  */
00012 
00013 // Part of the SValue implementation that BValueMap would like to use.
00014 #ifndef _VALUEINTERNAL_H_
00015 #define _VALUEINTERNAL_H_
00016 
00017 #include <support/Value.h>
00018 #include <support/SharedBuffer.h>
00019 
00020 #include <math.h>
00021 #include <ctype.h>
00022 #include <float.h>
00023 #include <new>
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 #include <string.h>
00027 
00028 #if _SUPPORTS_NAMESPACE
00029 namespace palmos {
00030 namespace support {
00031 #endif
00032 
00033 // -----------------------------------------------------------------------
00034 // -----------------------------------------------------------------------
00035 // -----------------------------------------------------------------------
00036 
00037 // Some useful compound type constants.
00038 
00039 enum {
00040     // Note -- undefined is 0, NOT a valid packed type.
00041     kUndefinedTypeCode = B_UNDEFINED_TYPE,
00042 
00043     kWildTypeCode = B_PACK_SMALL_TYPE(B_WILD_TYPE, 0),
00044     kNullTypeCode = B_PACK_SMALL_TYPE(B_NULL_TYPE, 0),
00045     kErrorTypeCode = B_PACK_SMALL_TYPE(B_ERROR_TYPE, 4),
00046     kMapTypeCode = B_TYPE_BYTEORDER_NORMAL | B_TYPE_LENGTH_MAP | B_VALUE_TYPE
00047 };
00048 
00049 #define CHECK_IS_SMALL_OBJECT(type) (((type)&(B_TYPE_LENGTH_MASK|0x00007f00)) == (sizeof(void*)|('*'<<B_TYPE_CODE_SHIFT)))
00050 #define CHECK_IS_LARGE_OBJECT(type) (((type)&(B_TYPE_LENGTH_MASK|0x00007f00)) == (B_TYPE_LENGTH_LARGE|('*'<<B_TYPE_CODE_SHIFT)))
00051 
00052 #define VALIDATE_TYPE(type) DbgOnlyFatalErrorIf(((type)&~B_TYPE_CODE_MASK) != 0, "Type codes can only use bits 0x7f7f7f00!");
00053 
00054 // Low-level inline funcs.
00055 
00056 inline bool SValue::is_defined() const
00057 {
00058     return m_type != kUndefinedTypeCode;
00059 }
00060 inline bool SValue::is_wild() const
00061 {
00062     return m_type == kWildTypeCode;
00063 }
00064 inline bool SValue::is_null() const
00065 {
00066     return m_type == kNullTypeCode;
00067 }
00068 inline bool SValue::is_error() const
00069 {
00070     return m_type == kErrorTypeCode;
00071 }
00072 inline bool SValue::is_final() const
00073 {
00074     return is_wild() || is_error();
00075 }
00076 inline bool SValue::is_simple() const
00077 {
00078     return B_UNPACK_TYPE_LENGTH(m_type) != B_TYPE_LENGTH_MAP;
00079 }
00080 inline bool SValue::is_map() const
00081 {
00082     return B_UNPACK_TYPE_LENGTH(m_type) == B_TYPE_LENGTH_MAP;
00083 }
00084 inline bool SValue::is_object() const
00085 {
00086     return CHECK_IS_SMALL_OBJECT(m_type);
00087 }
00088 inline bool SValue::is_specified() const
00089 {
00090     return is_defined() && !is_wild();
00091 }
00092 
00093 #if _SUPPORTS_NAMESPACE
00094 } } // namespace palmos::support
00095 #endif
00096 
00097 #endif /* _VALUEINTERNAL_H_ */