fbxrenamingstrategyutilities.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /****************************************************************************************
  2. Copyright (C) 2015 Autodesk, Inc.
  3. All rights reserved.
  4. Use of this software is subject to the terms of the Autodesk license agreement
  5. provided at the time of installation or download, or which otherwise accompanies
  6. this software in either electronic or hard copy form.
  7. ****************************************************************************************/
  8. //! \file fbxrenamingstrategyutilities.h
  9. #ifndef _FBXSDK_UTILS_RENAMINGSTRATEGY_UTILITIES_H_
  10. #define _FBXSDK_UTILS_RENAMINGSTRATEGY_UTILITIES_H_
  11. #include <fbxsdk/fbxsdk_def.h>
  12. #include <fbxsdk/core/base/fbxstring.h>
  13. #include <fbxsdk/fbxsdk_nsbegin.h>
  14. #define NAMECLASH1_KEY "_ncl1_" // name (x)
  15. #define NAMECLASH2_KEY "_ncl2_" // Upper/lower cases clash
  16. #define UPPERTOLOWER_KEY "ul"
  17. #define LOWERTOUPPER_KEY "lu"
  18. /** \brief This class contains a set of utilities, which are used by the FBX renaming strategy.
  19. * \nosubgrouping
  20. */
  21. class FBXSDK_DLL FbxRenamingStrategyUtils
  22. {
  23. public:
  24. /** Check if the string has non alphanumeric characters and replace them with a special string containing a prefix and
  25. * the character code.
  26. * \param pString String to be processed. The result of the conversion is also returned in this string.
  27. * \param pFirstCharMustBeAlphaOnly This flag tells whether the first char of the string must be alpha only. Its default
  28. * value is \c false.
  29. * \param pPermittedChars List of non alphanumeric characters that do not require to be converted because already
  30. * supported by the destination application. When encountered, these characters are simply
  31. * skipped and left as is.
  32. * \param p8bitCharsOnly When \c true, this flag tells the routine that only 8 bit coded characters can be
  33. * represented by the encoding format (see note below). If set to \c false, the range of supported
  34. * character is increased and the memory usage may be less. But the routine will perform slower
  35. * because of the internal conversions required.
  36. * \return Returns \c true if at least one character in \c pString has been encoded.
  37. * \note The encoding string depends on the value of \c p8bitCharsOnly argument. When this parameter value is \c true,
  38. * each non-alphanumeric character is replaced with FBXASC### (where ### is the decimal code of the character).
  39. * Inversely, when the value is \c false, each non-alphanumeric characters is replaced with FBXCHR##### (where
  40. * ##### is the hexadecimal representation of the character code).
  41. */
  42. static bool EncodeNonAlpha(FbxString &pString, bool pFirstCharMustBeAlphaOnly=false, FbxString pPermittedChars="", bool p8bitCharsOnly = true);
  43. /** Take a string that has been encoded by EncodeNonAlpha and re-extract the non-alphanumeric values.
  44. * \param pString String to be processed. The result of the conversion is also returned in this string.
  45. * \return Returns \c true if the \c pString argument has been decoded.
  46. */
  47. static bool DecodeNonAlpha(FbxString &pString);
  48. /** This method will add the _ncl1_ with the provided pInstanceNumber to the string
  49. * \param pString
  50. * \param pInstanceNumber Its default value is 0.
  51. * \return Always returns true.
  52. * \remarks please ALWAYS call Encode Duplicate BEFORE Encode Case Insensitive.
  53. */
  54. static bool EncodeDuplicate(FbxString &pString, int pInstanceNumber=0);
  55. /** This method will remove the _ncl1_xxx from the given string
  56. * \param pString
  57. * \return Returns true if the pString has been modified
  58. */
  59. static bool DecodeDuplicate(FbxString &pString);
  60. /** This method will compare pString and pString2, set pString to pString2 and append the ncl2 suffix to it
  61. * \param pString
  62. * \param pString2
  63. * \return Returns true if the pString has been modified
  64. * \remarks pString and pString2 must be identical except for casing.
  65. */
  66. static bool EncodeCaseInsensitive(FbxString &pString, const FbxString pString2);
  67. /** This method will decode a string that has a ncl2 to it
  68. * \param pString
  69. * \return Returns true if the pString has been modified
  70. */
  71. static bool DecodeCaseInsensitive(FbxString &pString);
  72. };
  73. #include <fbxsdk/fbxsdk_nsend.h>
  74. #endif /* _FBXSDK_UTILS_RENAMINGSTRATEGY_UTILITIES_H_ */