]> git.saurik.com Git - wxWidgets.git/blob - samples/ipc/connection.h
Fix testing for existence of paths with trailing separators in wxMSW.
[wxWidgets.git] / samples / ipc / connection.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: connection.h
3 // Purpose: DDE sample: MyConnection class
4 // Author: Vadim Zeitlin
5 // Created: 2008-02-11 (extracted from client.cpp)
6 // RCS-ID: $Id$
7 // Copyright: (c) 1999 Julian Smart
8 // 2008 Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_SAMPLE_IPC_CONNECTION_H_
13 #define _WX_SAMPLE_IPC_CONNECTION_H_
14
15 // This simple connection class adds logging of all operations
16 class MyConnectionBase : public wxConnection
17 {
18 protected:
19 void Log(const wxString& command,
20 const wxString& topic,
21 const wxString& item,
22 const void *data,
23 size_t size,
24 wxIPCFormat format)
25 {
26 wxString s;
27 if (topic.IsEmpty() && item.IsEmpty())
28 s.Printf("%s(", command.c_str());
29 else if (topic.IsEmpty())
30 s.Printf("%s(item=\"%s\",", command.c_str(), item.c_str());
31 else if (item.IsEmpty())
32 s.Printf("%s(topic=\"%s\",", command.c_str(), topic.c_str());
33 else
34 s.Printf("%s(topic=\"%s\",item=\"%s\",", command.c_str(), topic.c_str(), item.c_str());
35
36 switch (format)
37 {
38 case wxIPC_TEXT:
39 s += wxString(static_cast<const char *>(data), size);
40 break;
41
42 #if wxUSE_UNICODE
43 case wxIPC_UNICODETEXT:
44 s += wxString(static_cast<const wchar_t *>(data), size);
45 break;
46 #endif // wxUSE_UNICODE
47
48 case wxIPC_UTF8TEXT:
49 s += wxString::FromUTF8(static_cast<const char *>(data), size);
50 break;
51
52 case wxIPC_PRIVATE:
53 if ( size == 3 )
54 {
55 const char *bytes = static_cast<const char *>(data);
56 s << '"' << bytes[0] << bytes[1] << bytes[2] << '"';
57 }
58 else
59 {
60 s << "\"???\"";
61 }
62 break;
63
64 case wxIPC_INVALID:
65 s += "[invalid data]";
66 break;
67
68 default:
69 s += "[unknown data]";
70 break;
71 }
72
73 wxLogMessage("%s,%d)", s, size);
74 }
75 };
76
77 #endif // _WX_SAMPLE_IPC_CONNECTION_H_