📄 tracetool.cpp.svn-base
字号:
#endif
// bypass any path before the module name
const char * ptr ;
ptr = pmbFilename + nbChar -1;
while (ptr > pmbFilename)
{
if ((*ptr == '/') ||
(*ptr == '\\') ||
(*ptr == ':'))
{
ptr ++ ;
break ;
} else {
ptr-- ;
}
}
if ((*ptr == '/') ||
(*ptr == '\\') ||
(*ptr == ':'))
ptr ++ ;
int fileLength = strlen(ptr) + 1 ;
m_processFileName = (char *) malloc (fileLength) ;
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && (! UNDER_CE) // visual studio 2005 : deprecated function
strcpy_s (m_processFileName, fileLength, ptr) ;
#else
strcpy (m_processFileName, ptr) ;
#endif
free (pmbFilename) ;
}
return m_processFileName ;
}
//==========================================================================
/// protected constructor
WinWatch::WinWatch(void)
{
id = "" ; // Wintrace id (empty for the main window)
enabled = true ; // enable or disable watches
}
//-------------------------------------------------------------------------
WinWatch::WinWatch (const char * WinWatchID , const char * WinWatchText)
{
id = "" ; // Wintrace id (empty for the main window)
enabled = true ; // enable or disable watches
if (WinWatchID == NULL || WinWatchID == "")
id = TTrace::CreateTraceID() ;
else
id = WinWatchID ;
CommandList Commands ;
if (WinWatchText == NULL || WinWatchText == "")
Commands.Add(CST_WINWATCH_NAME, id.c_str()) ;
else
Commands.Add(CST_WINWATCH_NAME, WinWatchText) ;
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
WinWatch::WinWatch (const wchar_t * WinWatchID , const wchar_t * WinWatchText)
{
id = "" ; // Wintrace id (empty for the main window)
enabled = true ; // enable or disable watches
char * strWinWatchID = TTrace::WideToMbs(WinWatchID) ;
char * strWinWatchText = TTrace::WideToMbs(WinWatchText) ;
if (strWinWatchID == NULL || strWinWatchID == "")
id = TTrace::CreateTraceID() ;
else {
id = strWinWatchID ; // copy
}
CommandList Commands ;
if (strWinWatchText == NULL || strWinWatchText == "")
Commands.Add(CST_WINWATCH_NAME, id.c_str()) ;
else
Commands.Add(CST_WINWATCH_NAME, strWinWatchText) ;
if (strWinWatchID != NULL)
free (strWinWatchID) ;
if (strWinWatchText != NULL)
free (strWinWatchText) ;
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
void WinWatch::DisplayWin (void)
{
CommandList Commands ;
Commands.Add(CST_DISPLAY_TREE) ;
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
void WinWatch::ClearAll (void)
{
CommandList Commands ;
Commands.Add(CST_CLEAR_ALL);
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
void WinWatch::Send (const char * WatchName , const char * WatchValue)
{
if (! enabled)
return ;
CommandList Commands ;
Commands.Add(CST_WATCH_NAME, WatchName) ;
// create the member and set col1
Commands.Add(CST_CREATE_MEMBER);
// col2 is the value
Commands.Add (CST_MEMBER_COL2, WatchValue);
// close the member group
Commands.Add(CST_ADD_MEMBER);
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
void WinWatch::Send (const wchar_t * WatchName , const wchar_t * WatchValue)
{
if (! enabled)
return ;
char * strWatchName = TTrace::WideToMbs(WatchName) ;
char * strWatchValue = TTrace::WideToMbs(WatchValue) ;
CommandList Commands ;
Commands.Add(CST_WATCH_NAME, strWatchName) ;
// create the member and set col1
Commands.Add(CST_CREATE_MEMBER);
// col2 is the value
Commands.Add (CST_MEMBER_COL2, strWatchValue);
// close the member group
Commands.Add(CST_ADD_MEMBER);
if (strWatchName != NULL)
free (strWatchName) ;
if (strWatchValue != NULL)
free (strWatchValue) ;
TTrace::SendToClient (& Commands,this);
}
//==========================================================================
/// <summary>
/// WinTrace constructor. <br>
/// you can map a WinTrace to an existing window. <br>
/// Nothing Is send to the viewer
/// </summary>
WinTrace::WinTrace(void)
{
init() ;
}
//-------------------------------------------------------------------------
/// <summary>
/// WinTrace constructor. The Window Trace is create on the viewer (if not already done)
/// </summary>
/// <param name="WinTraceID">Required window trace Id. If empty, a guid will be generated</param>
/// <param name="WinTraceText">The Window Title on the viewer.If empty, a default name will be used</param>
WinTrace::WinTrace(const char * WinTraceID , const char * WinTraceTitle)
{
init() ;
if (WinTraceID == NULL || WinTraceID == "")
id = TTrace::CreateTraceID() ;
else
id = WinTraceID ;
// create the trace window
CommandList Commands ;
if (WinTraceTitle == NULL || WinTraceTitle == "")
Commands.Add (CST_TREE_NAME, id.c_str());
else
Commands.Add (CST_TREE_NAME, WinTraceTitle);
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
/// <summary>
/// WinTrace constructor. The Window Trace is create on the viewer (if not already done)
/// </summary>
/// <param name="WinTraceID">Required window trace Id. If empty, a guid will be generated</param>
/// <param name="WinTraceText">The Window Title on the viewer.If empty, a default name will be used</param>
WinTrace::WinTrace(const wchar_t * WinTraceID , const wchar_t * WinTraceTitle)
{
init() ;
char * strWinTraceID = TTrace::WideToMbs(WinTraceID) ;
char * strWinTraceTitle = TTrace::WideToMbs(WinTraceTitle) ;
if (strWinTraceID == NULL || strWinTraceID == "")
id = TTrace::CreateTraceID() ;
else
id = strWinTraceID ; // copy
// create the trace window
CommandList Commands ;
if (strWinTraceTitle == NULL || strWinTraceTitle == "")
Commands.Add (CST_TREE_NAME, id.c_str());
else
Commands.Add (CST_TREE_NAME, strWinTraceTitle);
if (strWinTraceID != NULL)
free (strWinTraceID) ;
if (strWinTraceTitle != NULL)
free (strWinTraceTitle) ;
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
/// private initialize (called by the 2 constructors)
void WinTrace::init()
{
debug = new TraceNode(NULL, false); // no parent node, don't create a GUID
error = new TraceNode(NULL, false);
warning = new TraceNode(NULL, false);
debug->iconIndex = CST_ICO_INFO; // store the iconIndex. don't add CST_ICO_INDEX command
error->iconIndex = CST_ICO_ERROR;
warning->iconIndex = CST_ICO_WARNING;
debug->winTrace = this ; // link the 3 node to the window
error->winTrace = this ;
warning->winTrace = this ;
}
//-------------------------------------------------------------------------
/// <summary>
/// Destructor
/// </summary>
WinTrace::~WinTrace(void)
{
delete debug;
delete error;
delete warning;
}
//-------------------------------------------------------------------------
/// <summary>
/// Save the window tree traces to a text file
/// </summary>
/// <param name="FileName">file to save</param>
void WinTrace::SaveToTextfile (const char * FileName)
{
CommandList Commands ;
Commands.Add(CST_SAVETOTEXT,FileName);
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
/// <summary>
/// Save the window tree traces to a text file
/// </summary>
/// <param name="FileName">file to save</param>
void WinTrace::SaveToTextfile (const wchar_t * FileName)
{
CommandList Commands ;
char * temp = TTrace::WideToMbs(FileName) ;
Commands.Add(CST_SAVETOTEXT,temp);
if (temp != NULL)
free (temp) ;
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
/// <summary>
/// Save the window tree traces to an XML file
/// </summary>
/// <param name="FileName">file to save</param>
void WinTrace::SaveToXml (const char * FileName)
{
CommandList Commands ;
Commands.Add (CST_SAVETOXML , FileName);
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
/// <summary>
/// Save the window tree traces to an XML file
/// </summary>
/// <param name="FileName">file to save</param>
void WinTrace::SaveToXml (const wchar_t * FileName)
{
CommandList Commands ;
char * temp = TTrace::WideToMbs(FileName) ;
Commands.Add (CST_SAVETOXML , temp);
if (temp != NULL)
free (temp) ;
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
/// <summary>
/// Load an XML file to the window tree traces
/// </summary>
/// <param name="FileName">file to open</param>
void WinTrace::LoadXml (const char * FileName)
{
CommandList Commands ;
Commands.Add (CST_LOADXML , FileName);
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
/// <summary>
/// Load an XML file to the window tree traces
/// </summary>
/// <param name="FileName">file to open</param>
void WinTrace::LoadXml (const wchar_t * FileName)
{
CommandList Commands ;
char * temp = TTrace::WideToMbs(FileName) ;
Commands.Add (CST_LOADXML , temp);
if (temp != NULL)
free (temp) ;
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
/// <summary>
/// Set the log file.(Path is relative to the viewer)
/// </summary>
/// <param name="FileName">file to open</param>
/// <param name="Mode"> 0 : Log is disabled. 1 : no limit. 2, daily file (with CCYYMMDD)</param>
void WinTrace::SetLogFile (const char * FileName, const int Mode)
{
CommandList Commands ;
Commands.Add (CST_LOGFILE, Mode , FileName);
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
/// <summary>
/// Set the log file.(Path is relative to the viewer)
/// </summary>
/// <param name="FileName">file to open</param>
/// <param name="Mode"> 0 : Log is disabled. 1 : no limit. 2, daily file (with CCYYMMDD)</param>
void WinTrace::SetLogFile (const wchar_t * FileName, const int Mode)
{
CommandList Commands ;
char * temp = TTrace::WideToMbs(FileName) ;
Commands.Add (CST_LOGFILE, Mode , temp);
if (temp != NULL)
free (temp) ;
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
/// <summary>
/// Show the window tree
/// </summary>
void WinTrace::DisplayWin ()
{
CommandList Commands ;
Commands.Add (CST_DISPLAY_TREE);
TTrace::SendToClient (& Commands,this);
}
//-------------------------------------------------------------------------
/// <summary>
/// change the tree to display user defined multiple columns
/// must be called before setting column titles
/// </summary>
/// <param name="MainColIndex">The Main column index (default is 0)</param>
void WinTrace::SetMultiColumn(const int MainColIndex)
{
CommandList Commands ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -