Cerata
A library to generate structural hardware designs
identifier.h
1 // Copyright 2018-2019 Delft University of Technology
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <optional>
18 #include <string>
19 #include <vector>
20 #include <deque>
21 #include <algorithm>
22 
23 #include "cerata/utils.h"
24 
25 namespace cerata::vhdl {
26 
30 class Identifier {
31  public:
32  Identifier() = default;
34  Identifier(std::initializer_list<std::string> parts, std::optional<char> sep = '_');
36  explicit Identifier(std::deque<std::string> parts, std::optional<char> sep = '_');
38  Identifier &append(const std::string &part);
40  Identifier &prepend(const std::string &part);
42  Identifier &operator+=(const std::string &rhs);
44  Identifier operator+(const std::string &rhs) const;
46  [[nodiscard]] std::string ToString() const;
47  private:
49  std::optional<char> separator_ = '_';
51  std::deque<std::string> parts_;
52 };
53 
54 } // namespace cerata::vhdl
cerata::vhdl::Identifier::prepend
Identifier & prepend(const std::string &part)
Append a part to the Identifier.
Definition: identifier.cc:53
cerata::vhdl::Identifier::operator+
Identifier operator+(const std::string &rhs) const
Create a copy and add a new part to the Identifier.
Definition: identifier.cc:69
cerata::vhdl::Identifier::append
Identifier & append(const std::string &part)
Append a part to the Identifier.
Definition: identifier.cc:46
cerata::vhdl::Identifier::ToString
std::string ToString() const
Return a human-readable string of the identifier.
Definition: identifier.cc:23
cerata::vhdl::Identifier::operator+=
Identifier & operator+=(const std::string &rhs)
Append a part to the Identifier.
Definition: identifier.cc:65
cerata::vhdl::Identifier
A VHDL Identifier convenience structure.
Definition: identifier.h:30
cerata::vhdl
Contains everything related to the VHDL back-end.
Definition: architecture.cc:31