| 38 | */ |
| 39 | template<typename MGenStreamType, typename ClassRegistryType> |
| 40 | class BinaryReader { |
| 41 | public: |
| 42 | |
| 43 | /** |
| 44 | * Constructs a BinaryReader with the given a data input stream (data source) |
| 45 | * and class registry. A third optional parameter can also be used to specify |
| 46 | * if this reader should perform extra type checking for incoming data. |
| 47 | * For situations where metadata on the wire is not actually needed, it will |
| 48 | * normally be ignored. However with the extraTypeChecking parameter set to true, |
| 49 | * redundant metadata will also be checked. |
| 50 | */ |
| 51 | BinaryReader( |
| 52 | MGenStreamType& inputStream, |
| 53 | const ClassRegistryType& classRegistry, |
| 54 | const bool extraTypeChecking = false) : |
| 55 | m_inputStream(inputStream), |
| 56 | m_classRegistry(classRegistry), |
| 57 | m_extraTypeChecking(extraTypeChecking) { |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Primary interface method for reading polymorphic objects from streams. |
| 62 | * Returns a read back object (on the heap), or NULL if an object of unknown |
| 63 | * type was received (in which case it's just skipped past in the stream). |
| 64 | */ |
| 65 | MGenBase * readObject() { |
| 66 | return readPoly(true, false, -1); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Similar to readObject(), this method also checks that the read back |
| 71 | * object is of a certain type (or base type), as specified with the |
| 72 | * template parameter. |
| 73 | */ |
| 74 | template<typename MGenType> |
| 75 | MGenType * readObject() { |
| 76 | return (MGenType*) readPoly(true, true, MGenType::_type_id); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Similar to readObject<MGenType>(), except that this method reads back |
| 81 | * the object directly to the stack and discards any potential subtype |
| 82 | * information. |
| 83 | */ |
| 84 | template<typename MGenType> |
| 85 | MGenType readStatic() { |
| 86 | MGenType out; |
| 87 | read(out, true); |
| 88 | return out; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Method called while reading the fields of an object from a data stream. |
| 93 | * When reading an object from stream, fields may appear in any order depending |
| 94 | * on the serialization format and also if the developer reorders the field |
| 95 | * in an object between different code versions. This method is what connects |
| 96 | * the field in the stream to the field on the object being read. |
| 97 | */ |
nothing calls this directly
no outgoing calls
no test coverage detected