1/* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef SYNCML_DM_READER_H 18#define SYNCML_DM_READER_H 19 20#ifndef __cplusplus 21#error "This is a C++ header file; it requires C++ to compile." 22#endif 23 24/*================================================================================================== 25 26 Header Name: SyncML_DM_Reader.H 27 28 General Description: ABC class for all readers of tree data. This class does not 29 possess a .cc file since there are two functions with little content. 30 31==================================================================================================*/ 32 33#include "SyncML_DM_FileHandle.H" 34 35class DMAddNodeProp; 36 37class SyncML_DM_Reader 38{ 39 40public: 41 42 /* Class constructor */ 43 SyncML_DM_Reader(DMFileHandler* handle) : fileHandle(handle){ } 44 45 /* Class destructor */ 46 virtual ~SyncML_DM_Reader(){ } 47 48 /* Accessor for setting the file handle used by the class' utilities */ 49 virtual void setFileHandle(DMFileHandler* fileHandle){ this->fileHandle = fileHandle; } 50 51 /* Read a byte into the argument of this function 52 * pure virtual method. Implementations of Reader must override 53 */ 54 virtual SYNCML_DM_RET_STATUS_T readByte(UINT8* bYte) = 0; 55 56 /* Read a tree node into the data structure pointer argument and 57 * return the next byte read 58 * 59 * This function allocates the memory returned in its node argument 60 * The stopByte is defined by the calling function and its pointer is passed. 61 */ 62 virtual SYNCML_DM_RET_STATUS_T readNode(DMAddNodeProp* node, UINT8* stopByte) = 0; 63 64protected: 65 66 /* The file handle used by this object. 67 * As implemented, this class requires the user to open a file "on the side" 68 * and set this variable so then the writer can work on the file. The caller 69 * is responsinble for closing the file and freeing the handle. 70 */ 71 DMFileHandler* fileHandle; 72 73}; 74 75#endif /* SYNCML_DM_READER_H */ 76