2#include <NDEVR/Model.h>
4#include <NDEVR/Translator.h>
10 class ContactName :
public Model
13 ContactName(
const Model& model)
17 if (!isOfType(TypeName()))
20 setModelProperty(Model::e_type, TypeName());
23 void set(
const String& name)
25 setProperty(DesignObject::e_untranslated_string_data, name);
29 return getProperty<String>(DesignObject::e_untranslated_string_data);
31 static constexpr const char* ValidRegex() {
return "(\\w+)(\\.|_)?(\\w*)@(\\w+)(\\.(\\w+))+"; }
32 static constexpr const char* TypeName() {
return "contact_name"; }
34 class TelephoneNumber :
public Model
37 TelephoneNumber(
const Model& model)
40 if (!isOfType(TypeName()))
43 setModelProperty(Model::e_type, TypeName());
44 setProperty(Model::e_name,
_t(
"Mobile"));
45 setProperty(Model::e_icon,
"mobile");
48 String phoneNumber()
const
50 return getProperty<String>(DesignObject::e_untranslated_string_data);
52 void updatePhoneNumber(
const String& phone_number,
const void* lock_ptr =
nullptr)
54 updateProperty<String>(DesignObject::e_untranslated_string_data, phone_number, lock_ptr);
56 String phoneNumberName()
const
58 return getProperty<String>(DesignObject::e_name);
60 void updatePhoneNumberName(
const String& phone_number_name,
const void* lock_ptr =
nullptr)
62 updateProperty<String>(DesignObject::e_name, phone_number_name, lock_ptr);
64 static constexpr const char* ValidRegex() {
return "sad"; }
65 static constexpr const char* TypeName() {
return "telephone_number"; }
69 class PhysicalAddressModel :
public Model
72 PhysicalAddressModel(
const Model& model)
75 if (getModelProperty<String>(Model::e_type) != TypeName())
77 setModelProperty(Model::e_type, TypeName());
79 setProperty(Model::e_name,
_t(
"Address"));
80 setProperty(Model::e_icon,
"pin");
83 String address()
const
85 return getProperty<String>(DesignObject::e_untranslated_string_data);
87 void setAddress(
const String& address)
89 lib_assert(address.count(
'\t') == 3,
"Bad Address");
90 if (address.count(
'\t') == 3)
91 updateProperty(DesignObject::e_untranslated_string_data, address);
93 String streetAddress()
const
95 return getProperty<String>(DesignObject::e_untranslated_string_data).splitString(
'\t')[0];
97 void setStreetAddress(
const String& street)
99 String current_data = getProperty<String>(DesignObject::e_untranslated_string_data);
100 Buffer<String> parts = current_data.splitString(
'\t');
102 current_data.clear();
103 for (uint04 i = 0; i < parts.size(); i++)
106 current_data += street;
108 current_data += parts[i];
110 current_data +=
"\t";
112 setAddress(current_data);
116 String s = getProperty<String>(DesignObject::e_untranslated_string_data);
117 if (s.contains(
'\t'))
118 return s.splitString(
'\t')[1];
122 void setCity(
const String& city)
124 String current_data = getProperty<String>(DesignObject::e_untranslated_string_data);
125 Buffer<String> parts = current_data.splitString(
'\t');
127 current_data.clear();
128 for (uint04 i = 0; i < parts.size(); i++)
131 current_data += city;
133 current_data += parts[i];
135 current_data +=
"\t";
137 setAddress(current_data);
142 String s = getProperty<String>(DesignObject::e_untranslated_string_data);
143 if (s.count(
'\t') >= 2)
144 return s.splitString(
'\t')[2];
148 void setState(
const String& state)
150 String current_data = getProperty<String>(DesignObject::e_untranslated_string_data);
151 Buffer<String> parts = current_data.splitString(
'\t');
153 current_data.clear();
154 for (uint04 i = 0; i < parts.size(); i++)
157 current_data += state;
159 current_data += parts[i];
161 current_data +=
"\t";
163 setAddress(current_data);
166 String zipCode()
const
168 String s = getProperty<String>(DesignObject::e_untranslated_string_data);
169 if (s.count(
'\t') >= 3)
170 return s.splitString(
'\t')[3];
174 void setZipCode(
const String& zip)
176 String current_data = getProperty<String>(DesignObject::e_untranslated_string_data);
177 Buffer<String> parts = current_data.splitString(
'\t');
179 current_data.clear();
180 for (uint04 i = 0; i < parts.size(); i++)
185 current_data += parts[i];
187 current_data +=
"\t";
189 setAddress(current_data);
191 static constexpr const char* TypeName() {
return "physical_address"; }
193 class EmailAddress :
public Model
196 EmailAddress(
const Model& model)
199 if (!isOfType(TypeName()))
202 setModelProperty(Model::e_type, TypeName());
205 static constexpr const char* TypeName() {
return "email_address"; }
206 void set(
const String& email)
208 setProperty(DesignObject::e_untranslated_string_data, email);
212 return getProperty<String>(DesignObject::e_untranslated_string_data);
215 class CompanyName :
public Model
218 CompanyName(
const Model& model)
221 if (!isOfType(TypeName()))
224 setModelProperty(Model::e_type, TypeName());
227 void set(
const String& companyName)
229 setProperty(DesignObject::e_untranslated_string_data, companyName);
233 return getProperty<String>(DesignObject::e_untranslated_string_data);
235 static constexpr const char* TypeName() {
return "company_name"; }
237 class CompanyRole :
public Model
240 CompanyRole(
const Model& model)
243 if (!isOfType(TypeName()))
246 setModelProperty(Model::e_type, TypeName());
249 void set(
const String& role)
251 setProperty(DesignObject::e_untranslated_string_data, role);
255 return getProperty<String>(DesignObject::e_untranslated_string_data);
257 static constexpr const char* TypeName() {
return "company_role"; }
260 class ContactInfo :
public Model
263 ContactInfo(
const Model& model)
266 if (!isOfType(TypeName()))
270 setModelProperty(Model::e_type, TypeName());
271 setProperty(DesignObject::e_name,
_t(
"Contact"));
274 ContactName contactName()
276 return ContactName(getChild(0));
278 TelephoneNumber telephoneNumber()
280 return TelephoneNumber(getChild(1));
282 EmailAddress emailAddress()
284 return EmailAddress(getChild(2));
286 CompanyName companyName()
288 return CompanyName(getChild(3));
290 CompanyRole companyRole()
292 return CompanyRole(getChild(4));
294 static constexpr const char* TypeName() {
return "contact_info"; }
#define lib_assert(expression, message)
Definition LibAssert.h:61
#define _t(english_string)
Definition Translator.h:90