Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47891-01

coherence/io/pof/PofBufferReader.hpp

00001 /*
00002 * PofBufferReader.hpp
00003 *
00004 * Copyright (c) 2000, 2014, 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     friend class IdentityHolder;
00058 
00059     // ----- constructors ---------------------------------------------------
00060 
00061     protected:
00062         /**
00063         * Construct a new PofBufferReader that will read a POF stream from
00064         * the passed BufferInput object.
00065         *
00066         * @param hIn   a BufferInput object
00067         * @param vCtx  the PofContext
00068         *
00069         * @return the new PofBufferReader
00070         */
00071         PofBufferReader(ReadBuffer::BufferInput::Handle hIn,
00072                 PofContext::View vCtx);
00073 
00074 
00075     // ----- PofReader interface --------------------------------------------
00076 
00077     public:
00078         /**
00079         * {@inheritDoc}
00080         */
00081         virtual bool readBoolean(int32_t iProp);
00082 
00083         /**
00084         * {@inheritDoc}
00085         */
00086         virtual octet_t readOctet(int32_t iProp);
00087 
00088         /**
00089         * {@inheritDoc}
00090         */
00091         virtual char16_t readChar16(int32_t iProp);
00092 
00093         /**
00094         * {@inheritDoc}
00095         */
00096         virtual int16_t readInt16(int32_t iProp);
00097 
00098         /**
00099         * {@inheritDoc}
00100         */
00101         virtual int32_t readInt32(int32_t iProp);
00102 
00103         /**
00104         * {@inheritDoc}
00105         */
00106         virtual int64_t readInt64(int32_t iProp);
00107 
00108         /**
00109         * {@inheritDoc}
00110         */
00111         virtual float32_t readFloat32(int32_t iProp);
00112 
00113         /**
00114         * {@inheritDoc}
00115         */
00116         virtual float64_t readFloat64(int32_t iProp);
00117 
00118         /**
00119         * {@inheritDoc}
00120         */
00121         virtual Array<bool>::Handle readBooleanArray(int32_t iProp);
00122 
00123         /**
00124         * {@inheritDoc}
00125         */
00126         virtual Array<octet_t>::Handle readOctetArray(int32_t iProp);
00127 
00128         /**
00129         * {@inheritDoc}
00130         */
00131         virtual Array<char16_t>::Handle readChar16Array(int32_t iProp);
00132 
00133         /**
00134         * {@inheritDoc}
00135         */
00136         virtual Array<int16_t>::Handle readInt16Array(int32_t iProp);
00137 
00138         /**
00139         * {@inheritDoc}
00140         */
00141         virtual Array<int32_t>::Handle readInt32Array(int32_t iProp);
00142 
00143         /**
00144         * {@inheritDoc}
00145         */
00146         virtual Array<int64_t>::Handle readInt64Array(int32_t iProp);
00147 
00148         /**
00149         * {@inheritDoc}
00150         */
00151         virtual Array<float32_t>::Handle readFloat32Array(int32_t iProp);
00152 
00153         /**
00154         * {@inheritDoc}
00155         */
00156         virtual Array<float64_t>::Handle readFloat64Array(int32_t iProp);
00157 
00158         /**
00159         * {@inheritDoc}
00160         */
00161         virtual Binary::View readBinary(int32_t iProp);
00162 
00163         /**
00164         * {@inheritDoc}
00165         */
00166         virtual String::View readString(int32_t iProp);
00167 
00168         /**
00169         * {@inheritDoc}
00170         */
00171         virtual RawDate::View readRawDate(int32_t iProp);
00172 
00173         /**
00174         * {@inheritDoc}
00175         */
00176         using PofHelper::readRawDate;
00177 
00178         /**
00179         * {@inheritDoc}
00180         */
00181         virtual RawTime::View readRawTime(int32_t iProp);
00182 
00183         /**
00184         * {@inheritDoc}
00185         */
00186         using PofHelper::readRawTime;
00187 
00188         /**
00189         * {@inheritDoc}
00190         */
00191         virtual RawDateTime::View readRawDateTime(int32_t iProp);
00192 
00193         /**
00194         * {@inheritDoc}
00195         */
00196         virtual RawYearMonthInterval::View readRawYearMonthInterval(
00197                 int32_t iProp);
00198 
00199         /**
00200         * {@inheritDoc}
00201         */
00202         virtual RawTimeInterval::View readRawTimeInterval(int32_t iProp);
00203 
00204         /**
00205         * {@inheritDoc}
00206         */
00207         virtual RawDayTimeInterval::View readRawDayTimeInterval(int32_t iProp);
00208 
00209         /**
00210         * {@inheritDoc}
00211         */
00212         virtual Object::Holder readObject(int32_t iProp);
00213 
00214         /**
00215         * {@inheritDoc}
00216         */
00217         virtual ObjectArray::Handle readObjectArray(int32_t iProp,
00218                 ObjectArray::Handle ha = NULL);
00219 
00220         /**
00221         * {@inheritDoc}
00222         */
00223         virtual LongArray::View readLongArray(int32_t iProp,
00224                 LongArray::Handle hla = NULL);
00225 
00226         /**
00227         * {@inheritDoc}
00228         */
00229         virtual Collection::View readCollection(int32_t iProp,
00230                 Collection::Handle hCol = NULL);
00231 
00232         /**
00233         * {@inheritDoc}
00234         */
00235         virtual Map::View readMap(int32_t iProp, Map::Handle hMap = NULL);
00236 
00237         /**
00238         * {@inheritDoc}
00239         */
00240         virtual PofContext::View getPofContext() const;
00241 
00242         /**
00243         * {@inheritDoc}
00244         */
00245         virtual void setPofContext(PofContext::View vCtx);
00246 
00247         /**
00248         * {@inheritDoc}
00249         */
00250         virtual int32_t getUserTypeId() const;
00251 
00252         /**
00253         * {@inheritDoc}
00254         */
00255         virtual int32_t getVersionId() const;
00256 
00257         /**
00258         * {@inheritDoc}
00259         */
00260         virtual void registerIdentity(Object::Holder oh);
00261 
00262         /**
00263         * {@inheritDoc}
00264         */
00265         virtual PofReader::Handle createNestedPofReader(int32_t iProp);
00266 
00267         /**
00268         * {@inheritDoc}
00269         */
00270         virtual Binary::View readRemainder();
00271 
00272 
00273     // ----- internal methods -----------------------------------------------
00274 
00275     protected:
00276         /**
00277         * Advance through the POF stream until the specified property is
00278         * found. If the property is found, return true, otherwise return
00279         * false and advance to the first property that follows the specified
00280         * property.
00281         *
00282         * @param iProp  the index of the property to advance to
00283         *
00284         * @return true if the property is found
00285         *
00286         * @throws IllegalStateException if the POF stream has already
00287         *         advanced past the desired property
00288         * @throws IOException if an I/O error occurs
00289         */
00290         virtual bool advanceTo(int32_t iProp);
00291 
00292         /**
00293         * Register the completion of the parsing of a value.
00294         *
00295         * @param iProp  the property index
00296         *
00297         * @throws IOException if an I/O error occurs
00298         */
00299         virtual void complete(int32_t iProp);
00300 
00301         /**
00302         * If this parser is contextually within a user type, obtain the
00303         * parser which created this parser in order to parse the user type.
00304         *
00305         * @return the parser for the context within which this parser is
00306         *         operating
00307         */
00308         virtual PofBufferReader::Handle getParentParser();
00309 
00310         /**
00311         * If this parser is contextually within a user type, obtain the
00312         * parser which created this parser in order to parse the user type.
00313         *
00314         * @return the parser for the context within which this parser is
00315         *         operating
00316         */
00317         virtual PofBufferReader::View getParentParser() const;
00318 
00319         /**
00320         * Obtain the registry for identity-reference pairs, creating it if
00321         * necessary.
00322         *
00323         * @return the identity-reference registry, never NULL
00324         */
00325         virtual LongArray::Handle ensureReferenceRegistry();
00326 
00327         /**
00328         * Register the passed value with the passed identity.
00329         *
00330         * @param nId      the identity
00331         * @param ohValue  the value to register
00332         *
00333         * @throws IOException if the specified identity is already
00334         *         registered with a different object
00335         */
00336         virtual void registerIdentity(int32_t nId, Object::Holder ohValue);
00337 
00338         /**
00339         * Look up the specified identity and return the object to which it
00340         * refers.
00341         *
00342         * @param nId  the identity
00343         *
00344         * @return the object registered under that identity
00345         *
00346         * @throws IOException if the requested identity is not registered
00347         */
00348         virtual Object::Holder lookupIdentity(int32_t nId);
00349 
00350         /**
00351         * Read a POF value as an Object.
00352         *
00353         * @param nType  the type identifier of the value
00354         *
00355         * @return an Object value
00356         *
00357         * @throws IOException if an I/O error occurs
00358         */
00359         virtual Object::Holder readAsObject(int32_t nType);
00360 
00361         /**
00362         * Read a POF value in a uniform array/map as an Object.
00363         *
00364         * @param nType  the type identifier of the value
00365         *
00366         * @return an Object value
00367         *
00368         * @throws IOException if an I/O error occurs
00369         *
00370         * @since Coherence 3.7.1
00371         */
00372         virtual Object::Holder readAsUniformObject(int32_t nType);
00373 
00374         /**
00375         * Read a POF value as an Object array.
00376         *
00377         * @param nType  the type identifier of the value
00378         * @param ha     the optional <tt>ObjectArray</tt> to use to store the values, or to use
00379         *               as a typed template for creating an array to store the
00380         *               values
00381         *
00382         * @return an Object array
00383         *
00384         * @throws IOException if an I/O error occurs
00385         */
00386         virtual ObjectArray::Handle readAsObjectArray(int32_t nType,
00387                 ObjectArray::Handle ha = NULL);
00388 
00389 
00390     // ----- data members ---------------------------------------------------
00391 
00392     protected:
00393         /**
00394         * The BufferInput containing the POF stream.
00395         */
00396         FinalHandle<ReadBuffer::BufferInput> f_hIn;
00397 
00398         /**
00399         * The PofContext to use to realize user data types as objects.
00400         */
00401         FinalView<PofContext> f_vCtx;
00402 
00403         /**
00404         * Lazily-constructed mapping of identities to references.
00405         */
00406         FinalHandle<LongArray> f_hlaRefs;
00407     };
00408 
00409 COH_CLOSE_NAMESPACE3
00410 
00411 #endif // COH_POF_BUFFER_READER_HPP
Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.