版本
menu_open
link
Wwise SDK 2023.1.3
AkXMLErrorMessageTranslator.h
浏览该文件的文档.
1 /*******************************************************************************
2 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
3 released in source code form as part of the SDK installer package.
4 
5 Commercial License Usage
6 
7 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
8 may use this file in accordance with the end user license agreement provided
9 with the software or, alternatively, in accordance with the terms contained in a
10 written agreement between you and Audiokinetic Inc.
11 
12  Copyright (c) 2024 Audiokinetic Inc.
13 *******************************************************************************/
14 
15 // AkErrorMessageTranslator.h
16 /// \file
17 /// Contains the error message translator that use an xml file
18 /// This translator use the AkFileHelper
19 
20 #pragma once
21 #include <AK/SoundEngine/Common/AkSoundEngine.h> // Sound engine
25 
26 struct SearchInfo;
27 class CAkBankReader;
28 
30 {
31 public:
32  /// MessageTranslator class constructor.
34 
35  AkXMLErrorMessageTranslator(const AkOSChar* in_filePath, AkUInt32 in_msTimeout = 10 /*Default timeout, 10ms*/);
36 
38 
39  void Init();
40 
41  virtual void Term() override;
42 
43  /**
44  Sets the file path to SoundBanksInfo.xml (or its equivalent). Note that the path is always with respect to the Base Path, as set with AK::SoundEngine::SetBasePath()
45  @param[in] in_filePath The file path to SoundBanksInfo.xml, relative to the Base Path, must include the filename and the extension.
46  @param[out] in_msTimeout Maximum time that can be spent resolving the error parameters. Set to INT_MAX to wait infinitely or 0 to disable XML translation entirely.
47  @return AKRESULT Ak_Success if the parameters are ok. AK_InvalidParameter if in_filePath is null. AK_InsufficientMemory if there was a memory allocaiton issue.
48  */
49  AKRESULT SetFileName(const AkOSChar* in_filePath, AkUInt32 in_msTimeout = 10 /*Default timeout, 10ms*/);
50 
51 protected:
52  /**
53  Call the external source and parse the tag if possible
54  @param[in] in_pTagList The list of tag to parse
55  @param[in] in_uCount The number of tag to parse
56  @param[in,out] io_uTranslated The list of information gathered by the parsing
57  @return bool Whether or not all the tag were parsed
58  */
59  virtual bool GetInfo(TagInformation* in_pTagList, AkUInt32 in_uCount, AkUInt32& io_uTranslated) override;
60 private:
61 
62  AKRESULT Setup();
63 
64  /**
65  Read the xml file and try to search for all the pattern stored inside the SearchInfo
66  When a pattern is found, the index where it was found is stored inside the SearchInfo
67  If the parsedInformation isn't a null pointer, search a bit further to find the string matching the id and print it inside the parsedInformation
68  @param[in,out] io_searchInfo List of all the pattern to find
69  @param[in] in_patternCount The amount of pattern to find
70  @param[in] in_longestDefaultTag Refers to the longest startTag / endTag stored in the in_SearchInfo. Since multiple search info can have the same startTag / endTag the longest one is sent instead of checking all the searchInfo one by one to find the longest one
71  @param[in] in_uPos The index where the search should begin. By default start at 0 (the begining)
72  @return AkInt32 The amount of pattern that were successfully found
73  */
74  AkInt32 ReadXmlFile(SearchInfo* io_searchInfo, const AkInt32& in_patternCount, AkInt32 in_longestDefaultTag, AkUInt32 in_uPos = 0);
75 
76  /**
77  A sligthly edited BooyerMoore search algorithm that allows to search for multiple pattern at the same time
78  If the parsedInformation isn't a null pointer, then an ID search is carried out
79  The search stretch a bit further to find the string matching the id stored inside the searchInfo and print it inside the parsedInformation
80  @param[in] in_data The buffer in which we're searching the pattern.
81  @param[in] in_dataSize The length of the buffer in which we're making the search.
82  @param[in,out] io_searchInfo The information about the pattern to find.
83  @param[in] in_patternCount The amount of pattern to find.
84  @return int The amount of pattern found.
85  */
86  AkInt32 BoyerMooreSearch(char* in_data, AkUInt32 in_dataSize, SearchInfo* io_searchInfo, AkUInt32 in_patternCount);
87 
88  /**
89  A continuation of the BooyerMoore search algorithm that happens during an ID search
90  It searches for the starting point of the ID based on SearchInfo.idStartingPoint
91  @param[in] in_data The buffer in which we're searching the pattern.
92  @param[in] in_dataSize The length of the buffer in which we're making the search.
93  @param[in,out] io_searchInfo The information about the pattern to find.
94  */
95  void BooyerMooreSearchIdStartingPoint(char* in_data, AkInt32 in_dataSize, SearchInfo& io_searchInfo);
96 
97  /**
98  Extract the ID from the xml file and store it inside the parsedInformation
99  @param[in] in_data The buffer in which we're searching the pattern.
100  @param[in] in_dataSize The length of the buffer in which we are making the search.
101  @param[in,out] io_searchInfo The information about the pattern to find.
102  */
103  void ExtractId(char* in_data, AkInt32 in_dataSize, SearchInfo& io_searchInfo);
104 
105  /**
106  Creates the bad heuristic array used in the BoyerMoore string search algorithm
107  @param[in] in_pattern The pattern we're looking for
108  @param[in] in_size The size of the pattern string
109  @param[out] out_badChar The bad char array that will be used later on in the algorithm
110  */
111  void BoyerMooreBadHeuristic(const char* in_pattern, AkInt32 in_size, AkInt8 out_badChar[]);
112 
113  AkOSChar m_fileName[AK_MAX_PATH];
114 
115  bool m_bFileOpeningFailed = false;
116  AkUInt32 m_msTimeout = 0xFFFFFFFF;
117 
118  CAkLock m_lock;
119  CAkBankReader* m_pReader = nullptr;
120 
121  enum class xmlTag
122  {
123  StreamedFiles = 0,
124  SoundBanks,
125 
126  // ALWAYS ADD NEW TAGS AT THE END !!!!!!!
127  // Otherwise it may break comm compatibility in a patch
128 
129  NUM_XML_TAG // THIS STAYS AT END OF ENUM
130  };
131 
132  AkUInt32 m_tagIndex[(AkInt32) AkXMLErrorMessageTranslator::xmlTag::NUM_XML_TAG];
133 
134  const char* s_xmlTag[(AkInt32)AkXMLErrorMessageTranslator::xmlTag::NUM_XML_TAG] =
135  {
136  "<StreamedFiles>",
137  "<SoundBanks>"
138  };
139 };
virtual bool GetInfo(TagInformation *in_pTagList, AkUInt32 in_uCount, AkUInt32 &io_uTranslated) override
#define AK_MAX_PATH
Maximum path length.
Definition: AkTypes.h:82
AKRESULT
Standard function call result.
Definition: AkTypes.h:213
char AkOSChar
Generic character string
Definition: AkTypes.h:60
int32_t AkInt32
Signed 32-bit integer
Definition: AkLock.h:38
AkXMLErrorMessageTranslator(const AkOSChar *in_filePath, AkUInt32 in_msTimeout=10)
AKRESULT SetFileName(const AkOSChar *in_filePath, AkUInt32 in_msTimeout=10)
uint32_t AkUInt32
Unsigned 32-bit integer
int8_t AkInt8
Signed 8-bit integer
AkXMLErrorMessageTranslator()
MessageTranslator class constructor.
virtual void Term() override

此页面对您是否有帮助?

需要技术支持?

仍有疑问?或者问题?需要更多信息?欢迎联系我们,我们可以提供帮助!

查看我们的“技术支持”页面

介绍一下自己的项目。我们会竭力为您提供帮助。

来注册自己的项目,我们帮您快速入门,不带任何附加条件!

开始 Wwise 之旅