|
12345678910111213141516171819202122232425262728 |
- class Type:
- def __init__(self, s):
- # Currently no recursion is allowed,
- # so you can't have a dictionary in dictionary.
- self.name = None
- self.first = None
- self.second = None
-
- # Dictionary.
- if s.startswith("std::map"):
- self.name = "map"
- # Remove prefix and suffix.
- prefix = "std::map<"
- s = s[len(prefix):]
- suffix = ">"
- s = s[:-len(suffix)]
- # Get map types.
- parts = s.split(", ")
- self.first = parts[0]
- self.second = parts[1]
- # By default we treat the type as is.
- else:
- self.name = s
-
- def __repr__(self):
- return self.__str__()
- def __str__(self):
- return f"Type(n/f/s: '{self.name}'/'{self.first}'/'{self.second}')"
|