00001 /** 00002 * @file dp_parser.cc 00003 * @author Nicolas VIVIEN 00004 * @date 2009-08-01 00005 * 00006 * @note CopyRight Nicolas VIVIEN 00007 * 00008 * @brief COD debug file parser 00009 * RIM's JDE generates several files when you build a COD application. 00010 * Indeed, with the COD files for the device, we have a ".debug" file. 00011 * This file is usefull to debug an application from JVM. 00012 * This tool is a parser to understand these ".debug" files. 00013 * Obviously, the file contents only some strings and 32 bits words. 00014 * 00015 * @par Modifications 00016 * - 2009/08/01 : N. VIVIEN 00017 * - First release 00018 * 00019 * @par Licences 00020 * Copyright (C) 2009-2010, Nicolas VIVIEN 00021 * 00022 * This program is free software; you can redistribute it and/or modify 00023 * it under the terms of the GNU General Public License as published by 00024 * the Free Software Foundation; either version 2 of the License, or 00025 * (at your option) any later version. 00026 * 00027 * This program is distributed in the hope that it will be useful, 00028 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00029 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00030 * 00031 * See the GNU General Public License in the COPYING file at the 00032 * root directory of this project for more details. 00033 */ 00034 00035 00036 #include <iostream> 00037 #include <stdlib.h> 00038 #include "dp_parser.h" 00039 #include "endian.h" 00040 00041 00042 using namespace std; 00043 00044 00045 namespace Barry { 00046 00047 namespace JDG { 00048 00049 00050 string ParseString(istream &input, const int length) 00051 { 00052 int i; 00053 string str; 00054 00055 for (i=0; i<length; i++) { 00056 uint16_t value; 00057 00058 input.read((char *) &value, sizeof(uint16_t)); 00059 00060 str += (char) be_btohs(value); 00061 } 00062 00063 return str; 00064 } 00065 00066 00067 uint32_t ParseInteger(istream &input) 00068 { 00069 uint32_t value; 00070 00071 input.read((char *) &value, sizeof(uint32_t)); 00072 00073 return be_btohl(value); 00074 } 00075 00076 00077 } // namespace JDG 00078 00079 } // namespace Barry 00080 00081