00001 /* 00002 * Copyright (C) 2003-2007 Funambol, Inc 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License version 2 as 00006 * published by the Free Software Foundation. 00007 * 00008 * This program is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY, TITLE, NONINFRINGEMENT or FITNESS FOR A PARTICULAR 00011 * PURPOSE. See the GNU General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program; if not, write to the Free Software 00015 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00016 * 02111-1307 USA 00017 */ 00018 00019 00020 #ifndef INCL_VIRTUAL_CONVERTER 00021 #define INCL_VIRTUAL_CONVERTER 00022 00024 #include "VObject.h" 00025 00026 class VConverter{ 00027 00028 public: 00029 static VObject* parse(const WCHAR* buffer); 00030 00031 private: 00032 static VProperty* readFieldHeader(WCHAR* buffer); 00033 static bool readFieldBody(WCHAR* buffer, VProperty* property); 00034 00035 // Extract the parameter of certain properties, e.g. "BEGIN:" or "VERSION:". 00036 // The result is a pointer into buffCopy, which is expected to have 00037 // buffCopyLen wchars and will be reallocated if necessary. 00038 static WCHAR* extractObjectProperty(const WCHAR* buffer, const WCHAR *property, 00039 WCHAR * &buffCopy, size_t &buffCopyLen); 00040 00041 // extractObjectType() and extractObjectVersion() contain static buffers, 00042 // copy the result before calling these functions again! 00043 static WCHAR* extractObjectType(const WCHAR* buffer); 00044 static WCHAR* extractObjectVersion(const WCHAR* buffer); 00045 static bool extractGroup(WCHAR* propertyName, WCHAR* propertyGroup); 00046 00047 }; 00049 #endif