/src/ois/includes/iphone/iPhonePrereqs.h

https://bitbucket.org/cabalistic/ogredeps/ · C Header · 56 lines · 24 code · 5 blank · 27 comment · 0 complexity · c40fea7ad57a6fd8625ad94c884c70bc MD5 · raw file

  1. /*
  2. The zlib/libpng License
  3. Copyright (c) 2006 Chris Snyder
  4. This software is provided 'as-is', without any express or implied warranty. In no event will
  5. the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose, including commercial
  7. applications, and to alter it and redistribute it freely, subject to the following
  8. restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not claim that
  10. you wrote the original software. If you use this software in a product,
  11. an acknowledgment in the product documentation would be appreciated but is
  12. not required.
  13. 2. Altered source versions must be plainly marked as such, and must not be
  14. misrepresented as being the original software.
  15. 3. This notice may not be removed or altered from any source distribution.
  16. */
  17. #ifndef OIS_iPhonePrereqs_H
  18. #define OIS_iPhonePrereqs_H
  19. #include <string>
  20. #include <list>
  21. #include <CoreFoundation/CoreFoundation.h>
  22. namespace OIS
  23. {
  24. class iPhoneInputManager;
  25. class iPhoneAccelerometer;
  26. class iPhoneMouse;
  27. /**
  28. Simple wrapper class for CFString which will create a valid CFString and retain ownership until class instance is outof scope
  29. To Access the CFStringRef instance, simply cast to void*, pass into a function expecting a void* CFStringRef object, or access via cf_str() method
  30. */
  31. class OIS_CFString
  32. {
  33. public:
  34. OIS_CFString() { m_StringRef = CFStringCreateWithCString(NULL, "", kCFStringEncodingUTF8); }
  35. OIS_CFString(const char* c_str) { m_StringRef = CFStringCreateWithCString(NULL, c_str, kCFStringEncodingUTF8); }
  36. OIS_CFString(const std::string &s_str) { m_StringRef = CFStringCreateWithCString(NULL, s_str.c_str(), kCFStringEncodingUTF8); }
  37. ~OIS_CFString() { CFRelease(m_StringRef); }
  38. //Allow this class to be autoconverted to base class of StringRef (void*)
  39. operator void*() { return (void*)m_StringRef; }
  40. CFStringRef cf_str() { return m_StringRef; }
  41. private:
  42. CFStringRef m_StringRef;
  43. };
  44. }
  45. #endif