WSF
XML_Context.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#ifndef XML_HPP
12#define XML_HPP
13
14#include <assert.h>
15#include <map>
16#include <string>
17
18#include "UtPath.hpp"
19#include "UtQtXmlReader.hpp"
20#include "UtQtXmlWriter.hpp"
21
22namespace wizard
23{
25{
26public:
28 void Add(const std::string& aName, int aValue)
29 {
30 mNameToValue[aName] = aValue;
31 mValueToName[aValue] = aName;
32 }
33
34
35 std::string GetName(int aValue, const char* aDefaultName = nullptr)
36 {
37 std::map<int, std::string>::iterator i = mValueToName.find(aValue);
38 if (i != mValueToName.end())
39 return i->second;
40 assert(aDefaultName);
41 return aDefaultName;
42 }
43
44 int GetValue(const std::string& aName, int aDefaultValue = -1)
45 {
46 std::map<std::string, int>::iterator i = mNameToValue.find(aName);
47 if (i != mNameToValue.end())
48 return i->second;
49 return aDefaultValue;
50 }
51
52private:
53 std::map<std::string, int> mNameToValue;
54 std::map<int, std::string> mValueToName;
55};
56
58{
59public:
60 explicit XML_Context(UtQtXmlWriter* aWriter);
61 explicit XML_Context(UtQtXmlReader* aReader);
62 const UtPath& GetFileName() const { return mFileName; }
63 void SetFileName(const UtPath& aPath)
64 {
65 mFileName = aPath;
66 mFileDirectory = aPath;
67 mFileDirectory.Up();
68 }
69 const UtPath& GetFileDirectory() const { return mFileDirectory; }
70 UtQtXmlWriter& GetWriter() { return *mXmlWriter; }
71 UtQtXmlReader& GetReader() { return *mXmlReader; }
72
73protected:
74 UtPath mFileName;
76 UtQtXmlWriter* mXmlWriter;
77 UtQtXmlReader* mXmlReader;
78};
79} // namespace wizard
80
81#endif
void Add(const std::string &aName, int aValue)
Definition XML_Context.hpp:28
Enumeration()
Definition XML_Context.hpp:27
std::string GetName(int aValue, const char *aDefaultName=nullptr)
Definition XML_Context.hpp:35
int GetValue(const std::string &aName, int aDefaultValue=-1)
Definition XML_Context.hpp:44
XML_Context(UtQtXmlWriter *aWriter)
Definition XML_Context.cpp:13
UtPath mFileDirectory
Definition XML_Context.hpp:75
const UtPath & GetFileName() const
Definition XML_Context.hpp:62
void SetFileName(const UtPath &aPath)
Definition XML_Context.hpp:63
UtQtXmlReader & GetReader()
Definition XML_Context.hpp:71
UtQtXmlWriter & GetWriter()
Definition XML_Context.hpp:70
UtPath mFileName
Definition XML_Context.hpp:74
UtQtXmlReader * mXmlReader
Definition XML_Context.hpp:77
UtQtXmlWriter * mXmlWriter
Definition XML_Context.hpp:76
const UtPath & GetFileDirectory() const
Definition XML_Context.hpp:69
Definition Runner.hpp:22
Copyrights Multiple, All Rights Reserved