OpenASIP  2.0
HDLTemplateInstantiator.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2011 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file HDLTemplateInstantiator.hh
26  *
27  * @author Pekka Jääskeläinen 2011
28  * @note rating: red
29  */
30 
31 #ifndef TTA_HDL_TEMPLATE_INSTANTIATOR_HH
32 #define TTA_HDL_TEMPLATE_INSTANTIATOR_HH
33 
34 #include <map>
35 #include <string>
36 
37 #include "TCEString.hh"
38 #include "Exception.hh"
39 
40 class Path;
41 
42 /**
43  * Helper class for instantiating HDL template files.
44  */
46 public:
48 
50  HDLTemplateInstantiator(const TCEString& entityStr);
51  void setEntityString(const TCEString& entityStr) {
52  entityStr_ = entityStr; }
53  void replacePlaceholder(
54  const std::string& key, const std::string& replacer,
55  bool append = false);
57  const std::string& key,
58  const Path& filePath,
59  bool append = false);
61  const std::string& templateFile,
62  const std::string& dstFile);
63 
64 private:
67  typedef std::map<PlaceholderKey, Replacer> ReplacerMap;
68 
69  void fillPlaceholders(TCEString& str);
73 
74  static const std::string PLACEHOLDERSEPARATOR;
75  static const std::string PLACEHOLDERBEGIN;
76  static const std::string PLACEHOLDEREND;
77 
80 
81 };
82 #endif
Path
Definition: FileSystem.hh:197
HDLTemplateInstantiator
Definition: HDLTemplateInstantiator.hh:45
Exception.hh
HDLTemplateInstantiator::findPlaceholder
TCEString findPlaceholder(const TCEString &str)
Definition: HDLTemplateInstantiator.cc:189
HDLTemplateInstantiator::HDLTemplateInstantiator
HDLTemplateInstantiator()
Definition: HDLTemplateInstantiator.cc:42
HDLTemplateInstantiator::getPlaceholderDefault
TCEString getPlaceholderDefault(const TCEString &str)
Definition: HDLTemplateInstantiator.cc:247
HDLTemplateInstantiator::PlaceholderKey
TCEString PlaceholderKey
Definition: HDLTemplateInstantiator.hh:65
HDLTemplateInstantiator::HDLTemplateInstantiatorTest
friend class HDLTemplateInstantiatorTest
Definition: HDLTemplateInstantiator.hh:47
HDLTemplateInstantiator::replacePlaceholderFromFile
void replacePlaceholderFromFile(const std::string &key, const Path &filePath, bool append=false)
Definition: HDLTemplateInstantiator.cc:89
HDLTemplateInstantiator::Replacer
TCEString Replacer
Definition: HDLTemplateInstantiator.hh:66
TCEString.hh
HDLTemplateInstantiator::replacers_
ReplacerMap replacers_
Definition: HDLTemplateInstantiator.hh:79
HDLTemplateInstantiator::fillPlaceholders
void fillPlaceholders(TCEString &str)
Definition: HDLTemplateInstantiator.cc:153
HDLTemplateInstantiator::ReplacerMap
std::map< PlaceholderKey, Replacer > ReplacerMap
Definition: HDLTemplateInstantiator.hh:67
HDLTemplateInstantiator::getPlaceholderKey
TCEString getPlaceholderKey(const TCEString &str)
Definition: HDLTemplateInstantiator.cc:215
HDLTemplateInstantiator::replacePlaceholder
void replacePlaceholder(const std::string &key, const std::string &replacer, bool append=false)
Definition: HDLTemplateInstantiator.cc:62
HDLTemplateInstantiator::entityStr_
TCEString entityStr_
Definition: HDLTemplateInstantiator.hh:78
HDLTemplateInstantiator::setEntityString
void setEntityString(const TCEString &entityStr)
Definition: HDLTemplateInstantiator.hh:51
TCEString
Definition: TCEString.hh:53
HDLTemplateInstantiator::PLACEHOLDEREND
static const std::string PLACEHOLDEREND
Definition: HDLTemplateInstantiator.hh:76
HDLTemplateInstantiator::instantiateTemplateFile
void instantiateTemplateFile(const std::string &templateFile, const std::string &dstFile)
Definition: HDLTemplateInstantiator.cc:113
HDLTemplateInstantiator::PLACEHOLDERSEPARATOR
static const std::string PLACEHOLDERSEPARATOR
Definition: HDLTemplateInstantiator.hh:74
HDLTemplateInstantiator::PLACEHOLDERBEGIN
static const std::string PLACEHOLDERBEGIN
Definition: HDLTemplateInstantiator.hh:75