WSF
WsfParseIndex.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11// ****************************************************************************
12// Updated by Infoscitex, a DCS Company.
13// ****************************************************************************
14
15#ifndef WSFPARSEINDEX_HPP
16#define WSFPARSEINDEX_HPP
17
18#include <map>
19#include <set>
20#include <string>
21#include <vector>
22
23#include "UtHistoryMap.hpp"
24#include "UtMemoryDebug.hpp"
25#include "UtReferenceCount.hpp"
26#include "UtStringRef.hpp"
27#include "UtTextDocument.hpp"
28#include "WsfParseType.hpp"
29class WsfParser;
30class WsfParseRule;
31class WsfParseNode;
33
39class WSF_PARSER_EXPORT WsfParseIndex
40{
41public:
42 WsfParseIndex(WsfParseDefinitions* aDefinitionsPtr);
43
45
46 void AddFilePath(const std::string& aPath);
47 void DefinePathVariable(const std::string& aVariableName, const std::string& aValue);
48 void UndefinePathVariable(const std::string& aVariableName);
49 void ResetFilePath();
50
51 void Clear();
52
53 std::string SubstitutePathVariables(const std::string& aString) const;
54
56 bool HasInclude(const std::string& aFullPath) const
57 {
58 return (mIncludeCount.find(aFullPath) != mIncludeCount.end());
59 }
60
62 size_t AddInclude(const UtStringRef& aFullPath) { return ++mIncludeCount[aFullPath]; }
63
64 const std::vector<UtStringRef>& GetIncludePath() const { return mIncludePath; }
65 const std::map<UtStringRef, size_t>& GetIncludes() const { return mIncludeCount; }
66
67 void SetParseVariable(const std::string& aName, const UtTextDocumentRange& aValue)
68 {
69 mParseVariables[aName] = aValue;
70 }
71 const UtTextDocumentRange& GetParseVariable(const std::string& aName) { return mParseVariables[aName]; }
72 void ClearParseVariable(const std::string& aName) { mParseVariables.erase(aName); }
73
74 void LoadCurrentType(WsfParseType* aCurrentType)
75 {
76 assert(aCurrentType != nullptr);
77 mCurrentTypeStack.push_back(aCurrentType);
78 }
79 void UnloadCurrentType() { mCurrentTypeStack.pop_back(); }
81 {
82 assert(!mCurrentTypeStack.empty());
83 return mCurrentTypeStack.back();
84 }
85 // size_t GetCurrentTypeStackSize() const { return mCurrentTypeStack.size(); }
86
87 // WsfParseTypePath
88 // UtHistoryMap<WsfParseTypePath, WsfParseType> mUserTypeTable;
89
91 int GenerateName() { return mGeneratedNameCount++; }
92
93private:
94 // No implementation:
95 WsfParseIndex& operator=(const WsfParseIndex& aRhs);
96 int mGeneratedNameCount;
97 std::map<UtStringRef, UtTextDocumentRange> mParseVariables;
98
99 // For each include path, store the number of times it has been included
100 // (always 1 for include_once)
101 std::map<UtStringRef, size_t> mIncludeCount;
102 std::vector<UtStringRef> mIncludePath;
103 std::map<UtStringRef, UtStringRef> mPathVariables;
104
105 std::vector<WsfParseType*> mCurrentTypeStack;
106
107 WsfParseDefinitions* mDefinitions;
108 UT_MEMORY_DEBUG_MARKER(cMDB_PARSE_INDEX);
109};
110#endif
@ cMDB_PARSE_INDEX
Definition WsfParseDebugMarkers.hpp:27
Definition WsfParseDefinitions.hpp:39
Definition WsfParseIndex.hpp:40
const UtTextDocumentRange & GetParseVariable(const std::string &aName)
Definition WsfParseIndex.hpp:71
const std::map< UtStringRef, size_t > & GetIncludes() const
Definition WsfParseIndex.hpp:65
void SetParseVariable(const std::string &aName, const UtTextDocumentRange &aValue)
Definition WsfParseIndex.hpp:67
void DefinePathVariable(const std::string &aVariableName, const std::string &aValue)
Definition WsfParseIndex.cpp:53
void UndefinePathVariable(const std::string &aVariableName)
Definition WsfParseIndex.cpp:58
void LoadCurrentType(WsfParseType *aCurrentType)
Definition WsfParseIndex.hpp:74
int GenerateName()
Definition WsfParseIndex.hpp:91
bool HasInclude(const std::string &aFullPath) const
Returns 'true' if aFullPath has already been included.
Definition WsfParseIndex.hpp:56
void Clear()
Definition WsfParseIndex.cpp:35
const std::vector< UtStringRef > & GetIncludePath() const
Definition WsfParseIndex.hpp:64
WsfParseType * GetCurrentType()
Definition WsfParseIndex.hpp:80
void ClearParseVariable(const std::string &aName)
Definition WsfParseIndex.hpp:72
size_t AddInclude(const UtStringRef &aFullPath)
Add an included file.
Definition WsfParseIndex.hpp:62
void ResetFilePath()
Definition WsfParseIndex.cpp:63
void UnloadCurrentType()
Definition WsfParseIndex.hpp:79
WsfParseType mUserTypes
Definition WsfParseIndex.hpp:90
WsfParseIndex(WsfParseDefinitions *aDefinitionsPtr)
Definition WsfParseIndex.cpp:22
std::string SubstitutePathVariables(const std::string &aString) const
Definition WsfParseIndex.cpp:68
void AddFilePath(const std::string &aPath)
Definition WsfParseIndex.cpp:44
Definition WsfParseNode.hpp:61
Definition WsfParseRule.hpp:131
Definition WsfParseType.hpp:40
Definition WsfParser.hpp:36
Copyrights Multiple, All Rights Reserved