gosu 0.7.25-universal-darwin → 0.7.26-universal-darwin
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING.txt +1 -1
- data/Gosu/Async.hpp +48 -0
- data/Gosu/Audio.hpp +165 -0
- data/Gosu/AutoLink.hpp +16 -0
- data/Gosu/Bitmap.hpp +85 -0
- data/Gosu/ButtonsMac.hpp +140 -0
- data/Gosu/ButtonsWin.hpp +140 -0
- data/Gosu/ButtonsX.hpp +141 -0
- data/Gosu/Color.hpp +202 -0
- data/Gosu/Directories.hpp +36 -0
- data/Gosu/Font.hpp +74 -0
- data/Gosu/Fwd.hpp +30 -0
- data/Gosu/Gosu.hpp +33 -0
- data/Gosu/Graphics.hpp +118 -0
- data/Gosu/GraphicsBase.hpp +69 -0
- data/Gosu/IO.hpp +252 -0
- data/Gosu/Image.hpp +136 -0
- data/Gosu/ImageData.hpp +49 -0
- data/Gosu/Input.hpp +162 -0
- data/Gosu/Math.hpp +135 -0
- data/Gosu/Platform.hpp +73 -0
- data/Gosu/Sockets.hpp +139 -0
- data/Gosu/Text.hpp +71 -0
- data/Gosu/TextInput.hpp +70 -0
- data/Gosu/Timing.hpp +16 -0
- data/Gosu/Utility.hpp +25 -0
- data/Gosu/Version.hpp +9 -0
- data/Gosu/WinUtility.hpp +76 -0
- data/Gosu/Window.hpp +124 -0
- data/lib/gosu.for_1_8.bundle +0 -0
- data/lib/gosu.for_1_9.bundle +0 -0
- data/lib/gosu/patches.rb +13 -13
- metadata +32 -4
data/Gosu/Platform.hpp
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
//! \file Platform.hpp
|
2
|
+
//! Macros and utility functions to facilitate programming on all of Gosu's supported platforms.
|
3
|
+
|
4
|
+
#ifndef GOSU_PLATFORM_HPP
|
5
|
+
#define GOSU_PLATFORM_HPP
|
6
|
+
|
7
|
+
#ifdef __BIG_ENDIAN__
|
8
|
+
#define GOSU_IS_BIG_ENDIAN
|
9
|
+
#define IDENTITY_FUN bigToNative
|
10
|
+
#define IDENTITY_FUN2 nativeToBig
|
11
|
+
#define CONV_FUN littleToNative
|
12
|
+
#define CONV_FUN2 nativeToLittle
|
13
|
+
#else
|
14
|
+
#define GOSU_IS_LITTLE_ENDIAN
|
15
|
+
#define IDENTITY_FUN littleToNative
|
16
|
+
#define IDENTITY_FUN2 nativeToLittle
|
17
|
+
#define CONV_FUN bigToNative
|
18
|
+
#define CONV_FUN2 nativeToBig
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#include <algorithm>
|
22
|
+
|
23
|
+
namespace Gosu
|
24
|
+
{
|
25
|
+
template<typename T> T IDENTITY_FUN(T t) { return t; }
|
26
|
+
template<typename T> T IDENTITY_FUN2(T t) { return t; }
|
27
|
+
|
28
|
+
template<typename T>
|
29
|
+
T CONV_FUN(T t)
|
30
|
+
{
|
31
|
+
char* begin = reinterpret_cast<char*>(&t);
|
32
|
+
std::reverse(begin, begin + sizeof t);
|
33
|
+
return t;
|
34
|
+
}
|
35
|
+
|
36
|
+
template<typename T> T CONV_FUN2(T t) { return CONV_FUN(t); }
|
37
|
+
}
|
38
|
+
|
39
|
+
#undef IDENTITY_FUN
|
40
|
+
#undef IDENTITY_FUN2
|
41
|
+
#undef CONV_FUN
|
42
|
+
#undef CONV_FUN2
|
43
|
+
|
44
|
+
#if defined(_MSC_VER)
|
45
|
+
#define GOSU_NORETURN __declspec(noreturn)
|
46
|
+
#elif defined(__GNUC__)
|
47
|
+
#define GOSU_NORETURN __attribute__ ((noreturn))
|
48
|
+
#endif
|
49
|
+
|
50
|
+
#if defined(WIN32)
|
51
|
+
# define GOSU_IS_WIN
|
52
|
+
#else
|
53
|
+
# define GOSU_IS_UNIX
|
54
|
+
# if defined(__linux) || defined(__FreeBSD__)
|
55
|
+
# define GOSU_IS_X
|
56
|
+
# else
|
57
|
+
# define GOSU_IS_MAC
|
58
|
+
# include <TargetConditionals.h>
|
59
|
+
# if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
60
|
+
# define GOSU_IS_IPHONE
|
61
|
+
# endif
|
62
|
+
# endif
|
63
|
+
#endif
|
64
|
+
|
65
|
+
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
66
|
+
# define GOSU_DEPRECATED __attribute__((__deprecated__))
|
67
|
+
#elif defined(GOSU_IS_WIN)
|
68
|
+
# define GOSU_DEPRECATED __declspec(deprecated)
|
69
|
+
#else
|
70
|
+
# define GOSU_DEPRECATED
|
71
|
+
#endif
|
72
|
+
|
73
|
+
#endif
|
data/Gosu/Sockets.hpp
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
//! \file Sockets.hpp
|
2
|
+
//! Interface of the three socket classes, MessageSocket, CommSocket and ListenerSocket.
|
3
|
+
|
4
|
+
#ifndef GOSU_SOCKETS_HPP
|
5
|
+
#define GOSU_SOCKETS_HPP
|
6
|
+
|
7
|
+
#include <boost/cstdint.hpp>
|
8
|
+
#include <boost/function.hpp>
|
9
|
+
#include <boost/scoped_ptr.hpp>
|
10
|
+
#include <cstddef>
|
11
|
+
#include <string>
|
12
|
+
|
13
|
+
namespace Gosu
|
14
|
+
{
|
15
|
+
//! Addresses are returned from and given to Gosu functions in host byte order.
|
16
|
+
typedef boost::uint32_t SocketAddress;
|
17
|
+
|
18
|
+
//! Ports are returned from and given to Gosu functions in host byte order.
|
19
|
+
typedef boost::uint16_t SocketPort;
|
20
|
+
|
21
|
+
//! Constant that can be used as a placeholder for an arbitrary port, e.g. when
|
22
|
+
//! starting to listen.
|
23
|
+
const SocketPort anyPort = 0;
|
24
|
+
|
25
|
+
//! Tries to convert a dotted IP4 string into an address suitable for
|
26
|
+
//! socket functions. If the string supplied is not such a string, it
|
27
|
+
//! tries to look up the host via DNS. If both methods fail, zero is
|
28
|
+
//! returned.
|
29
|
+
SocketAddress stringToAddress(const std::string& s);
|
30
|
+
//! Converts an address into a dotted IP4 string.
|
31
|
+
std::string addressToString(SocketAddress address);
|
32
|
+
|
33
|
+
//! Wraps an UDP socket. Message sockets can send data to and receive
|
34
|
+
//! data from arbitrary addresses. Also, message sockets send messages
|
35
|
+
//! (packets) which are limited in size and can arrive in any order, or
|
36
|
+
//! not at all.
|
37
|
+
class MessageSocket
|
38
|
+
{
|
39
|
+
struct Impl;
|
40
|
+
boost::scoped_ptr<Impl> pimpl;
|
41
|
+
|
42
|
+
public:
|
43
|
+
//! Opens a message socket for listening at the specified port.
|
44
|
+
//! Gosu::anyPort may be passed to have the message socket use
|
45
|
+
//! a random free port.
|
46
|
+
explicit MessageSocket(SocketPort port);
|
47
|
+
~MessageSocket();
|
48
|
+
|
49
|
+
//! Returns the local address of the socket.
|
50
|
+
SocketAddress address() const;
|
51
|
+
//! Returns the local port of the socket.
|
52
|
+
SocketPort port() const;
|
53
|
+
//! Returns the maximum size, in bytes, of a packet that can be sent
|
54
|
+
//! from this socket.
|
55
|
+
std::size_t maxMessageSize() const;
|
56
|
+
|
57
|
+
//! Collects all the packets that were sent to this socket and
|
58
|
+
//! calls onReceive for each of them.
|
59
|
+
void update();
|
60
|
+
|
61
|
+
//! Sends something to the given port of the computer identified
|
62
|
+
//! by the address.
|
63
|
+
void send(SocketAddress address, SocketPort port,
|
64
|
+
const void* buffer, std::size_t size);
|
65
|
+
/*void broadcast(SocketPort port, const void* buffer,
|
66
|
+
std::size_t size);*/
|
67
|
+
|
68
|
+
//! If assigned, will be called by update for every packet received.
|
69
|
+
boost::function<void (SocketAddress, SocketPort, const void*,
|
70
|
+
std::size_t)> onReceive;
|
71
|
+
};
|
72
|
+
|
73
|
+
//! Defines the way in which data is collected until the onReceive event
|
74
|
+
//! is called for CommSockets.
|
75
|
+
enum CommMode
|
76
|
+
{
|
77
|
+
cmRaw,
|
78
|
+
//cmLines,
|
79
|
+
cmManaged
|
80
|
+
};
|
81
|
+
|
82
|
+
class Socket;
|
83
|
+
|
84
|
+
//! Wraps a TCP socket that is used for one part of bi-directional
|
85
|
+
//! communication.
|
86
|
+
class CommSocket
|
87
|
+
{
|
88
|
+
struct Impl;
|
89
|
+
boost::scoped_ptr<Impl> pimpl;
|
90
|
+
|
91
|
+
public:
|
92
|
+
CommSocket(CommMode mode, SocketAddress targetAddress,
|
93
|
+
SocketPort targetPort);
|
94
|
+
CommSocket(CommMode mode, Socket& socket);
|
95
|
+
~CommSocket();
|
96
|
+
|
97
|
+
SocketAddress address() const;
|
98
|
+
SocketPort port() const;
|
99
|
+
SocketAddress remoteAddress() const;
|
100
|
+
SocketPort remotePort() const;
|
101
|
+
CommMode mode() const;
|
102
|
+
|
103
|
+
bool connected() const;
|
104
|
+
void disconnect();
|
105
|
+
bool keepAlive() const;
|
106
|
+
void setKeepAlive(bool value);
|
107
|
+
|
108
|
+
void update();
|
109
|
+
void send(const void* buffer, std::size_t size);
|
110
|
+
void sendPendingData();
|
111
|
+
std::size_t pendingBytes() const;
|
112
|
+
|
113
|
+
boost::function<void (const void*, std::size_t)> onReceive;
|
114
|
+
boost::function<void ()> onDisconnection;
|
115
|
+
};
|
116
|
+
|
117
|
+
//! Wraps a TCP socket that waits on a specific port and can create
|
118
|
+
//! CommSocket instances via its onConnection event.
|
119
|
+
class ListenerSocket
|
120
|
+
{
|
121
|
+
struct Impl;
|
122
|
+
boost::scoped_ptr<Impl> pimpl;
|
123
|
+
|
124
|
+
public:
|
125
|
+
ListenerSocket(SocketPort port);
|
126
|
+
~ListenerSocket();
|
127
|
+
|
128
|
+
SocketAddress address() const;
|
129
|
+
SocketPort port() const;
|
130
|
+
|
131
|
+
void update();
|
132
|
+
|
133
|
+
//! This signal is fired by update() whenever someone connects
|
134
|
+
//! to the port which is currently listened on.
|
135
|
+
boost::function<void (Socket&)> onConnection;
|
136
|
+
};
|
137
|
+
}
|
138
|
+
|
139
|
+
#endif
|
data/Gosu/Text.hpp
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
//! \file Text.hpp
|
2
|
+
//! Functions to output text on bitmaps.
|
3
|
+
|
4
|
+
#ifndef GOSU_TEXT_HPP
|
5
|
+
#define GOSU_TEXT_HPP
|
6
|
+
|
7
|
+
#include <Gosu/Fwd.hpp>
|
8
|
+
#include <Gosu/Color.hpp>
|
9
|
+
#include <Gosu/GraphicsBase.hpp>
|
10
|
+
#include <string>
|
11
|
+
|
12
|
+
namespace Gosu
|
13
|
+
{
|
14
|
+
//! Returns the name of a neutral font that is available on the current
|
15
|
+
//! platform.
|
16
|
+
std::wstring defaultFontName();
|
17
|
+
|
18
|
+
//! Returns the width an unformatted line of text would span on a bitmap if it were drawn using
|
19
|
+
//! drawText with the same arguments. This is a very low-level function that does not understand
|
20
|
+
//! any of Gosu's HTML-like markup.
|
21
|
+
//! \param text Unformatted text.
|
22
|
+
//! \param fontName Name of a system font, or a filename to a TTF file (must contain '/').
|
23
|
+
unsigned textWidth(const std::wstring& text,
|
24
|
+
const std::wstring& fontName, unsigned fontHeight,
|
25
|
+
unsigned fontFlags = 0);
|
26
|
+
|
27
|
+
//! Draws a line of unformatted text on a bitmap. This is a very low-level function that does not understand
|
28
|
+
//! any of Gosu's HTML-like markup.
|
29
|
+
//! \param text Unformatted text.
|
30
|
+
//! \param fontName Name of a system font, or a filename to a TTF file (must contain '/').
|
31
|
+
//! \param fontHeight Height, in pixels, of the text.
|
32
|
+
//! \param fontFlags Binary combination of members of the FontFlags
|
33
|
+
//! enum.
|
34
|
+
void drawText(Bitmap& bitmap, const std::wstring& text, int x, int y,
|
35
|
+
Color c, const std::wstring& fontName, unsigned fontHeight,
|
36
|
+
unsigned fontFlags = 0);
|
37
|
+
|
38
|
+
//! Creates a bitmap that is filled with a line of formatted text given to the function.
|
39
|
+
//! The line can contain line breaks and HTML-like markup.
|
40
|
+
//! \param text Formatted text.
|
41
|
+
//! \param fontName Name of a system font, or a filename to a TTF file (must contain '/').
|
42
|
+
//! \param fontHeight Height of the font in pixels.
|
43
|
+
//! \param fontFlags Binary combination of members of the FontFlags
|
44
|
+
//! enum.
|
45
|
+
Bitmap createText(const std::wstring& text,
|
46
|
+
const std::wstring& fontName, unsigned fontHeight,
|
47
|
+
unsigned fontFlags = 0);
|
48
|
+
|
49
|
+
//! Creates a bitmap that is filled with the formatted text given to the function.
|
50
|
+
//! The line can contain line breaks and HTML-like markup.
|
51
|
+
//! \param text Formatted text.
|
52
|
+
//! \param fontName Name of a system font, or a filename to a TTF file (must contain '/').
|
53
|
+
//! \param fontHeight Height of the font in pixels.
|
54
|
+
//! \param lineSpacing Spacing between two lines of text in pixels. Can be negative to make
|
55
|
+
//! text stick together more closely.
|
56
|
+
//! \param maxWidth Width of the bitmap that will be returned. Text
|
57
|
+
//! will be split into multiple lines to avoid drawing over the right
|
58
|
+
//! border. When a single word is too long, it will be truncated.
|
59
|
+
//! \param fontFlags Binary combination of members of the FontFlags
|
60
|
+
//! enum.
|
61
|
+
Bitmap createText(const std::wstring& text,
|
62
|
+
const std::wstring& fontName, unsigned fontHeight,
|
63
|
+
int lineSpacing, unsigned maxWidth, TextAlign align,
|
64
|
+
unsigned fontFlags = 0);
|
65
|
+
|
66
|
+
//! Registers a new HTML-style entity that can subsequently be used
|
67
|
+
//! with Gosu::Font and Gosu::createText. The name is given without & and ;.
|
68
|
+
void registerEntity(const std::wstring& name, const Bitmap& replacement);
|
69
|
+
}
|
70
|
+
|
71
|
+
#endif
|
data/Gosu/TextInput.hpp
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
//! \file TextInput.hpp
|
2
|
+
//! Interface of the TextInput class.
|
3
|
+
|
4
|
+
#ifndef GOSU_TEXTINPUT_HPP
|
5
|
+
#define GOSU_TEXTINPUT_HPP
|
6
|
+
|
7
|
+
#include <Gosu/Fwd.hpp>
|
8
|
+
#include <Gosu/Platform.hpp>
|
9
|
+
#include <boost/scoped_ptr.hpp>
|
10
|
+
#include <string>
|
11
|
+
|
12
|
+
namespace Gosu
|
13
|
+
{
|
14
|
+
//! TextInput instances are invisible objects that build a text string from input,
|
15
|
+
//! using the current operating system's keyboard layout.
|
16
|
+
//! At its most basic form, you only need to create a new TextInput instance and
|
17
|
+
//! pass it to your window via setTextInput. Until you call this function again,
|
18
|
+
//! passing 0, the TextInput object will build a text that can be accessed via
|
19
|
+
//! TextInput::text().
|
20
|
+
//! A TextInput object is purely abstract, though; drawing the input field is left
|
21
|
+
//! to the user. As with most of Gosu, how this is handled is completely left open.
|
22
|
+
//! TextInput only aims to provide enough code for your own GUIs to build upon.
|
23
|
+
class TextInput
|
24
|
+
{
|
25
|
+
struct Impl;
|
26
|
+
boost::scoped_ptr<Impl> pimpl;
|
27
|
+
|
28
|
+
public:
|
29
|
+
TextInput();
|
30
|
+
virtual ~TextInput();
|
31
|
+
|
32
|
+
std::wstring text() const;
|
33
|
+
|
34
|
+
//! Replaces the current text by the given string and positions the cursor
|
35
|
+
//! at the end of the text, with an empty selection.
|
36
|
+
void setText(const std::wstring& text);
|
37
|
+
|
38
|
+
//! Position of the caret as the index of the character that it's left to.
|
39
|
+
unsigned caretPos() const;
|
40
|
+
//! Sets the caret position as returned by caretPos.
|
41
|
+
//! You usually also want to use setSelectionStart.
|
42
|
+
void setCaretPos(unsigned pos);
|
43
|
+
|
44
|
+
//! If there is a selection, the selectionStart() member yields its beginning,
|
45
|
+
//! using the same indexing scheme as caretPos. If there is no selection,
|
46
|
+
//! selectionStart() is equal to caretPos().
|
47
|
+
unsigned selectionStart() const;
|
48
|
+
//! Sets the start of the selection as returned by selectionStart.
|
49
|
+
void setSelectionStart(unsigned pos);
|
50
|
+
|
51
|
+
// Platform-specific communication with Gosu::Input.
|
52
|
+
#if defined(GOSU_IS_MAC)
|
53
|
+
bool feedNSEvent(void* event);
|
54
|
+
#elif defined(GOSU_IS_WIN)
|
55
|
+
bool feedMessage(unsigned long message, unsigned long wparam, unsigned long lparam);
|
56
|
+
#elif defined(GOSU_IS_X)
|
57
|
+
bool feedXEvent(void* display, void* event);
|
58
|
+
#endif
|
59
|
+
|
60
|
+
//! Overridable filter that is applied to all new text that is entered.
|
61
|
+
//! Allows for context-sensitive filtering/extending/... of the text.
|
62
|
+
//! The text will be inserted at caretPos afterwards.
|
63
|
+
virtual std::wstring filter(const std::wstring& textIn) const
|
64
|
+
{
|
65
|
+
return textIn;
|
66
|
+
}
|
67
|
+
};
|
68
|
+
}
|
69
|
+
|
70
|
+
#endif
|
data/Gosu/Timing.hpp
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
//! \file Timing.hpp
|
2
|
+
//! Functions for timing.
|
3
|
+
|
4
|
+
#ifndef GOSU_TIMING_HPP
|
5
|
+
#define GOSU_TIMING_HPP
|
6
|
+
|
7
|
+
namespace Gosu
|
8
|
+
{
|
9
|
+
//! Freezes the current thread for at least the specified time.
|
10
|
+
void sleep(unsigned milliseconds);
|
11
|
+
|
12
|
+
//! Incrementing, possibly wrapping millisecond timer.
|
13
|
+
unsigned long milliseconds();
|
14
|
+
}
|
15
|
+
|
16
|
+
#endif
|
data/Gosu/Utility.hpp
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
//! \file Utility.hpp
|
2
|
+
//! General purpose utility functions.
|
3
|
+
|
4
|
+
// REDESIGN: Rename to StringConversion.hpp?
|
5
|
+
|
6
|
+
#ifndef GOSU_UTILITY_HPP
|
7
|
+
#define GOSU_UTILITY_HPP
|
8
|
+
|
9
|
+
#include <string>
|
10
|
+
#include <vector>
|
11
|
+
|
12
|
+
namespace Gosu
|
13
|
+
{
|
14
|
+
//! Converts an std::string into an std::wstring.
|
15
|
+
std::wstring utf8ToWstring(const std::string& utf8);
|
16
|
+
//! Converts an std::wstring into an std::string.
|
17
|
+
std::string wstringToUTF8(const std::wstring& ws);
|
18
|
+
|
19
|
+
//! Converts an std::string into an std::wstring using local encoding.
|
20
|
+
std::wstring widen(const std::string& s);
|
21
|
+
//! Converts an std::wstring into an std::string using local encoding.
|
22
|
+
std::string narrow(const std::wstring& ws);
|
23
|
+
}
|
24
|
+
|
25
|
+
#endif
|
data/Gosu/Version.hpp
ADDED
data/Gosu/WinUtility.hpp
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
//! \file WinUtility.hpp
|
2
|
+
//! Contains some functions which are used to implement Gosu on Windows and
|
3
|
+
//! might be useful for advanced users who try to integrate Gosu in a Win32
|
4
|
+
//! application.
|
5
|
+
|
6
|
+
#ifndef GOSU_WINUTILITY_HPP
|
7
|
+
#define GOSU_WINUTILITY_HPP
|
8
|
+
|
9
|
+
#include <windows.h>
|
10
|
+
#include <Gosu/Platform.hpp>
|
11
|
+
#include <boost/function.hpp>
|
12
|
+
#include <boost/shared_ptr.hpp>
|
13
|
+
#include <string>
|
14
|
+
|
15
|
+
namespace Gosu
|
16
|
+
{
|
17
|
+
//! Implementation helpers for the Windows platform.
|
18
|
+
namespace Win
|
19
|
+
{
|
20
|
+
//! Returns the instance handle of the application.
|
21
|
+
HINSTANCE instance();
|
22
|
+
|
23
|
+
//! Blocking function which waits for the next message, processes it,
|
24
|
+
//! then returns.
|
25
|
+
void handleMessage();
|
26
|
+
|
27
|
+
//! Non-blocking function which processes all waiting messages but does
|
28
|
+
//! not wait for further incoming messages.
|
29
|
+
void processMessages();
|
30
|
+
|
31
|
+
//! Registers a function to be called by handleMessage and
|
32
|
+
//! processMessages. Every message is passed to the hooks and not
|
33
|
+
//! processed further if any hook function returns true.
|
34
|
+
void registerMessageHook(const boost::function<bool (MSG&)>& hook);
|
35
|
+
|
36
|
+
//! Throws an exception according to the error which GetLastError()
|
37
|
+
//! returns, optionally prefixed with "While (action), the following
|
38
|
+
//! error occured: ".
|
39
|
+
GOSU_NORETURN void throwLastError(const std::string& action = "");
|
40
|
+
|
41
|
+
//! Small helper function that throws an exception whenever the value
|
42
|
+
//! passed through is false. Note that this doesn't make sense for all
|
43
|
+
//! Windows API functions, but for most of them.
|
44
|
+
template<typename T>
|
45
|
+
inline T check(T valToCheck, const std::string& action = "")
|
46
|
+
{
|
47
|
+
if (!valToCheck)
|
48
|
+
throwLastError(action);
|
49
|
+
return valToCheck;
|
50
|
+
}
|
51
|
+
|
52
|
+
// IMPR: Why can't I use mem_fn for releasing objects even though it is
|
53
|
+
// shown like that in the shared_ptr documentation?
|
54
|
+
template<typename T>
|
55
|
+
void releaseComPtr(T* ptr)
|
56
|
+
{
|
57
|
+
ptr->Release();
|
58
|
+
}
|
59
|
+
|
60
|
+
//! Small helper function that transfers ownership of a COM interface
|
61
|
+
//! to a boost::shared_ptr.
|
62
|
+
template<typename T>
|
63
|
+
inline boost::shared_ptr<T> shareComPtr(T* ptr)
|
64
|
+
{
|
65
|
+
return boost::shared_ptr<T>(ptr, releaseComPtr<T>);
|
66
|
+
}
|
67
|
+
|
68
|
+
//! Returns the executable's filename.
|
69
|
+
std::wstring appFilename();
|
70
|
+
|
71
|
+
//! Returns the executable's containing directory.
|
72
|
+
std::wstring appDirectory();
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
#endif
|