/thirdparty/qxt/qxtweb-standalone/qxtweb/qxtglobal.cpp

http://github.com/tomahawk-player/tomahawk · C++ · 241 lines · 5 code · 15 blank · 221 comment · 0 complexity · 2255379ab5df533011b471ffe753cffa MD5 · raw file

  1. /****************************************************************************
  2. **
  3. ** Copyright (C) Qxt Foundation. Some rights reserved.
  4. **
  5. ** This file is part of the QxtCore module of the Qxt library.
  6. **
  7. ** This library is free software; you can redistribute it and/or modify it
  8. ** under the terms of the Common Public License, version 1.0, as published
  9. ** by IBM, and/or under the terms of the GNU Lesser General Public License,
  10. ** version 2.1, as published by the Free Software Foundation.
  11. **
  12. ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
  13. ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
  14. ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
  15. ** FITNESS FOR A PARTICULAR PURPOSE.
  16. **
  17. ** You should have received a copy of the CPL and the LGPL along with this
  18. ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files
  19. ** included with the source distribution for more information.
  20. ** If you did not receive a copy of the licenses, contact the Qxt Foundation.
  21. **
  22. ** <http://libqxt.org> <foundation@libqxt.org>
  23. **
  24. ****************************************************************************/
  25. #include "qxtglobal.h"
  26. /*!
  27. \headerfile <QxtGlobal>
  28. \title Global Qxt Declarations
  29. \inmodule QxtCore
  30. \brief The <QxtGlobal> header provides basic declarations and
  31. is included by all other Qxt headers.
  32. */
  33. /*!
  34. \macro QXT_VERSION
  35. \relates <QxtGlobal>
  36. This macro expands a numeric value of the form 0xMMNNPP (MM =
  37. major, NN = minor, PP = patch) that specifies Qxt's version
  38. number. For example, if you compile your application against Qxt
  39. 0.4.0, the QXT_VERSION macro will expand to 0x000400.
  40. You can use QXT_VERSION to use the latest Qt features where
  41. available. For example:
  42. \code
  43. #if QXT_VERSION >= 0x000400
  44. qxtTabWidget->setTabMovementMode(QxtTabWidget::InPlaceMovement);
  45. #endif
  46. \endcode
  47. \sa QXT_VERSION_STR, qxtVersion()
  48. */
  49. /*!
  50. \macro QXT_VERSION_STR
  51. \relates <QxtGlobal>
  52. This macro expands to a string that specifies Qxt's version number
  53. (for example, "0.4.0"). This is the version against which the
  54. application is compiled.
  55. \sa qxtVersion(), QXT_VERSION
  56. */
  57. /*!
  58. \relates <QxtGlobal>
  59. Returns the version number of Qxt at run-time as a string (for
  60. example, "0.4.0"). This may be a different version than the
  61. version the application was compiled against.
  62. \sa QXT_VERSION_STR
  63. */
  64. const char* qxtVersion()
  65. {
  66. return QXT_VERSION_STR;
  67. }
  68. /*!
  69. \headerfile <QxtPimpl>
  70. \title The Qxt private implementation
  71. \inmodule QxtCore
  72. \brief The <QxtPimpl> header provides tools for hiding
  73. details of a class.
  74. Application code generally doesn't have to be concerned about hiding its
  75. implementation details, but when writing library code it is important to
  76. maintain a constant interface, both source and binary. Maintaining a constant
  77. source interface is easy enough, but keeping the binary interface constant
  78. means moving implementation details into a private class. The PIMPL, or
  79. d-pointer, idiom is a common method of implementing this separation. QxtPimpl
  80. offers a convenient way to connect the public and private sides of your class.
  81. \section1 Getting Started
  82. Before you declare the public class, you need to make a forward declaration
  83. of the private class. The private class must have the same name as the public
  84. class, followed by the word Private. For example, a class named MyTest would
  85. declare the private class with:
  86. \code
  87. class MyTestPrivate;
  88. \endcode
  89. \section1 The Public Class
  90. Generally, you shouldn't keep any data members in the public class without a
  91. good reason. Functions that are part of the public interface should be declared
  92. in the public class, and functions that need to be available to subclasses (for
  93. calling or overriding) should be in the protected section of the public class.
  94. To connect the private class to the public class, include the
  95. QXT_DECLARE_PRIVATE macro in the private section of the public class. In the
  96. example above, the private class is connected as follows:
  97. \code
  98. private:
  99. QXT_DECLARE_PRIVATE(MyTest)
  100. \endcode
  101. Additionally, you must include the QXT_INIT_PRIVATE macro in the public class's
  102. constructor. Continuing with the MyTest example, your constructor might look
  103. like this:
  104. \code
  105. MyTest::MyTest() {
  106. // initialization
  107. QXT_INIT_PRIVATE(MyTest);
  108. }
  109. \endcode
  110. \section1 The Private Class
  111. As mentioned above, data members should usually be kept in the private class.
  112. This allows the memory layout of the private class to change without breaking
  113. binary compatibility for the public class. Functions that exist only as
  114. implementation details, or functions that need access to private data members,
  115. should be implemented here.
  116. To define the private class, inherit from the template QxtPrivate class, and
  117. include the QXT_DECLARE_PUBLIC macro in its public section. The template
  118. parameter should be the name of the public class. For example:
  119. \code
  120. class MyTestPrivate : public QxtPrivate<MyTest> {
  121. public:
  122. MyTestPrivate();
  123. QXT_DECLARE_PUBLIC(MyTest)
  124. };
  125. \endcode
  126. \section1 Accessing Private Members
  127. Use the qxt_d() function (actually a function-like object) from functions in
  128. the public class to access the private class. Similarly, functions in the
  129. private class can invoke functions in the public class by using the qxt_p()
  130. function (this one's actually a function).
  131. For example, assume that MyTest has methods named getFoobar and doBaz(),
  132. and MyTestPrivate has a member named foobar and a method named doQuux().
  133. The code might resemble this example:
  134. \code
  135. int MyTest::getFoobar() {
  136. return qxt_d().foobar;
  137. }
  138. void MyTestPrivate::doQuux() {
  139. qxt_p().doBaz(foobar);
  140. }
  141. \endcode
  142. */
  143. /*!
  144. * \macro QXT_DECLARE_PRIVATE(PUB)
  145. * \relates <QxtPimpl>
  146. * Declares that a public class has a related private class.
  147. *
  148. * This shuold be put in the private section of the public class. The parameter is the name of the public class.
  149. */
  150. /*!
  151. * \macro QXT_DECLARE_PUBLIC(PUB)
  152. * \relates <QxtPimpl>
  153. * Declares that a private class has a related public class.
  154. *
  155. * This may be put anywhere in the declaration of the private class. The parameter is the name of the public class.
  156. */
  157. /*!
  158. * \macro QXT_INIT_PRIVATE(PUB)
  159. * \relates <QxtPimpl>
  160. * Initializes resources owned by the private class.
  161. *
  162. * This should be called from the public class's constructor,
  163. * before qxt_d() is used for the first time. The parameter is the name of the public class.
  164. */
  165. /*!
  166. * \macro QXT_D(PUB)
  167. * \relates <QxtPimpl>
  168. * Returns a reference in the current scope named "d" to the private class.
  169. *
  170. * This function is only available in a class using \a QXT_DECLARE_PRIVATE.
  171. */
  172. /*!
  173. * \macro QXT_P(PUB)
  174. * \relates <QxtPimpl>
  175. * Creates a reference in the current scope named "q" to the public class.
  176. *
  177. * This macro only works in a class using \a QXT_DECLARE_PUBLIC.
  178. */
  179. /*!
  180. * \fn QxtPrivate<PUB>& PUB::qxt_d()
  181. * \relates <QxtPimpl>
  182. * Returns a reference to the private class.
  183. *
  184. * This function is only available in a class using \a QXT_DECLARE_PRIVATE.
  185. */
  186. /*!
  187. * \fn const QxtPrivate<PUB>& PUB::qxt_d() const
  188. * \relates <QxtPimpl>
  189. * Returns a const reference to the private class.
  190. *
  191. * This function is only available in a class using \a QXT_DECLARE_PRIVATE.
  192. * This overload will be automatically used in const functions.
  193. */
  194. /*!
  195. * \fn PUB& QxtPrivate::qxt_p()
  196. * \relates <QxtPimpl>
  197. * Returns a reference to the public class.
  198. *
  199. * This function is only available in a class using \a QXT_DECLARE_PUBLIC.
  200. */
  201. /*!
  202. * \fn const PUB& QxtPrivate::qxt_p() const
  203. * \relates <QxtPimpl>
  204. * Returns a const reference to the public class.
  205. *
  206. * This function is only available in a class using \a QXT_DECLARE_PUBLIC.
  207. * This overload will be automatically used in const functions.
  208. */