WSF
WsfPProxyFileWriter.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 WSFPPROXYFILEWRITER_HPP
16#define WSFPPROXYFILEWRITER_HPP
17
18#include <map>
19#include <memory>
20#include <string>
21
22#include "UtTextDocument.hpp"
23#include "WsfPProxyPath.hpp"
24class WsfParseNode;
27
29{
30 UtTextDocumentRange mReplaceRange;
31 std::string mReplaceText;
32 // Update a range of text after applying this change
33 void ApplyChangeToRange(UtTextRange& aRange) const
34 {
35 if (mReplaceRange.GetBegin() > aRange.GetBegin())
36 {
37 return;
38 }
39 size_t delta = mReplaceText.size() - mReplaceRange.Length();
40 aRange.SetRange(aRange.GetBegin() + delta, aRange.GetEnd() + delta);
41 }
42};
43
45{
46public:
53
54 void SetRootFile(UtTextDocument* aFilePtr);
56
57 void ApplyChanges();
58 void MoveCursor(UtTextDocumentLocation aLocation);
59 void InsertText(const std::string& aText);
60 void SetSourceProvider(WsfParseSourceProvider* aSourceProvider);
61 void SetSaveFiles(const std::map<WsfPProxyPath, std::string>& aProxySaveLocations)
62 {
63 mProxySaveLocations = aProxySaveLocations;
64 }
65 void WriteTrace(WsfPParseRuleTrace* aTracePtr);
66 void SetIncludeDirectories(const UtPath& aWorkingDirectory, const std::vector<UtStringRef>& aIncludeDirectories);
67 const std::vector<UtTextDocumentRange>& GetNewRanges() { return mNewRanges; }
68
69 const std::map<UtTextDocument*, std::unique_ptr<UtTextDocument>>& GetDocumentCopies() const
70 {
71 return mDocumentCopies;
72 }
73 using ChangeList = std::vector<WsfPProxyFileWriterChange>;
74 using ChangeMap = std::map<UtTextDocument*, ChangeList>;
75
76private:
77 std::string BestIncludePath(const UtPath& aFilePath);
78 void UpdateSaveLocations(WsfPParseRuleTrace* aTracePtr);
79 void WriteTraceP(WsfParseNode* aNodePtr);
80 void WriteTraceP(WsfPParseRuleTrace* aTracePtr);
81 void ExpandCommandRangeForWhitespace(UtTextDocumentRange& aRange, UtTextDocument* aDocPtr);
82 UtTextDocument* GetWritableDocument(UtTextDocument* aDocument);
83 void MoveCursorToFile(const std::string& aFileName);
84
85 // Changes not associated with a file get added here
86 UtTextDocument* mRootFilePtr;
87 ChangeMap mChanges;
88 UtTextDocumentLocation mCursor;
89 std::vector<UtTextDocumentRange> mNewRanges;
90 std::map<UtTextDocument*, std::unique_ptr<UtTextDocument>> mDocumentCopies;
91 // for new constructs, the file may be selected
92 std::map<WsfPParseRuleTrace*, std::string> mSaveFiles;
93 std::map<WsfPProxyPath, std::string> mProxySaveLocations;
94 WsfParseSourceProvider* mSourceProvider;
95
96 UtPath mWorkingDirectory;
97 std::vector<std::string> mNewFileList;
98 std::vector<UtStringRef> mIncludeDirectories;
99};
100
101#endif
Definition WsfPProxyRuleTrace.hpp:73
const std::map< UtTextDocument *, std::unique_ptr< UtTextDocument > > & GetDocumentCopies() const
Definition WsfPProxyFileWriter.hpp:69
void InsertText(const std::string &aText)
Definition WsfPProxyFileWriter.cpp:133
std::vector< WsfPProxyFileWriterChange > ChangeList
Definition WsfPProxyFileWriter.hpp:73
std::map< UtTextDocument *, ChangeList > ChangeMap
Definition WsfPProxyFileWriter.hpp:74
void MoveCursor(UtTextDocumentLocation aLocation)
Definition WsfPProxyFileWriter.cpp:103
const std::vector< UtTextDocumentRange > & GetNewRanges()
Definition WsfPProxyFileWriter.hpp:67
WsfPProxyFileWriter & operator=(const WsfPProxyFileWriter &)=delete
void SetSourceProvider(WsfParseSourceProvider *aSourceProvider)
Definition WsfPProxyFileWriter.cpp:372
WsfPProxyFileWriter(const WsfPProxyFileWriter &)=delete
WsfPProxyFileWriter & operator=(WsfPProxyFileWriter &&)=default
WsfPProxyFileWriter(WsfPProxyFileWriter &&)=default
void SetRootFile(UtTextDocument *aFilePtr)
Definition WsfPProxyFileWriter.cpp:34
void SetSaveFiles(const std::map< WsfPProxyPath, std::string > &aProxySaveLocations)
Definition WsfPProxyFileWriter.hpp:61
void AddChange(WsfPProxyFileWriterChange c)
Definition WsfPProxyFileWriter.cpp:29
~WsfPProxyFileWriter()=default
void SetIncludeDirectories(const UtPath &aWorkingDirectory, const std::vector< UtStringRef > &aIncludeDirectories)
Definition WsfPProxyFileWriter.cpp:377
WsfPProxyFileWriter()
Definition WsfPProxyFileWriter.cpp:23
void ApplyChanges()
Definition WsfPProxyFileWriter.cpp:58
void WriteTrace(WsfPParseRuleTrace *aTracePtr)
Definition WsfPProxyFileWriter.cpp:163
Definition WsfParseNode.hpp:61
Interface providing source files to the WsfParser.
Definition WsfParseSourceProvider.hpp:24
Definition WsfPProxyFileWriter.hpp:29
UtTextDocumentRange mReplaceRange
Definition WsfPProxyFileWriter.hpp:30
void ApplyChangeToRange(UtTextRange &aRange) const
Definition WsfPProxyFileWriter.hpp:33
std::string mReplaceText
Definition WsfPProxyFileWriter.hpp:31
Copyrights Multiple, All Rights Reserved