CCNS.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2013-2017 Chukong Technologies
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __PLATFOMR_CCNS_H__
  22. #define __PLATFOMR_CCNS_H__
  23. #include "math/CCGeometry.h"
  24. NS_CC_BEGIN
  25. /**
  26. * @addtogroup base
  27. * @{
  28. */
  29. /**
  30. * @brief Returns a Core Graphics rectangle structure corresponding to the data in a given string.
  31. * @param str A string object whose contents are of the form "{{x,y},{w, h}}",
  32. * where x is the x coordinate, y is the y coordinate, w is the width, and h is the height.
  33. * These components can represent integer or float values.
  34. * An example of a valid string is "{{3,2},{4,5}}".
  35. * The string is not localized, so items are always separated with a comma.
  36. * @return A Core Graphics structure that represents a rectangle.
  37. * If the string is not well-formed, the function returns Rect::ZERO.
  38. */
  39. Rect CC_DLL RectFromString(const std::string& str);
  40. /**
  41. * @brief Returns a Core Graphics point structure corresponding to the data in a given string.
  42. * @param str A string object whose contents are of the form "{x,y}",
  43. * where x is the x coordinate and y is the y coordinate.
  44. * The x and y values can represent integer or float values.
  45. * An example of a valid string is "{3.0,2.5}".
  46. * The string is not localized, so items are always separated with a comma.
  47. * @return A Core Graphics structure that represents a point.
  48. * If the string is not well-formed, the function returns Vec2::ZERO.
  49. */
  50. Vec2 CC_DLL PointFromString(const std::string& str);
  51. /**
  52. * @brief Returns a Core Graphics size structure corresponding to the data in a given string.
  53. * @param str A string object whose contents are of the form "{w, h}",
  54. * where w is the width and h is the height.
  55. * The w and h values can be integer or float values.
  56. * An example of a valid string is "{3.0,2.5}".
  57. * The string is not localized, so items are always separated with a comma.
  58. * @return A Core Graphics structure that represents a size.
  59. * If the string is not well-formed, the function returns Size::ZERO.
  60. */
  61. Size CC_DLL SizeFromString(const std::string& str);
  62. // end of data_structure group
  63. /** @} */
  64. NS_CC_END
  65. #endif // __PLATFOMR_CCNS_H__