CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

callstack.h

Go to the documentation of this file.
00001 /*
00002   Call stack creation helper
00003   Copyright (C) 2004 by Jorrit Tyberghein
00004             (C) 2004 by Frank Richter
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Library General Public
00008   License as published by the Free Software Foundation; either
00009   version 2 of the License, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Library General Public License for more details.
00015 
00016   You should have received a copy of the GNU Library General Public
00017   License along with this library; if not, write to the Free
00018   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 #ifndef __CS_UTIL_CALLSTACK_H__
00021 #define __CS_UTIL_CALLSTACK_H__
00022 
00027 /*
00028  @@@ Not implemented on all platforms yet!
00029  */
00030  
00031 #include "csextern.h"
00032 #include "csutil/csstring.h"
00033 
00034 // @@@ Document me
00035 class CS_CSUTIL_EXPORT csCallStack
00036 {
00037 protected:
00038   virtual ~csCallStack() {}
00039 public:
00040   virtual void Free() { delete this; }
00041   
00042   virtual size_t GetEntryCount () = 0;
00043   virtual bool GetFunctionName (size_t num, csString& str) = 0;
00044   virtual bool GetLineNumber (size_t num, csString& str) = 0;
00045   virtual bool GetParameters (size_t num, csString& str) = 0;
00046   void Print (FILE* f = stdout, bool Short = false)
00047   {
00048     for (size_t i = 0; i < GetEntryCount(); i++)
00049     {
00050       csString s;
00051       bool hasFunc = GetFunctionName (i, s);
00052       fprintf (f, "%s", hasFunc ? (const char*)s : "<unknown>");
00053       if (!Short && (GetLineNumber (i, s)))
00054         fprintf (f, " @%s", (const char*)s);
00055       if (!Short && (GetParameters (i, s)))
00056         fprintf (f, " (%s)", (const char*)s);
00057       fprintf (f, "\n");
00058     }
00059     fflush (f);
00060   }
00061 };
00062 
00063 // @@@ Document me
00064 class CS_CSUTIL_EXPORT csCallStackHelper
00065 {
00066 public:
00075   static csCallStack* CreateCallStack (int skip = 0);
00076 };
00077 
00078 #endif // __CS_UTIL_CALLSTACK_H__

Generated for Crystal Space by doxygen 1.3.9.1