1 /* 2 * Copyright (C) 2007 Esmertec AG. 3 * Copyright (C) 2007 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #ifndef IMPS_ENCODER_H 19 #define IMPS_ENCODER_H 20 21 #include "wbxml_encoder.h" 22 #include "wbxml_stl.h" 23 24 class ImpsWbxmlEncoder : public WbxmlEncoder 25 { 26 public: 27 ImpsWbxmlEncoder(int publicid) : 28 WbxmlEncoder(publicid) 29 { 30 reset(); 31 } 32 33 /** 34 * Reset the encoder so it can be used for encoding next document. 35 */ 36 void reset(); 37 38 EncoderError startElement(const char *name, const char **atts); 39 40 EncoderError characters(const char *chars, int len); 41 42 /** 43 * Send OPAQUE data to the encoder. Should only be used for ContentData. 44 * The application should choose to encode ContentData either by characters() 45 * when the ContentType is text (e.g. text/plain) or by opaque() if the 46 * ContentType is of some binary types. 47 * WBXML Integer and DateTime are automatically converted to opaque data 48 * in characters() so there's no need for the application to use opaque() 49 * for these types. 50 */ 51 EncoderError opaque(const char *chars, int len); 52 53 EncoderError endElement(); 54 55 private: 56 int mTagCodePage; 57 string mCurrElement; 58 int mDepth; 59 60 EncoderError encodeString(const char *chars, int len); 61 EncoderError encodeAttrib(const char *name, const char *value); 62 }; 63 64 #endif 65 66