3from .Attribute
import Attribute
9 Wrapper around C++ string which is not a dataype supported by
12 max_length Maximum length of the strings that can be handled.
13 The shorter you keep this value, the smaller the
14 MPI message size, as we don't use dynamic data
15 structures. We always map the C++ string onto an
16 array with max_length entries.
25 qualifier=Attribute.Qualifier.NONE,
28 if initval
is not None:
31 if not initval.startswith(
'"'):
32 initval =
'"' + initval
34 if not initval.endswith(
'\\0"'):
35 if initval.endswith(
'"'):
38 initval = initval[:-1]
43 expose = qualifier == Attribute.Qualifier.CONSTEXPR
51 expose_in_header_file=expose,
57 def get_methods(self, _full_qualified_class_name, for_declaration=True):
64 getter = (
"get" + accessor_name +
"()",
"static std::string")
67 getter = (
"get" + accessor_name +
"()",
"std::string")
72 getter = (
"get" + accessor_name +
"()",
"static std::string")
76 getter = (
"get" + accessor_name +
"()",
"std::string")
79 getter = (
"get" + accessor_name +
"() const",
"const std::string")
82 raise NotImplementedError(
"Strings + constexpr not implemented yet.")
87 getter = (
"get" + accessor_name +
"() const",
"std::string")
89 methods.append(getter)
94 (
"set" + accessor_name +
"(const std::string& value)",
"void")
109 typestring =
"inline static char"
110 lengthtype =
"inline static int"
117 lengthtype =
"inline static int"
120 typestring =
"inline const static char"
125 lengthtype =
"inline const static int"
128 typestring =
"const char"
133 lengthtype =
"const int"
136 raise NotImplementedError(
"Strings + constexpr not implemented yet.")
147 if self.
_initval is not None and not for_constructor:
154 lengthstring =
"_" + self.
_name +
"Length"
155 if lengthval
is not None:
158 lengthstring +=
" = " + str(lengthval)
161 (namestring, typestring,
""),
162 (lengthstring, lengthtype),
169 if signature.startswith(
"get"):
172 std::ostringstream result;
176 result << static_cast<char>(_"""
183 elif signature.startswith(
"set"):
188 +
"""Length = value.length();
189 for (int i=0; i<value.length(); i++) {
192 +
"""[i] = value.data()[i];
202 return [(
"MPI_CHAR", self.
_max_length), (
"MPI_INT", 1)]
207 Return string representation of attribute.
Represents one attribute.
get_accessor_name(self)
Generate the accessor name used throughout dastgen2 to create variables, function names,...
Wrapper around C++ string which is not a dataype supported by MPI natively.
get_methods(self, _full_qualified_class_name, for_declaration=True)
Return sequence of methods that are defined for this attribute.
get_to_string(self)
Return string representation of attribute.
get_method_body(self, signature)
I hand in the method signature (see get_methods()) and wanna get the whole implementation.
get_native_MPI_type(self)
Return native (built-in) MPI datatype.
get_plain_C_attributes(self, for_constructor=False)
Return list of n-tuples.
__init__(self, name, max_length=80, ifdefs=[], qualifier=Attribute.Qualifier.NONE, initval=None)
name: String This is a plain string which has to follow the C++ naming conventions,...
get_setter_getter_name(self)