1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4// ============================================================
5//
6// TextualIdentityParser.hpp
7//
8
9
10//
11// Defines the TextualIdentityParser class
12//
13// ============================================================
14
15#ifndef __BINDER__TEXTUAL_IDENTITY_PARSER_HPP__
16#define __BINDER__TEXTUAL_IDENTITY_PARSER_HPP__
17
18#include "bindertypes.hpp"
19#include "stringlexer.hpp"
20
21namespace BINDER_SPACE
22{
23 class AssemblyVersion;
24 class AssemblyIdentity;
25
26 class TextualIdentityParser : public StringLexer
27 {
28 public:
29 TextualIdentityParser(AssemblyIdentity *pAssemblyIdentity);
30 ~TextualIdentityParser();
31
32 virtual BOOL IsSeparatorChar(WCHAR wcChar);
33 virtual StringLexer::LEXEME_TYPE GetLexemeType(WCHAR wcChar);
34
35 static HRESULT Parse(/* in */ SString &textualIdentity,
36 /* out */ AssemblyIdentity *pAssemblyIdentity,
37 /* in */ BOOL fPermitUnescapedQuotes = FALSE);
38 static HRESULT ToString(/* in */ AssemblyIdentity *pAssemblyIdentity,
39 /* in */ DWORD dwIdentityFlags,
40 /* out */ SString &textualIdentity);
41
42 static BOOL ParseVersion(/* in */ SString &versionString,
43 /* out */ AssemblyVersion *pAssemblyVersion);
44
45 static BOOL HexToBlob(/* in */ SString &publicKeyOrToken,
46 /* in */ BOOL fValidateHex,
47 /* in */ BOOL fIsToken,
48 /* out */ SBuffer &publicKeyOrTokenBLOB);
49 static void BlobToHex(/* in */ SBuffer &publicKeyOrTokenBLOB,
50 /* out */ SString &publicKeyOrToken);
51
52 BOOL ParseString(/* in */ SString &textualString,
53 /* out */ SString &contentString);
54
55 protected:
56 BOOL Parse(/* in */ SString &textualIdentity,
57 /* in */ BOOL fPermitUnescapedQuotes = FALSE);
58
59 BOOL PopulateAssemblyIdentity(/* in */ SString &attributeString,
60 /* in */ SString &valueString);
61
62 static void EscapeString(/* in */ SString &input,
63 /* out*/ SString &result);
64
65 AssemblyIdentity *m_pAssemblyIdentity;
66 DWORD m_dwAttributesSeen;
67 };
68};
69
70#endif
71