CrystalSpace

Public API Reference

csutil/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 #include "csextern.h"
00028 #include "csutil/csstring.h"
00029 
00031 class CS_CRYSTALSPACE_EXPORT csCallStack
00032 {
00033 protected:
00034   virtual ~csCallStack() {}
00035 public:
00039   virtual void Free() = 0;
00040   
00042   virtual size_t GetEntryCount () = 0;
00048   virtual bool GetFunctionName (size_t num, csString& str) = 0;
00054   virtual bool GetLineNumber (size_t num, csString& str) = 0;
00059   virtual bool GetParameters (size_t num, csString& str) = 0;
00065   void Print (FILE* f = stdout, bool brief = false)
00066   {
00067     for (size_t i = 0; i < GetEntryCount(); i++)
00068     {
00069       csString s;
00070       bool hasFunc = GetFunctionName (i, s);
00071       fprintf (f, "%s", hasFunc ? (const char*)s : "<unknown>");
00072       if (!brief && (GetLineNumber (i, s)))
00073         fprintf (f, " @%s", (const char*)s);
00074       if (!brief && (GetParameters (i, s)))
00075         fprintf (f, " (%s)", (const char*)s);
00076       fprintf (f, "\n");
00077     }
00078     fflush (f);
00079   }
00085   csString GetEntryAll (size_t i, bool brief = false)
00086   {
00087     csString line;
00088     csString s;
00089     bool hasFunc = GetFunctionName (i, s);
00090     line << (hasFunc ? (const char*)s : "<unknown>");
00091     if (!brief && GetLineNumber (i, s))
00092       line << " @" << s;
00093     if (!brief && GetParameters (i, s))
00094       line << " (" << s << ")";
00095     return line;
00096   }
00097 };
00098 
00100 class CS_CRYSTALSPACE_EXPORT csCallStackHelper
00101 {
00102 public:
00114   static csCallStack* CreateCallStack (int skip = 0, bool fast = false);
00115 };
00116 
00117 #endif // __CS_UTIL_CALLSTACK_H__

Generated for Crystal Space 1.2.1 by doxygen 1.5.3