Oracle Coherence for C++ API
Release 3.6.0.0
E15728-01

- Main Page
- Namespaces
- Classes
- Files

# coherence/io/pof/PofBufferReader.hpp

    00001 /*
    00002 * PofBufferReader.hpp
    00003 *
    00004 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    00005 *
    00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
    00007 * affiliates.
    00008 *
    00009 * This software is the confidential and proprietary information of Oracle
    00010 * Corporation. You shall not disclose such confidential and proprietary
    00011 * information and shall use it only in accordance with the terms of the
    00012 * license agreement you entered into with Oracle.
    00013 *
    00014 * This notice may not be removed or altered.
    00015 */
    00016 #ifndef COH_POF_BUFFER_READER_HPP
    00017 #define COH_POF_BUFFER_READER_HPP
    00018
    00019 #include "coherence/lang.ns"
    00020
    00021 #include "coherence/io/ReadBuffer.hpp"
    00022 #include "coherence/io/pof/PofContext.hpp"
    00023 #include "coherence/io/pof/PofHelper.hpp"
    00024 #include "coherence/io/pof/PofReader.hpp"
    00025 #include "coherence/io/pof/RawDate.hpp"
    00026 #include "coherence/io/pof/RawDateTime.hpp"
    00027 #include "coherence/io/pof/RawDayTimeInterval.hpp"
    00028 #include "coherence/io/pof/RawTime.hpp"
    00029 #include "coherence/io/pof/RawTimeInterval.hpp"
    00030 #include "coherence/io/pof/RawYearMonthInterval.hpp"
    00031 #include "coherence/util/Binary.hpp"
    00032 #include "coherence/util/Collection.hpp"
    00033 #include "coherence/util/LongArray.hpp"
    00034 #include "coherence/util/Map.hpp"
    00035
    00036 COH_OPEN_NAMESPACE3(coherence,io,pof)
    00037
    00038 using coherence::io::ReadBuffer;
    00039 using coherence::util::Binary;
    00040 using coherence::util::Collection;
    00041 using coherence::util::LongArray;
    00042 using coherence::util::Map;
    00043
    00044
    00045 /**
    00046 * PofReader implementation that reads POF-encoded data from a
    00047 * ReadBuffer::BufferInput.
    00048 *
    00049 * @author jh  2008.04.09
    00050 */
    00051 class COH_EXPORT PofBufferReader
    00052     : public class_spec<PofBufferReader,
    00053         extends<PofHelper>,
    00054         implements<PofReader> >
    00055     {
    00056     friend class factory<PofBufferReader>;
    00057
    00058     // ----- constructors ---------------------------------------------------
    00059
    00060     protected:
    00061         /**
    00062         * Construct a new PofBufferReader that will read a POF stream from
    00063         * the passed BufferInput object.
    00064         *
    00065         * @param hIn   a BufferInput object
    00066         * @param vCtx  the PofContext
    00067         *
    00068         * @return the new PofBufferReader
    00069         */
    00070         PofBufferReader(ReadBuffer::BufferInput::Handle hIn,
    00071                 PofContext::View vCtx);
    00072
    00073
    00074     // ----- PofReader interface --------------------------------------------
    00075
    00076     public:
    00077         /**
    00078         * {@inheritDoc}
    00079         */
    00080         virtual bool readBoolean(int32_t iProp);
    00081
    00082         /**
    00083         * {@inheritDoc}
    00084         */
    00085         virtual octet_t readOctet(int32_t iProp);
    00086
    00087         /**
    00088         * {@inheritDoc}
    00089         */
    00090         virtual char16_t readChar16(int32_t iProp);
    00091
    00092         /**
    00093         * {@inheritDoc}
    00094         */
    00095         virtual int16_t readInt16(int32_t iProp);
    00096
    00097         /**
    00098         * {@inheritDoc}
    00099         */
    00100         virtual int32_t readInt32(int32_t iProp);
    00101
    00102         /**
    00103         * {@inheritDoc}
    00104         */
    00105         virtual int64_t readInt64(int32_t iProp);
    00106
    00107         /**
    00108         * {@inheritDoc}
    00109         */
    00110         virtual float32_t readFloat32(int32_t iProp);
    00111
    00112         /**
    00113         * {@inheritDoc}
    00114         */
    00115         virtual float64_t readFloat64(int32_t iProp);
    00116
    00117         /**
    00118         * {@inheritDoc}
    00119         */
    00120         virtual Array<bool>::Handle readBooleanArray(int32_t iProp);
    00121
    00122         /**
    00123         * {@inheritDoc}
    00124         */
    00125         virtual Array<octet_t>::Handle readOctetArray(int32_t iProp);
    00126
    00127         /**
    00128         * {@inheritDoc}
    00129         */
    00130         virtual Array<char16_t>::Handle readChar16Array(int32_t iProp);
    00131
    00132         /**
    00133         * {@inheritDoc}
    00134         */
    00135         virtual Array<int16_t>::Handle readInt16Array(int32_t iProp);
    00136
    00137         /**
    00138         * {@inheritDoc}
    00139         */
    00140         virtual Array<int32_t>::Handle readInt32Array(int32_t iProp);
    00141
    00142         /**
    00143         * {@inheritDoc}
    00144         */
    00145         virtual Array<int64_t>::Handle readInt64Array(int32_t iProp);
    00146
    00147         /**
    00148         * {@inheritDoc}
    00149         */
    00150         virtual Array<float32_t>::Handle readFloat32Array(int32_t iProp);
    00151
    00152         /**
    00153         * {@inheritDoc}
    00154         */
    00155         virtual Array<float64_t>::Handle readFloat64Array(int32_t iProp);
    00156
    00157         /**
    00158         * {@inheritDoc}
    00159         */
    00160         virtual Binary::View readBinary(int32_t iProp);
    00161
    00162         /**
    00163         * {@inheritDoc}
    00164         */
    00165         virtual String::View readString(int32_t iProp);
    00166
    00167         /**
    00168         * {@inheritDoc}
    00169         */
    00170         virtual RawDate::View readRawDate(int32_t iProp);
    00171
    00172         /**
    00173         * {@inheritDoc}
    00174         */
    00175         using PofHelper::readRawDate;
    00176
    00177         /**
    00178         * {@inheritDoc}
    00179         */
    00180         virtual RawTime::View readRawTime(int32_t iProp);
    00181
    00182         /**
    00183         * {@inheritDoc}
    00184         */
    00185         using PofHelper::readRawTime;
    00186
    00187         /**
    00188         * {@inheritDoc}
    00189         */
    00190         virtual RawDateTime::View readRawDateTime(int32_t iProp);
    00191
    00192         /**
    00193         * {@inheritDoc}
    00194         */
    00195         virtual RawYearMonthInterval::View readRawYearMonthInterval(
    00196                 int32_t iProp);
    00197
    00198         /**
    00199         * {@inheritDoc}
    00200         */
    00201         virtual RawTimeInterval::View readRawTimeInterval(int32_t iProp);
    00202
    00203         /**
    00204         * {@inheritDoc}
    00205         */
    00206         virtual RawDayTimeInterval::View readRawDayTimeInterval(int32_t iProp);
    00207
    00208         /**
    00209         * {@inheritDoc}
    00210         */
    00211         virtual Object::Holder readObject(int32_t iProp);
    00212
    00213         /**
    00214         * {@inheritDoc}
    00215         */
    00216         virtual ObjectArray::Handle readObjectArray(int32_t iProp);
    00217
    00218         /**
    00219         * {@inheritDoc}
    00220         */
    00221         virtual LongArray::View readLongArray(int32_t iProp,
    00222                 LongArray::Handle hla = NULL);
    00223
    00224         /**
    00225         * {@inheritDoc}
    00226         */
    00227         virtual Collection::View readCollection(int32_t iProp,
    00228                 Collection::Handle hCol = NULL);
    00229
    00230         /**
    00231         * {@inheritDoc}
    00232         */
    00233         virtual Map::View readMap(int32_t iProp, Map::Handle hMap = NULL);
    00234
    00235         /**
    00236         * {@inheritDoc}
    00237         */
    00238         virtual PofContext::View getPofContext() const;
    00239
    00240         /**
    00241         * {@inheritDoc}
    00242         */
    00243         virtual void setPofContext(PofContext::View vCtx);
    00244
    00245         /**
    00246         * {@inheritDoc}
    00247         */
    00248         virtual int32_t getUserTypeId() const;
    00249
    00250         /**
    00251         * {@inheritDoc}
    00252         */
    00253         virtual int32_t getVersionId() const;
    00254
    00255         /**
    00256         * {@inheritDoc}
    00257         */
    00258         virtual Binary::View readRemainder();
    00259
    00260
    00261     // ----- internal methods -----------------------------------------------
    00262
    00263     protected:
    00264         /**
    00265         * Advance through the POF stream until the specified property is
    00266         * found. If the property is found, return true, otherwise return
    00267         * false and advance to the first property that follows the specified
    00268         * property.
    00269         *
    00270         * @param iProp  the index of the property to advance to
    00271         *
    00272         * @return true if the property is found
    00273         *
    00274         * @throws IllegalStateException if the POF stream has already
    00275         *         advanced past the desired property
    00276         * @throws IOException if an I/O error occurs
    00277         */
    00278         virtual bool advanceTo(int32_t iProp);
    00279
    00280         /**
    00281         * Register the completion of the parsing of a value.
    00282         *
    00283         * @param iProp  the property index
    00284         *
    00285         * @throws IOException if an I/O error occurs
    00286         */
    00287         virtual void complete(int32_t iProp);
    00288
    00289         /**
    00290         * If this parser is contextually within a user type, obtain the
    00291         * parser which created this parser in order to parse the user type.
    00292         *
    00293         * @return the parser for the context within which this parser is
    00294         *         operating
    00295         */
    00296         virtual Handle getParentParser();
    00297
    00298         /**
    00299         * If this parser is contextually within a user type, obtain the
    00300         * parser which created this parser in order to parse the user type.
    00301         *
    00302         * @return the parser for the context within which this parser is
    00303         *         operating
    00304         */
    00305         virtual View getParentParser() const;
    00306
    00307         /**
    00308         * Obtain the registry for identity-reference pairs, creating it if
    00309         * necessary.
    00310         *
    00311         * @return the identity-reference registry, never NULL
    00312         */
    00313         virtual LongArray::Handle ensureReferenceRegistry();
    00314
    00315         /**
    00316         * Register the passed value with the passed identity.
    00317         *
    00318         * @param nId      the identity
    00319         * @param ohValue  the value to register
    00320         *
    00321         * @throws IOException if the specified identity is already
    00322         *         registered
    00323         */
    00324         virtual void registerIdentity(int32_t nId, Object::Holder ohValue);
    00325
    00326         /**
    00327         * Look up the specified identity and return the object to which it
    00328         * refers.
    00329         *
    00330         * @param nId  the identity
    00331         *
    00332         * @return the object registered under that identity
    00333         *
    00334         * @throws IOException if the requested identity is not registered
    00335         */
    00336         virtual Object::Holder lookupIdentity(int32_t nId);
    00337
    00338         /**
    00339         * Read a POF value as an Object.
    00340         *
    00341         * @param nType  the type identifier of the value
    00342         *
    00343         * @return an Object value
    00344         *
    00345         * @throws IOException if an I/O error occurs
    00346         */
    00347         virtual Object::Holder readAsObject(int32_t nType);
    00348
    00349         /**
    00350         * Read a POF value as an Object array.
    00351         *
    00352         * @param nType  the type identifier of the value
    00353         *
    00354         * @return an Object array
    00355         *
    00356         * @throws IOException if an I/O error occurs
    00357         */
    00358         virtual ObjectArray::Handle readAsObjectArray(int32_t nType);
    00359
    00360
    00361     // ----- data members ---------------------------------------------------
    00362
    00363     protected:
    00364         /**
    00365         * The BufferInput containing the POF stream.
    00366         */
    00367         MemberHandle<ReadBuffer::BufferInput> m_hIn;
    00368
    00369         /**
    00370         * The PofContext to use to realize user data types as objects.
    00371         */
    00372         MemberView<PofContext> m_vCtx;
    00373
    00374         /**
    00375         * Lazily-constructed mapping of identities to references.
    00376         */
    00377         MemberHandle<LongArray> m_hlaRefs;
    00378     };
    00379
    00380 COH_CLOSE_NAMESPACE3
    00381
    00382 #endif // COH_POF_BUFFER_READER_HPP

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.