Version
menu_open
link
Wwise SDK 2022.1.11
AkXMLErrorMessageTranslator.h
Go to the documentation of this file.
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 
29 {
30 public:
31  /// MessageTranslator class constructor.
33 
34  AkXMLErrorMessageTranslator(const AkOSChar* in_filePath, AkUInt32 in_msTimeout = 10 /*Default timeout, 10ms*/);
35 
37 
38  void Init();
39 
40  virtual void Term() override;
41 
42  /**
43  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()
44  @param[in] in_filePath The file path to SoundBanksInfo.xml, relative to the Base Path, must include the filename and the extension.
45  @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.
46  @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.
47  */
48  AKRESULT SetFileName(const AkOSChar* in_filePath, AkUInt32 in_msTimeout = 10 /*Default timeout, 10ms*/);
49 
50 protected:
51  /**
52  Call the external source and parse the tag if possible
53  @param[in] in_pTagList The list of tag to parse
54  @param[in] in_uCount The number of tag to parse
55  @param[in,out] io_uTranslated The list of information gathered by the parsing
56  @return bool Whether or not all the tag were parsed
57  */
58  virtual bool GetInfo(TagInformation* in_pTagList, AkUInt32 in_uCount, AkUInt32& io_uTranslated) override;
59 private:
60 
61  AKRESULT Setup();
62 
63  /**
64  Read the xml file and try to search for all the pattern stored inside the SearchInfo
65  When a pattern is found, the index where it was found is stored inside the SearchInfo
66  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
67  @param[in,out] io_searchInfo List of all the pattern to find
68  @param[in] in_patternCount The amount of pattern to find
69  @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
70  @param[in] in_uPos The index where the search should begin. By default start at 0 (the begining)
71  @return AkInt32 The amount of pattern that were successfully found
72  */
73  AkInt32 ReadXmlFile(SearchInfo* io_searchInfo, const AkInt32& in_patternCount, AkInt32 in_longestDefaultTag, AkUInt32 in_uPos = 0);
74 
75  /**
76  A sligthly edited BooyerMoore search algorithm that allows to search for multiple pattern at the same time
77  If the parsedInformation isn't a null pointer, then an ID search is carried out
78  The search stretch a bit further to find the string matching the id stored inside the searchInfo and print it inside the parsedInformation
79  @param[in] in_data The buffer in which we're searching the pattern.
80  @param[in] in_dataSize The length of the buffer in which we're making the search.
81  @param[in,out] io_searchInfo The information about the pattern to find.
82  @param[in] in_patternCount The amount of pattern to find.
83  @return int The amount of pattern found.
84  */
85  AkInt32 BoyerMooreSearch(char* in_data, AkUInt32 in_dataSize, SearchInfo* io_searchInfo, AkUInt32 in_patternCount);
86 
87  /**
88  A continuation of the BooyerMoore search algorithm that happens during an ID search
89  It searches for the starting point of the ID based on SearchInfo.idStartingPoint
90  @param[in] in_data The buffer in which we're searching the pattern.
91  @param[in] in_dataSize The length of the buffer in which we're making the search.
92  @param[in,out] io_searchInfo The information about the pattern to find.
93  */
94  void BooyerMooreSearchIdStartingPoint(char* in_data, AkInt32 in_dataSize, SearchInfo& io_searchInfo);
95 
96  /**
97  Extract the ID from the xml file and store it inside the parsedInformation
98  @param[in] in_data The buffer in which we're searching the pattern.
99  @param[in] in_dataSize The length of the buffer in which we are making the search.
100  @param[in,out] io_searchInfo The information about the pattern to find.
101  */
102  void ExtractId(char* in_data, AkInt32 in_dataSize, SearchInfo& io_searchInfo);
103 
104  /**
105  Creates the bad heuristic array used in the BoyerMoore string search algorithm
106  @param[in] in_pattern The pattern we're looking for
107  @param[in] in_size The size of the pattern string
108  @param[out] out_badChar The bad char array that will be used later on in the algorithm
109  */
110  void BoyerMooreBadHeuristic(const char* in_pattern, AkInt32 in_size, AkInt8 out_badChar[]);
111 
112  AkOSChar m_fileName[AK_MAX_PATH];
113 
114  bool m_bFileOpeningFailed;
115  AkUInt32 m_msTimeout;
116 
117  enum class xmlTag
118  {
119  StreamedFiles = 0,
120  SoundBanks,
121 
122  // ALWAYS ADD NEW TAGS AT THE END !!!!!!!
123  // Otherwise it may break comm compatibility in a patch
124 
125  NUM_XML_TAG // THIS STAYS AT END OF ENUM
126  };
127 
128  AkUInt32 m_tagIndex[(AkInt32) AkXMLErrorMessageTranslator::xmlTag::NUM_XML_TAG];
129 
130  const char* s_xmlTag[(AkInt32)AkXMLErrorMessageTranslator::xmlTag::NUM_XML_TAG] =
131  {
132  "<StreamedFiles>",
133  "<SoundBanks>"
134  // When adding tags, make sure they are all shorter than MAX_XML_SEARCH_LEN.
135  };
136 };
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:199
char AkOSChar
Generic character string.
Definition: AkTypes.h:60
int32_t AkInt32
Signed 32-bit integer.
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

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell us about your project. We're here to help.

Register your project and we'll help you get started with no strings attached!

Get started with Wwise