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