libassa 3.5.1
Loading...
Searching...
No Matches
MemDump.h
Go to the documentation of this file.
1// -*- c++ -*-
2//------------------------------------------------------------------------------
3// MemDump.h
4//------------------------------------------------------------------------------
5// Copyright (c) 1995 by Vladislav Grinchenko
6//
7// This library is free software; you can redistribute it and/or
8// modify it under the terms of the GNU Library General Public
9// License as published by the Free Software Foundation; either
10// version 2 of the License, or (at your option) any later version.
11//
12// Permission to use, copy, modify, and distribute this software
13// and its documentation for any purpose and without fee is hereby
14// granted, provided that the above copyright notice appear in all
15// copies. The author makes no representations about the suitability
16// of this software for any purpose. It is provided "as is" without
17// express or implied warranty.
18//------------------------------------------------------------------------------
19// Creation Date: November 25, 1995
20//------------------------------------------------------------------------------
21#ifndef MEM_DUMP_H
22#define MEM_DUMP_H
23
24#include <stdio.h>
25#include <string.h>
26
27namespace ASSA {
28
40class MemDump
41{
42private:
44 char* m_dump;
45
47 static const char m_empty_str[];
48
49public:
58 MemDump (const char* msg_, int len_);
59
61 ~MemDump();
62
66 const char* getMemDump() const;
67
75 static void dump_to_log (unsigned long mask_,
76 const char* info_,
77 const char* msg_,
78 int len_);
79};
80
81
82inline
85{
86 if (m_dump && m_dump != m_empty_str) {
87 delete [] m_dump;
88 }
89 m_dump = NULL;
90}
91
92inline const char*
94getMemDump () const
95{
96 return (m_dump ? (const char*) m_dump : m_empty_str);
97}
98
99} // end namespace ASSA
100
101#endif /* MEM_DUMP_H */
A wrapper class to provide AutoPtr with reference semantics.
Definition AutoPtr.h:32
static const char m_empty_str[]
static Null string
Definition MemDump.h:47
const char * getMemDump() const
Obtain a pointer to the dump image (null-terminated char string).
Definition MemDump.h:94
~MemDump()
Destructor releases image memory.
Definition MemDump.h:84
char * m_dump
pointer to converted image
Definition MemDump.h:44
static void dump_to_log(unsigned long mask_, const char *info_, const char *msg_, int len_)
Write hex/ascii dump of a memory region to log file.
Definition MemDump.cpp:111