j_jdwp.h

Go to the documentation of this file.
00001 ///
00002 /// \file       j_jdwp.h
00003 ///             JDWP classes
00004 ///
00005 
00006 /*
00007     Copyright (C) 2009, Nicolas VIVIEN
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018     See the GNU General Public License in the COPYING file at the
00019     root directory of this project for more details.
00020 */
00021 
00022 #ifndef __BARRYJDWP_JDWP_H__
00023 #define __BARRYJDWP_JDWP_H__
00024 
00025 #include "error.h"
00026 
00027 namespace Barry {
00028 
00029 // forward declarations
00030 class Data;
00031 
00032 namespace JDWP {
00033 
00034 /// \addtogroup exceptions
00035 /// @{
00036 
00037 /// Thrown on low level JDWP errors.
00038 class BXEXPORT Error : public Barry::Error
00039 {
00040         int m_errcode;
00041 
00042 public:
00043         Error(const std::string &str);
00044         Error(int errcode, const std::string &str);
00045 
00046         // can return 0 in some case, if unknown error code
00047         int errcode() const { return m_errcode; }
00048 };
00049 
00050 class BXEXPORT Timeout : public Error
00051 {
00052 public:
00053         Timeout(const std::string &str) : Error(str) {}
00054         Timeout(int errcode, const std::string &str)
00055                 : Error(errcode, str) {}
00056 };
00057 
00058 /// @}
00059 
00060 
00061 
00062 class JDWP
00063 {
00064 private:
00065         int m_lasterror;
00066 
00067 protected:
00068 
00069 public:
00070         JDWP();
00071         ~JDWP();
00072 
00073         bool Read(int socket, Barry::Data &data, int timeout = -1);
00074         bool Write(int socket, const Barry::Data &data, int timeout = -1);
00075         bool Write(int socket, const void *data, size_t size, int timeout = -1);
00076 };
00077 
00078 }} // namespace Barry::JDWP
00079 
00080 #endif
00081