Line data Source code
1 : #include "EdaDataFile.h"
2 : #include <fstream>
3 : #include <sstream>
4 : #include "str_utils.h"
5 : #include "../../enums.h"
6 : #include "edadatafile.pb.h"
7 : #include "ArchiveExtractor.h"
8 : #include "Logger.h"
9 : #include "../parse_info.h"
10 : #include "../parse_error.h"
11 : #include "../invalid_odb_error.h"
12 : #include "../../Text/Utf8Sanitizer.h"
13 :
14 : using namespace std::filesystem;
15 : using namespace Utils;
16 :
17 : namespace Odb::Lib::FileModel::Design
18 : {
19 102 : EdaDataFile::EdaDataFile(bool logAllLineParsing)
20 102 : : m_logAllLineParsing(logAllLineParsing)
21 : {
22 102 : }
23 :
24 84 : EdaDataFile::~EdaDataFile()
25 : {
26 84 : m_layerNames.clear();
27 84 : m_attributeNames.clear();
28 84 : m_attributeTextValues.clear();
29 84 : m_netRecords.clear();
30 84 : m_netRecordsByName.clear();
31 84 : m_packageRecords.clear();
32 84 : m_packageRecordsByName.clear();
33 84 : m_featureGroupRecords.clear();
34 84 : m_propertyRecords.clear();
35 84 : }
36 :
37 0 : const std::filesystem::path& EdaDataFile::GetPath() const
38 : {
39 0 : return m_path;
40 : }
41 :
42 0 : const std::filesystem::path& EdaDataFile::GetDirectory() const
43 : {
44 0 : return m_directory;
45 : }
46 :
47 0 : const std::string& EdaDataFile::GetUnits() const
48 : {
49 0 : return m_units;
50 : }
51 :
52 0 : const std::string& EdaDataFile::GetSource() const
53 : {
54 0 : return m_source;
55 : }
56 :
57 828954 : EdaDataFile::NetRecord::SubnetRecord::~SubnetRecord()
58 : {
59 828954 : m_featureIdRecords.clear();
60 828954 : }
61 :
62 886191 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord> EdaDataFile::NetRecord::SubnetRecord::to_protobuf() const
63 : {
64 886191 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord> pSubnetRecordMessage(new Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord);
65 886191 : pSubnetRecordMessage->set_type((Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord::Type) type);
66 886191 : if (type == Type::Toeprint)
67 : {
68 249249 : pSubnetRecordMessage->set_componentnumber(componentNumber);
69 249249 : pSubnetRecordMessage->set_toeprintnumber(toeprintNumber);
70 249249 : pSubnetRecordMessage->set_side((Odb::Lib::Protobuf::BoardSide)side);
71 : }
72 636942 : else if (type == Type::Plane)
73 : {
74 9455 : pSubnetRecordMessage->set_filltype((Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord::FillType)fillType);
75 9455 : pSubnetRecordMessage->set_cutouttype((Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord::CutoutType) cutoutType);
76 9455 : pSubnetRecordMessage->set_fillsize(fillSize);
77 : }
78 :
79 6001560 : for (const auto& featureIdRecord : m_featureIdRecords)
80 : {
81 5115369 : auto pFeatureIdRecordMessage = pSubnetRecordMessage->add_featureidrecords();
82 5115369 : pFeatureIdRecordMessage->CopyFrom(*featureIdRecord->to_protobuf());
83 : }
84 886191 : return pSubnetRecordMessage;
85 0 : }
86 :
87 52389 : void EdaDataFile::NetRecord::SubnetRecord::from_protobuf(const Odb::Lib::Protobuf::EdaDataFile::NetRecord::SubnetRecord& message)
88 : {
89 52389 : type = static_cast<Type>(message.type());
90 :
91 52389 : if (type == Type::Toeprint)
92 : {
93 13327 : componentNumber = message.componentnumber();
94 13327 : toeprintNumber = message.toeprintnumber();
95 13327 : side = static_cast<BoardSide>(message.side());
96 : }
97 39062 : else if (type == Type::Plane)
98 : {
99 841 : fillType = static_cast<FillType>(message.filltype());
100 841 : cutoutType = static_cast<CutoutType>(message.cutouttype());
101 841 : fillSize = message.fillsize();
102 841 : index = message.index();
103 : }
104 :
105 356432 : for (const auto& featureIdRecordMessage : message.featureidrecords())
106 : {
107 304043 : auto pFeatureIdRecord = std::make_shared<FeatureIdRecord>();
108 304043 : pFeatureIdRecord->from_protobuf(featureIdRecordMessage);
109 304043 : m_featureIdRecords.push_back(pFeatureIdRecord);
110 304043 : }
111 52389 : }
112 :
113 53059 : EdaDataFile::NetRecord::~NetRecord()
114 : {
115 53059 : m_subnetRecords.clear();
116 53059 : m_propertyRecords.clear();
117 53059 : }
118 :
119 59200 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::NetRecord> EdaDataFile::NetRecord::to_protobuf() const
120 : {
121 59200 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::NetRecord> pNetRecordMessage(new Odb::Lib::Protobuf::EdaDataFile::NetRecord);
122 118400 : pNetRecordMessage->set_name(Odb::Lib::Text::ToUtf8(name));
123 : //pNetRecordMessage->set_attributesidstring(attributesIdString);
124 59200 : pNetRecordMessage->set_index(index);
125 59200 : if (id.has_value())
126 : {
127 2 : pNetRecordMessage->set_id(*id);
128 : }
129 :
130 59200 : for (const auto& propertyRecord : m_propertyRecords)
131 : {
132 0 : auto pPropertyRecordMessage = pNetRecordMessage->add_propertyrecords();
133 0 : pPropertyRecordMessage->CopyFrom(*propertyRecord->to_protobuf());
134 : }
135 :
136 945391 : for (const auto& subnetRecord : m_subnetRecords)
137 : {
138 886191 : auto pSubnetRecordMessage = pNetRecordMessage->add_subnetrecords();
139 886191 : pSubnetRecordMessage->CopyFrom(*subnetRecord->to_protobuf());
140 : }
141 118398 : for (const auto& kvAttributeAssignment : m_attributeLookupTable)
142 : {
143 59198 : (*pNetRecordMessage->mutable_attributelookuptable())[Odb::Lib::Text::ToUtf8(kvAttributeAssignment.first)] = Odb::Lib::Text::ToUtf8(kvAttributeAssignment.second);
144 : }
145 59200 : return pNetRecordMessage;
146 0 : }
147 :
148 3288 : void EdaDataFile::NetRecord::from_protobuf(const Odb::Lib::Protobuf::EdaDataFile::NetRecord& message)
149 : {
150 3288 : name = message.name();
151 : //attributesIdString = message.attributesidstring();
152 3288 : index = message.index();
153 3288 : if (message.has_id())
154 : {
155 2 : id = message.id();
156 : }
157 :
158 3288 : for (const auto& propertyRecordMessage : message.propertyrecords())
159 : {
160 0 : auto pPropertyRecord = std::make_shared<PropertyRecord>();
161 0 : pPropertyRecord->from_protobuf(propertyRecordMessage);
162 0 : m_propertyRecords.push_back(pPropertyRecord);
163 0 : }
164 :
165 55677 : for (const auto& subnetRecordMessage : message.subnetrecords())
166 : {
167 52389 : auto pSubnetRecord = std::make_shared<SubnetRecord>();
168 52389 : pSubnetRecord->from_protobuf(subnetRecordMessage);
169 52389 : m_subnetRecords.push_back(pSubnetRecord);
170 52389 : }
171 :
172 9860 : for (const auto& kvAttributeAssignment : message.attributelookuptable())
173 : {
174 3286 : m_attributeLookupTable[kvAttributeAssignment.first] = kvAttributeAssignment.second;
175 : }
176 3288 : }
177 :
178 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::FeatureIdRecord>
179 5115370 : EdaDataFile::FeatureIdRecord::to_protobuf() const
180 : {
181 5115370 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::FeatureIdRecord> pFeatureIdRecordMessage(new Odb::Lib::Protobuf::EdaDataFile::FeatureIdRecord);
182 5115370 : pFeatureIdRecordMessage->set_type((Odb::Lib::Protobuf::EdaDataFile::FeatureIdRecord::Type) type);
183 5115370 : pFeatureIdRecordMessage->set_layernumber(layerNumber);
184 5115370 : pFeatureIdRecordMessage->set_featurenumber(featureNumber);
185 5115370 : return pFeatureIdRecordMessage;
186 0 : }
187 :
188 304044 : void EdaDataFile::FeatureIdRecord::from_protobuf(const Odb::Lib::Protobuf::EdaDataFile::FeatureIdRecord& message)
189 : {
190 304044 : type = static_cast<Type>(message.type());
191 304044 : layerNumber = message.layernumber();
192 304044 : featureNumber = message.featurenumber();
193 304044 : }
194 :
195 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::FeatureGroupRecord>
196 1 : EdaDataFile::FeatureGroupRecord::to_protobuf() const
197 : {
198 1 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::FeatureGroupRecord> pFeatureGroupRecordMessage(new Odb::Lib::Protobuf::EdaDataFile::FeatureGroupRecord);
199 2 : pFeatureGroupRecordMessage->set_type(Odb::Lib::Text::ToUtf8(type));
200 2 : for (const auto& featureIdRecord : m_featureIdRecords)
201 : {
202 1 : auto pFeatureIdRecordMessage = pFeatureGroupRecordMessage->add_featureidrecords();
203 1 : pFeatureIdRecordMessage->CopyFrom(*featureIdRecord->to_protobuf());
204 : }
205 2 : for (const auto& propertyRecord : m_propertyRecords)
206 : {
207 : // PropertyRecord payloads belong in propertyrecords (field 2); the
208 : // previous add_featureidrecords() here was a cross-type
209 : // Message::CopyFrom (type confusion / UB) whenever a design carries
210 : // feature-group property records.
211 1 : auto pPropertyRecordMessage = pFeatureGroupRecordMessage->add_propertyrecords();
212 1 : pPropertyRecordMessage->CopyFrom(*propertyRecord->to_protobuf());
213 : }
214 1 : return pFeatureGroupRecordMessage;
215 0 : }
216 :
217 1 : void EdaDataFile::FeatureGroupRecord::from_protobuf(const Odb::Lib::Protobuf::EdaDataFile::FeatureGroupRecord& message)
218 : {
219 1 : type = message.type();
220 2 : for (const auto& featureIdRecordMessage : message.featureidrecords())
221 : {
222 1 : auto pFeatureIdRecord = std::make_shared<FeatureIdRecord>();
223 1 : pFeatureIdRecord->from_protobuf(featureIdRecordMessage);
224 1 : m_featureIdRecords.push_back(pFeatureIdRecord);
225 1 : }
226 2 : for (const auto& propertyRecordMessage : message.propertyrecords())
227 : {
228 1 : auto pPropertyRecord = std::make_shared<PropertyRecord>();
229 1 : pPropertyRecord->from_protobuf(propertyRecordMessage);
230 1 : m_propertyRecords.push_back(pPropertyRecord);
231 1 : }
232 1 : }
233 :
234 82 : const std::vector<std::string>& EdaDataFile::GetLayerNames() const
235 : {
236 82 : return m_layerNames;
237 : }
238 :
239 82 : const std::vector<std::string>& EdaDataFile::GetAttributeNames() const
240 : {
241 82 : return m_attributeNames;
242 : }
243 :
244 82 : const std::vector<std::string>& EdaDataFile::GetAttributeTextValues() const
245 : {
246 82 : return m_attributeTextValues;
247 : }
248 :
249 224 : const EdaDataFile::NetRecord::Vector& EdaDataFile::GetNetRecords() const
250 : {
251 224 : return m_netRecords;
252 : }
253 :
254 0 : const EdaDataFile::NetRecord::StringMap& EdaDataFile::GetNetRecordsByName() const
255 : {
256 0 : return m_netRecordsByName;
257 : }
258 :
259 224 : const EdaDataFile::PackageRecord::Vector& EdaDataFile::GetPackageRecords() const
260 : {
261 224 : return m_packageRecords;
262 : }
263 :
264 0 : const EdaDataFile::PackageRecord::StringMap& EdaDataFile::GetPackageRecordsByName() const
265 : {
266 0 : return m_packageRecordsByName;
267 : }
268 :
269 82 : const EdaDataFile::FeatureGroupRecord::Vector& EdaDataFile::GetFeatureGroupRecords() const
270 : {
271 82 : return m_featureGroupRecords;
272 : }
273 :
274 82 : const PropertyRecord::Vector& EdaDataFile::GetPropertyRecords() const
275 : {
276 82 : return m_propertyRecords;
277 : }
278 :
279 97 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile> EdaDataFile::to_protobuf() const
280 : {
281 97 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile> pEdaDataFileMessage(new Odb::Lib::Protobuf::EdaDataFile);
282 194 : pEdaDataFileMessage->set_path(Odb::Lib::Text::ToUtf8(m_path.string()));
283 194 : pEdaDataFileMessage->set_units(Odb::Lib::Text::ToUtf8(m_units));
284 194 : pEdaDataFileMessage->set_source(Odb::Lib::Text::ToUtf8(m_source));
285 1640 : for (const auto& layerName : m_layerNames)
286 : {
287 1543 : pEdaDataFileMessage->add_layernames(Odb::Lib::Text::ToUtf8(layerName));
288 : }
289 187 : for (const auto& attributeName : m_attributeNames)
290 : {
291 90 : pEdaDataFileMessage->add_attributenames(Odb::Lib::Text::ToUtf8(attributeName));
292 : }
293 97 : for (const auto& attrTextValue : m_attributeTextValues)
294 : {
295 0 : pEdaDataFileMessage->add_attributetextvalues(Odb::Lib::Text::ToUtf8(attrTextValue));
296 : }
297 59295 : for (const auto& pNetRecord : m_netRecords)
298 : {
299 59198 : auto pNetRecordMessage = pEdaDataFileMessage->add_netrecords();
300 59198 : pNetRecordMessage->CopyFrom(*pNetRecord->to_protobuf());
301 : }
302 97 : for (const auto& kvNetRecord : m_netRecordsByName)
303 : {
304 0 : (*pEdaDataFileMessage->mutable_netrecordsbyname())[Odb::Lib::Text::ToUtf8(kvNetRecord.first)] = *kvNetRecord.second->to_protobuf();
305 : }
306 8628 : for (const auto& pPackageRecord : m_packageRecords)
307 : {
308 8531 : auto pPackageRecordMessage = pEdaDataFileMessage->add_packagerecords();
309 8531 : pPackageRecordMessage->CopyFrom(*pPackageRecord->to_protobuf());
310 : }
311 97 : for (const auto& kvPackageRecord : m_packageRecordsByName)
312 : {
313 0 : (*pEdaDataFileMessage->mutable_packagerecordsbyname())[Odb::Lib::Text::ToUtf8(kvPackageRecord.first)] = *kvPackageRecord.second->to_protobuf();
314 : }
315 97 : for (const auto& pPropertyRecord : m_propertyRecords)
316 : {
317 0 : auto pPropertyRecordMessage = pEdaDataFileMessage->add_propertyrecords();
318 0 : pPropertyRecordMessage->CopyFrom(*pPropertyRecord->to_protobuf());
319 : }
320 97 : for (const auto& pFeatureGroupRecord : m_featureGroupRecords)
321 : {
322 0 : auto pFeatureGroupRecordMessage = pEdaDataFileMessage->add_featuregrouprecords();
323 0 : pFeatureGroupRecordMessage->CopyFrom(*pFeatureGroupRecord->to_protobuf());
324 : }
325 :
326 97 : return pEdaDataFileMessage;
327 0 : }
328 :
329 8 : void EdaDataFile::from_protobuf(const Odb::Lib::Protobuf::EdaDataFile& message)
330 : {
331 8 : m_path = message.path();
332 8 : m_units = message.units();
333 8 : m_source = message.source();
334 113 : for (const auto& layerName : message.layernames())
335 : {
336 105 : m_layerNames.push_back(layerName);
337 : }
338 18 : for (const auto& attributeName : message.attributenames())
339 : {
340 10 : m_attributeNames.push_back(attributeName);
341 : }
342 8 : for (const auto& attrTextValue : message.attributetextvalues())
343 : {
344 0 : m_attributeTextValues.push_back(attrTextValue);
345 : }
346 3294 : for (const auto& netRecordMessage : message.netrecords())
347 : {
348 3286 : auto pNetRecord = std::make_shared<NetRecord>();
349 3286 : pNetRecord->from_protobuf(netRecordMessage);
350 3286 : m_netRecords.push_back(pNetRecord);
351 3286 : }
352 8 : for (const auto& kvNetRecordMessage : message.netrecordsbyname())
353 : {
354 0 : auto pNetRecord = std::make_shared<NetRecord>();
355 0 : pNetRecord->from_protobuf(kvNetRecordMessage.second);
356 0 : m_netRecordsByName[kvNetRecordMessage.first] = pNetRecord;
357 0 : }
358 593 : for (const auto& packageRecordMessage : message.packagerecords())
359 : {
360 585 : auto pPackageRecord = std::make_shared<PackageRecord>();
361 585 : pPackageRecord->from_protobuf(packageRecordMessage);
362 585 : m_packageRecords.push_back(pPackageRecord);
363 585 : }
364 8 : for (const auto& kvPackageRecordMessage : message.packagerecordsbyname())
365 : {
366 0 : auto pPackageRecord = std::make_shared<PackageRecord>();
367 0 : pPackageRecord->from_protobuf(kvPackageRecordMessage.second);
368 0 : m_packageRecordsByName[kvPackageRecordMessage.first] = pPackageRecord;
369 0 : }
370 8 : for (const auto& propertyRecordMessage : message.propertyrecords())
371 : {
372 0 : auto pPropertyRecord = std::make_shared<PropertyRecord>();
373 0 : pPropertyRecord->from_protobuf(propertyRecordMessage);
374 0 : m_propertyRecords.push_back(pPropertyRecord);
375 0 : }
376 8 : for (const auto& featureGroupRecordMessage : message.featuregrouprecords())
377 : {
378 0 : auto pFeatureGroupRecord = std::make_shared<FeatureGroupRecord>();
379 0 : pFeatureGroupRecord->from_protobuf(featureGroupRecordMessage);
380 0 : m_featureGroupRecords.push_back(pFeatureGroupRecord);
381 0 : }
382 8 : }
383 :
384 0 : bool EdaDataFile::Save(std::ostream& os)
385 : {
386 0 : return true;
387 : }
388 :
389 94 : bool EdaDataFile::Parse(std::filesystem::path path)
390 : {
391 94 : std::ifstream edaDataFile;
392 94 : int lineNumber = 0;
393 94 : std::string line;
394 :
395 : try
396 : {
397 376 : loginfo("checking for extraction...");
398 :
399 94 : m_directory = path;
400 94 : m_path = ArchiveExtractor::getUncompressedFilePath(m_directory.string(), EDADATA_FILENAME);
401 :
402 94 : if (!std::filesystem::exists(m_path))
403 : {
404 0 : auto message = "eda/data file does not exist: [" + m_path.string() + "]";
405 0 : throw invalid_odb_error(message.c_str());
406 0 : }
407 94 : else if (!std::filesystem::is_regular_file(m_path))
408 : {
409 0 : auto message = "eda/data is not a file: [" + m_path.string() + "]";
410 0 : throw invalid_odb_error(message.c_str());
411 0 : }
412 :
413 376 : loginfo("any extraction complete, parsing data...");
414 :
415 94 : edaDataFile.open(m_path.string(), std::ios::in);
416 94 : if (!edaDataFile.is_open())
417 : {
418 0 : auto message = "unable to open eda/data file: [" + m_path.string() + "]";
419 0 : throw invalid_odb_error(message.c_str());
420 0 : }
421 :
422 94 : std::shared_ptr<NetRecord> pCurrentNetRecord;
423 94 : std::shared_ptr<NetRecord::SubnetRecord> pCurrentSubnetRecord;
424 :
425 94 : std::shared_ptr<PackageRecord> pCurrentPackageRecord;
426 94 : std::shared_ptr<PackageRecord::PinRecord> pCurrentPinRecord;
427 :
428 94 : std::shared_ptr<PackageRecord::OutlineRecord> pCurrentContourOutlineRecord;
429 94 : std::shared_ptr<ContourPolygon> pCurrentContourPolygon;
430 :
431 94 : FeatureGroupRecord::shared_ptr pCurrentFeatureGroupRecord;
432 :
433 7290886 : while (std::getline(edaDataFile, line))
434 : {
435 : // keep track of line number
436 7290795 : lineNumber++;
437 :
438 : // trim whitespace from beginning and end of line
439 7290795 : Utils::str_trim(line);
440 7290795 : if (!line.empty())
441 : {
442 7290795 : if (m_logAllLineParsing)
443 : {
444 0 : parse_info pi(m_path, line, lineNumber);
445 0 : logdebug(pi.toString("Parsing line..."));
446 0 : }
447 :
448 7290795 : std::stringstream lineStream(line);
449 :
450 14581590 : if (line.find(ATTRIBUTE_NAME_TOKEN) == 0 ||
451 29163180 : line.find(std::string(COMMENT_TOKEN) + ATTRIBUTE_NAME_TOKEN) == 0) // backward compatibility dictates allowing comment character in front of attribute value token
452 : {
453 : // component attribute name line
454 180 : std::string token;
455 : // TODO: continue on failing line parse, to make a less strict/more robust parser (make a flag: enum ParseStrictness { strict, lax })
456 180 : if (!std::getline(lineStream, token, ' '))
457 : {
458 0 : throw_parse_error(m_path, line, token, lineNumber);
459 : }
460 180 : else if (!std::getline(lineStream, token, ' '))
461 : {
462 0 : throw_parse_error(m_path, line, token, lineNumber);
463 : }
464 180 : m_attributeNames.push_back(token);
465 180 : }
466 14581230 : else if (line.find(ATTRIBUTE_VALUE_TOKEN) == 0 ||
467 29162460 : line.find(std::string(COMMENT_TOKEN) + ATTRIBUTE_VALUE_TOKEN) == 0) // backward compatibility dictates allowing comment character in front of attribute value token
468 : {
469 : // component attribute text string values
470 0 : std::string token;
471 0 : if (!std::getline(lineStream, token, ' '))
472 : {
473 0 : throw_parse_error(m_path, line, token, lineNumber);
474 : }
475 0 : else if (!std::getline(lineStream, token, ' '))
476 : {
477 0 : throw_parse_error(m_path, line, token, lineNumber);
478 : }
479 0 : m_attributeTextValues.push_back(token);
480 0 : }
481 7290615 : else if (line.find(COMMENT_TOKEN) == 0)
482 : {
483 : // comment line
484 : // TODO: attribute lines can begin with a comment for backward compatbility
485 : }
486 7182443 : else if (line.find(UNITS_TOKEN) == 0)
487 : {
488 : // units line
489 94 : std::string token;
490 94 : if (!std::getline(lineStream, token, '='))
491 : {
492 0 : throw_parse_error(m_path, line, token, lineNumber);
493 : }
494 94 : else if (!std::getline(lineStream, token, '='))
495 : {
496 0 : throw_parse_error(m_path, line, token, lineNumber);
497 : }
498 94 : m_units = token;
499 94 : }
500 7182349 : else if (line.find(HEADER_RECORD_TOKEN) == 0)
501 : {
502 : // component record line
503 94 : std::string token;
504 :
505 94 : lineStream >> token;
506 94 : if (token != HEADER_RECORD_TOKEN)
507 : {
508 0 : throw_parse_error(m_path, line, token, lineNumber);
509 : }
510 :
511 : // read the rest of the line as the source
512 94 : if (!std::getline(lineStream, m_source))
513 : {
514 0 : throw_parse_error(m_path, line, token, lineNumber);
515 : }
516 :
517 94 : Utils::str_trim(m_source);
518 94 : }
519 7182255 : else if (line.find(LAYER_NAMES_RECORD_TOKEN) == 0)
520 : {
521 : // component record line
522 94 : std::string token;
523 :
524 94 : lineStream >> token;
525 94 : if (token != LAYER_NAMES_RECORD_TOKEN)
526 : {
527 0 : throw_parse_error(m_path, line, token, lineNumber);
528 : }
529 :
530 2036 : while (lineStream >> token)
531 : {
532 1942 : m_layerNames.push_back(token);
533 : }
534 94 : }
535 7182161 : else if (line.find(PropertyRecord::RECORD_TOKEN) == 0)
536 : {
537 : // component property record line
538 10904 : std::string token;
539 10904 : if (!(lineStream >> token))
540 : {
541 0 : throw_parse_error(m_path, line, token, lineNumber);
542 : }
543 :
544 10904 : if (token != PropertyRecord::RECORD_TOKEN)
545 : {
546 0 : throw_parse_error(m_path, line, token, lineNumber);
547 : }
548 :
549 10904 : auto pPropertyRecord = std::make_shared<PropertyRecord>();
550 :
551 10904 : if (!(lineStream >> pPropertyRecord->name))
552 : {
553 0 : throw_parse_error(m_path, line, token, lineNumber);
554 : }
555 :
556 10904 : if (!(lineStream >> token))
557 : {
558 0 : throw_parse_error(m_path, line, token, lineNumber);
559 : }
560 :
561 10904 : if (!token.empty())
562 : {
563 : // handle case where the beginning of the value, after the opening single-quote, is whitespace...
564 10904 : if (token == "'")
565 : {
566 : // eat the single-quote and get the next token, i.e. the actual value (w/ space in front)
567 0 : if (!(lineStream >> token))
568 : {
569 0 : throw_parse_error(m_path, line, token, lineNumber);
570 : }
571 : }
572 :
573 10904 : if (token.size() > 0 && token[0] == '\'')
574 : {
575 : // remove leading quote
576 10904 : token.erase(0, 1);
577 : }
578 :
579 10904 : if (token.size() > 0 && token[token.size() - 1] == '\'')
580 : {
581 : // remove trailing quote
582 10904 : token.erase(token.size() - 1);
583 : }
584 :
585 10904 : Utils::str_trim(token);
586 : }
587 :
588 10904 : pPropertyRecord->value = token;
589 :
590 : double f;
591 10904 : while (lineStream >> f)
592 : {
593 0 : pPropertyRecord->floatValues.push_back(f);
594 : }
595 :
596 10904 : if (pCurrentNetRecord != nullptr)
597 : {
598 0 : pCurrentNetRecord->m_propertyRecords.push_back(pPropertyRecord);
599 : }
600 10904 : else if (pCurrentPackageRecord != nullptr)
601 : {
602 10904 : pCurrentPackageRecord->m_propertyRecords.push_back(pPropertyRecord);
603 : }
604 0 : else if (pCurrentFeatureGroupRecord != nullptr)
605 : {
606 0 : pCurrentFeatureGroupRecord->m_propertyRecords.push_back(pPropertyRecord);
607 : }
608 : else
609 : {
610 : // top-level PRP record
611 0 : m_propertyRecords.push_back(pPropertyRecord);
612 : }
613 10904 : }
614 7171257 : else if (line.find(NET_RECORD_TOKEN) == 0)
615 : {
616 : // net record line
617 61724 : std::string token;
618 :
619 61724 : if (!(lineStream >> token))
620 : {
621 0 : throw_parse_error(m_path, line, token, lineNumber);
622 : }
623 :
624 61724 : if (token != NET_RECORD_TOKEN)
625 : {
626 0 : throw_parse_error(m_path, line, token, lineNumber);
627 : }
628 :
629 : // finish current (previous) net record
630 61724 : if (pCurrentNetRecord != nullptr)
631 : {
632 : // finish up (any) current subnet record
633 61630 : if (pCurrentSubnetRecord != nullptr)
634 : {
635 61630 : pCurrentNetRecord->m_subnetRecords.push_back(pCurrentSubnetRecord);
636 61630 : pCurrentSubnetRecord.reset();
637 : }
638 :
639 61630 : m_netRecords.push_back(pCurrentNetRecord);
640 : //m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
641 61630 : pCurrentNetRecord.reset();
642 : }
643 :
644 : // net name
645 61724 : if (!std::getline(lineStream, token, ';'))
646 : {
647 0 : throw_parse_error(m_path, line, token, lineNumber);
648 : }
649 :
650 : // trim whitespace from beginning
651 61724 : str_trim(token);
652 :
653 : // create new net record
654 61724 : pCurrentNetRecord = std::make_shared<NetRecord>();
655 61724 : pCurrentNetRecord->name = token;
656 61724 : pCurrentNetRecord->index = static_cast<unsigned>(m_netRecords.size());
657 :
658 61724 : std::string attrIdString;
659 61724 : lineStream >> attrIdString;
660 61724 : if (!pCurrentNetRecord->ParseAttributeLookupTable(attrIdString, pCurrentNetRecord->id))
661 : {
662 0 : throw_parse_error(m_path, line, token, lineNumber);
663 : }
664 61724 : }
665 7109533 : else if (line.find(NetRecord::SubnetRecord::RECORD_TOKEN) == 0)
666 : {
667 : // component record line
668 979062 : std::string token;
669 :
670 979062 : lineStream >> token;
671 979062 : if (token != NetRecord::SubnetRecord::RECORD_TOKEN)
672 : {
673 0 : throw_parse_error(m_path, line, token, lineNumber);
674 : }
675 :
676 979062 : if (pCurrentNetRecord != nullptr)
677 : {
678 : // finish current (previous) subnet record
679 979062 : if (pCurrentSubnetRecord != nullptr)
680 : {
681 917338 : pCurrentNetRecord->m_subnetRecords.push_back(pCurrentSubnetRecord);
682 917338 : pCurrentSubnetRecord.reset();
683 : }
684 : }
685 :
686 979062 : pCurrentSubnetRecord = std::make_shared<NetRecord::SubnetRecord>();
687 979062 : pCurrentSubnetRecord->index = static_cast<unsigned>(pCurrentNetRecord->m_subnetRecords.size());
688 :
689 : // subnet type
690 979062 : lineStream >> token;
691 979062 : if (token == NetRecord::SubnetRecord::RECORD_TYPE_VIA_TOKEN)
692 : {
693 573664 : pCurrentSubnetRecord->type = NetRecord::SubnetRecord::Type::Via;
694 : }
695 405398 : else if (token == NetRecord::SubnetRecord::RECORD_TYPE_TRACE_TOKEN)
696 : {
697 138966 : pCurrentSubnetRecord->type = NetRecord::SubnetRecord::Type::Trace;
698 : }
699 266432 : else if (token == NetRecord::SubnetRecord::RECORD_TYPE_PLANE_TOKEN)
700 : {
701 15302 : pCurrentSubnetRecord->type = NetRecord::SubnetRecord::Type::Plane;
702 :
703 : // fill type
704 15302 : lineStream >> token;
705 15302 : if (token == "S")
706 : {
707 15302 : pCurrentSubnetRecord->fillType = NetRecord::SubnetRecord::FillType::Solid;
708 : }
709 0 : else if (token == "O")
710 : {
711 0 : pCurrentSubnetRecord->fillType = NetRecord::SubnetRecord::FillType::Outline;
712 : }
713 : else
714 : {
715 0 : throw_parse_error(m_path, line, token, lineNumber);
716 : }
717 :
718 : // cutout type
719 15302 : lineStream >> token;
720 15302 : if (token == "C")
721 : {
722 15302 : pCurrentSubnetRecord->cutoutType = NetRecord::SubnetRecord::CutoutType::Circle;
723 : }
724 0 : else if (token == "R")
725 : {
726 0 : pCurrentSubnetRecord->cutoutType = NetRecord::SubnetRecord::CutoutType::Rectangle;
727 : }
728 0 : else if (token == "O")
729 : {
730 0 : pCurrentSubnetRecord->cutoutType = NetRecord::SubnetRecord::CutoutType::Octagon;
731 : }
732 0 : else if (token == "E")
733 : {
734 0 : pCurrentSubnetRecord->cutoutType = NetRecord::SubnetRecord::CutoutType::Exact;
735 : }
736 : else
737 : {
738 0 : throw_parse_error(m_path, line, token, lineNumber);
739 : }
740 :
741 : // fill size
742 15302 : lineStream >> pCurrentSubnetRecord->fillSize;
743 : }
744 251130 : else if (token == NetRecord::SubnetRecord::RECORD_TYPE_TOEPRINT_TOKEN)
745 : {
746 251130 : pCurrentSubnetRecord->type = NetRecord::SubnetRecord::Type::Toeprint;
747 :
748 : // side
749 251130 : lineStream >> token;
750 251130 : if (token == "T")
751 : {
752 192166 : pCurrentSubnetRecord->side = BoardSide::Top;
753 : }
754 58964 : else if (token == "B")
755 : {
756 58964 : pCurrentSubnetRecord->side = BoardSide::Bottom;
757 : }
758 : else
759 : {
760 0 : throw_parse_error(m_path, line, token, lineNumber);
761 : }
762 :
763 : // componentNumber
764 251130 : lineStream >> pCurrentSubnetRecord->componentNumber;
765 :
766 : // toeprintNumber
767 251130 : lineStream >> pCurrentSubnetRecord->toeprintNumber;
768 : }
769 : else
770 : {
771 0 : throw_parse_error(m_path, line, token, lineNumber);
772 : }
773 979062 : }
774 6130471 : else if (line.find(FEATURE_ID_RECORD_TOKEN) == 0)
775 : {
776 : // component record line
777 5679642 : std::string token;
778 :
779 5679642 : if (!(lineStream >> token) || token != FEATURE_ID_RECORD_TOKEN)
780 : {
781 0 : throw_parse_error(m_path, line, token, lineNumber);
782 : }
783 :
784 5679642 : auto pFeatureIdRecord = std::make_shared<FeatureIdRecord>();
785 :
786 : // type
787 5679642 : if (!(lineStream >> token))
788 : {
789 0 : throw_parse_error(m_path, line, token, lineNumber);
790 : }
791 :
792 5679642 : if (token == "C")
793 : {
794 4869576 : pFeatureIdRecord->type = FeatureIdRecord::Type::Copper;
795 : }
796 810066 : else if (token == "L")
797 : {
798 357686 : pFeatureIdRecord->type = FeatureIdRecord::Type::Laminate;
799 : }
800 452380 : else if (token == "H")
801 : {
802 452380 : pFeatureIdRecord->type = FeatureIdRecord::Type::Hole;
803 : }
804 : else
805 : {
806 0 : throw_parse_error(m_path, line, token, lineNumber);
807 : }
808 :
809 : // layer number
810 5679642 : if (!(lineStream >> pFeatureIdRecord->layerNumber))
811 : {
812 0 : throw_parse_error(m_path, line, token, lineNumber);
813 : }
814 :
815 : // feature number
816 5679642 : if (!(lineStream >> pFeatureIdRecord->featureNumber))
817 : {
818 0 : throw_parse_error(m_path, line, token, lineNumber);
819 : }
820 :
821 11359284 : if (pCurrentNetRecord != nullptr &&
822 5679642 : pCurrentSubnetRecord != nullptr)
823 : {
824 5679642 : pCurrentSubnetRecord->m_featureIdRecords.push_back(pFeatureIdRecord);
825 : }
826 0 : else if (pCurrentFeatureGroupRecord != nullptr)
827 : {
828 0 : pCurrentFeatureGroupRecord->m_featureIdRecords.push_back(pFeatureIdRecord);
829 : }
830 : else
831 : {
832 0 : throw_parse_error(m_path, line, token, lineNumber);
833 : }
834 5679642 : }
835 450829 : else if (line.find(PACKAGE_RECORD_TOKEN) == 0)
836 : {
837 : // package record line
838 10814 : std::string token;
839 :
840 10814 : if (!(lineStream >> token) || token != PACKAGE_RECORD_TOKEN)
841 : {
842 0 : throw_parse_error(m_path, line, token, lineNumber);
843 : }
844 :
845 : // finish current (previous) net record
846 10814 : if (pCurrentNetRecord != nullptr)
847 : {
848 : // finish up (any) current subnet record
849 94 : if (pCurrentSubnetRecord != nullptr)
850 : {
851 94 : pCurrentNetRecord->m_subnetRecords.push_back(pCurrentSubnetRecord);
852 94 : pCurrentSubnetRecord.reset();
853 : }
854 :
855 94 : m_netRecords.push_back(pCurrentNetRecord);
856 : //m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
857 94 : pCurrentNetRecord.reset();
858 : }
859 10720 : else if (pCurrentPackageRecord != nullptr)
860 : {
861 : // finish up any current (previous) pin records
862 10720 : if (pCurrentPinRecord != nullptr)
863 : {
864 : // check for overflow
865 10662 : if (pCurrentPackageRecord->m_pinRecords.size() > UINT_MAX)
866 : {
867 0 : throw_parse_error(m_path, line, token, lineNumber);
868 : }
869 10662 : pCurrentPinRecord->index = static_cast<unsigned>(pCurrentPackageRecord->m_pinRecords.size());
870 10662 : pCurrentPackageRecord->m_pinRecords.push_back(pCurrentPinRecord);
871 10662 : pCurrentPinRecord.reset();
872 : }
873 :
874 : // finish up any current (previous) package records
875 10720 : m_packageRecords.push_back(pCurrentPackageRecord);
876 : //m_packageRecordsByName[pCurrentPackageRecord->name] = pCurrentPackageRecord;
877 10720 : pCurrentPackageRecord.reset();
878 : }
879 :
880 10814 : pCurrentPackageRecord = std::make_shared<PackageRecord>();
881 10814 : pCurrentPackageRecord->index = static_cast<unsigned int>(m_packageRecords.size());
882 :
883 : // name
884 10814 : if (!(lineStream >> pCurrentPackageRecord->name))
885 : {
886 0 : throw_parse_error(m_path, line, token, lineNumber);
887 : }
888 :
889 : // pitch
890 10814 : if (!(lineStream >> pCurrentPackageRecord->pitch))
891 : {
892 0 : throw_parse_error(m_path, line, token, lineNumber);
893 : }
894 :
895 : // xmin, ymin
896 10814 : if (!(lineStream >> pCurrentPackageRecord->xMin >> pCurrentPackageRecord->yMin))
897 : {
898 0 : throw_parse_error(m_path, line, token, lineNumber);
899 : }
900 :
901 : // xmax
902 10814 : if (!(lineStream >> pCurrentPackageRecord->xMax))
903 : {
904 0 : throw_parse_error(m_path, line, token, lineNumber);
905 : }
906 :
907 : // ymax and attributes/ID string
908 10814 : if (!std::getline(lineStream, token, ';'))
909 : {
910 0 : throw_parse_error(m_path, line, token, lineNumber);
911 : }
912 :
913 : // ymax
914 10814 : pCurrentPackageRecord->yMax = std::stof(token);
915 :
916 10814 : std::string attrIdString;
917 10814 : lineStream >> attrIdString;
918 10814 : if (!pCurrentPackageRecord->ParseAttributeLookupTable(attrIdString, pCurrentPackageRecord->id))
919 : {
920 0 : throw_parse_error(m_path, line, token, lineNumber);
921 : }
922 10814 : }
923 440015 : else if (line.find(PIN_RECORD_TOKEN) == 0)
924 : {
925 : // package pin record line
926 113525 : std::string token;
927 :
928 113525 : if (!(lineStream >> token) || token != PIN_RECORD_TOKEN)
929 : {
930 0 : throw_parse_error(m_path, line, token, lineNumber);
931 : }
932 :
933 113525 : if (pCurrentPackageRecord != nullptr)
934 : {
935 : // finish up any current (previous) pin records
936 113525 : if (pCurrentPinRecord != nullptr)
937 : {
938 : // check for overflow
939 102769 : if (pCurrentPackageRecord->m_pinRecords.size() > UINT_MAX)
940 : {
941 0 : throw_parse_error(m_path, line, token, lineNumber);
942 : }
943 102769 : pCurrentPinRecord->index = static_cast<unsigned>(pCurrentPackageRecord->m_pinRecords.size());
944 102769 : pCurrentPackageRecord->m_pinRecords.push_back(pCurrentPinRecord);
945 102769 : pCurrentPinRecord.reset();
946 : }
947 : }
948 :
949 113525 : pCurrentPinRecord = std::make_shared<PackageRecord::PinRecord>();
950 : //pCurrentPinRecord->index = static_cast<unsigned>(pCurrentPackageRecord->m_pinRecords.size());
951 :
952 : // name
953 113525 : lineStream >> pCurrentPinRecord->name;
954 :
955 : // type
956 113525 : if (!(lineStream >> token))
957 : {
958 0 : throw_parse_error(m_path, line, token, lineNumber);
959 : }
960 :
961 113525 : if (token == "T")
962 : {
963 8395 : pCurrentPinRecord->type = PackageRecord::PinRecord::Type::ThroughHole;
964 : }
965 105130 : else if (token == "B")
966 : {
967 0 : pCurrentPinRecord->type = PackageRecord::PinRecord::Type::Blind;
968 : }
969 105130 : else if (token == "S")
970 : {
971 105128 : pCurrentPinRecord->type = PackageRecord::PinRecord::Type::Surface;
972 : }
973 : else
974 : {
975 4 : logerror("unknown pin type: [" + token + "]");
976 2 : throw_parse_error(m_path, line, token, lineNumber);
977 : }
978 :
979 : // xc, xy
980 113523 : if (!(lineStream >> pCurrentPinRecord->xCenter >> pCurrentPinRecord->yCenter))
981 : {
982 0 : throw_parse_error(m_path, line, token, lineNumber);
983 : }
984 :
985 : // finished hole size (fhs)
986 113523 : if (!(lineStream >> pCurrentPinRecord->finishedHoleSize))
987 : {
988 0 : throw_parse_error(m_path, line, token, lineNumber);
989 : }
990 :
991 : // electrical type
992 113523 : if (!(lineStream >> token))
993 : {
994 0 : throw_parse_error(m_path, line, token, lineNumber);
995 : }
996 :
997 113523 : if (token == "E")
998 : {
999 0 : pCurrentPinRecord->electricalType = PackageRecord::PinRecord::ElectricalType::Electrical;
1000 : }
1001 113523 : else if (token == "M")
1002 : {
1003 0 : pCurrentPinRecord->electricalType = PackageRecord::PinRecord::ElectricalType::NonElectrical;
1004 : }
1005 113523 : else if (token == "U")
1006 : {
1007 113522 : pCurrentPinRecord->electricalType = PackageRecord::PinRecord::ElectricalType::Undefined;
1008 : }
1009 : else
1010 : {
1011 2 : logerror("unknown pin electrical type: [" + token + "]");
1012 1 : throw_parse_error(m_path, line, token, lineNumber);
1013 : }
1014 :
1015 : // mount type
1016 113522 : if (!(lineStream >> token))
1017 : {
1018 0 : throw_parse_error(m_path, line, token, lineNumber);
1019 : }
1020 :
1021 113522 : if (token == "S")
1022 : {
1023 0 : pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::Smt;
1024 : }
1025 113522 : else if (token == "D")
1026 : {
1027 0 : pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::RecommendedSmtPad;
1028 : }
1029 113522 : else if (token == "T")
1030 : {
1031 0 : pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::MT_ThroughHole;
1032 : }
1033 113522 : else if (token == "R")
1034 : {
1035 0 : pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::RecommendedThroughHole;
1036 : }
1037 113522 : else if (token == "P")
1038 : {
1039 0 : pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::Pressfit;
1040 : }
1041 113522 : else if (token == "N")
1042 : {
1043 0 : pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::NonBoard;
1044 : }
1045 113522 : else if (token == "H")
1046 : {
1047 0 : pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::Hole;
1048 : }
1049 113522 : else if (token == "U")
1050 : {
1051 113522 : pCurrentPinRecord->mountType = PackageRecord::PinRecord::MountType::MT_Undefined;
1052 : }
1053 : else
1054 : {
1055 0 : logerror("unknown pin mount type: [" + token + "]");
1056 0 : throw_parse_error(m_path, line, token, lineNumber);
1057 : }
1058 :
1059 : // ID=<id>
1060 : // PIN record, ID field is optional: spec pg.31
1061 113522 : if (lineStream >> token)
1062 : {
1063 113522 : std::stringstream idStream(token);
1064 113522 : if (!std::getline(idStream, token, '=') || token != "ID")
1065 : {
1066 0 : throw_parse_error(m_path, line, token, lineNumber);
1067 : }
1068 :
1069 113522 : idStream >> pCurrentPinRecord->id;
1070 113522 : }
1071 : else
1072 : {
1073 :
1074 : #define SIMULATE_PARSE_ERROR 0
1075 : #if SIMULATE_PARSE_ERROR
1076 : throw_parse_error(m_path, line, token, lineNumber);
1077 : #endif
1078 :
1079 0 : pCurrentPinRecord->id = UINT_MAX;
1080 : }
1081 113525 : }
1082 326490 : else if (line.find(FEATURE_GROUP_RECORD_TOKEN) == 0)
1083 : {
1084 : // feature group record line
1085 0 : std::string token;
1086 :
1087 0 : if (!(lineStream >> token))
1088 : {
1089 0 : throw_parse_error(m_path, line, token, lineNumber);
1090 : }
1091 :
1092 0 : if (token != FEATURE_GROUP_RECORD_TOKEN)
1093 : {
1094 0 : throw_parse_error(m_path, line, token, lineNumber);
1095 : }
1096 :
1097 : // finish current (previous) net record
1098 0 : if (pCurrentNetRecord != nullptr)
1099 : {
1100 : // finish up (any) current subnet record
1101 0 : if (pCurrentSubnetRecord != nullptr)
1102 : {
1103 0 : pCurrentNetRecord->m_subnetRecords.push_back(pCurrentSubnetRecord);
1104 0 : pCurrentSubnetRecord.reset();
1105 : }
1106 :
1107 0 : m_netRecords.push_back(pCurrentNetRecord);
1108 : //m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
1109 0 : pCurrentNetRecord.reset();
1110 : }
1111 0 : else if (pCurrentPackageRecord != nullptr)
1112 : {
1113 : // finish up any current (previous) pin records
1114 0 : if (pCurrentPinRecord != nullptr)
1115 : {
1116 : // check for overflow
1117 0 : if (pCurrentPackageRecord->m_pinRecords.size() > UINT_MAX)
1118 : {
1119 0 : throw_parse_error(m_path, line, token, lineNumber);
1120 : }
1121 0 : pCurrentPinRecord->index = static_cast<unsigned>(pCurrentPackageRecord->m_pinRecords.size());
1122 0 : pCurrentPackageRecord->m_pinRecords.push_back(pCurrentPinRecord);
1123 0 : pCurrentPinRecord.reset();
1124 : }
1125 :
1126 : // finish up any current (previous) package records
1127 0 : m_packageRecords.push_back(pCurrentPackageRecord);
1128 : //m_packageRecordsByName[pCurrentPackageRecord->name] = pCurrentPackageRecord;
1129 0 : pCurrentPackageRecord.reset();
1130 : }
1131 0 : else if (pCurrentFeatureGroupRecord != nullptr)
1132 : {
1133 0 : m_featureGroupRecords.push_back(pCurrentFeatureGroupRecord);
1134 0 : pCurrentFeatureGroupRecord.reset();
1135 : }
1136 :
1137 0 : pCurrentFeatureGroupRecord = std::make_shared<FeatureGroupRecord>();
1138 :
1139 0 : if (!(lineStream >> pCurrentFeatureGroupRecord->type))
1140 : {
1141 0 : throw_parse_error(m_path, line, token, lineNumber);
1142 : }
1143 0 : }
1144 326490 : else if (line.find(PackageRecord::OutlineRecord::RECTANGLE_RECORD_TOKEN) == 0)
1145 : {
1146 55698 : std::string token;
1147 55698 : if (!(lineStream >> token))
1148 : {
1149 0 : throw_parse_error(m_path, line, token, lineNumber);
1150 : }
1151 :
1152 55698 : if (token != PackageRecord::OutlineRecord::RECTANGLE_RECORD_TOKEN)
1153 : {
1154 0 : throw_parse_error(m_path, line, token, lineNumber);
1155 : }
1156 :
1157 55698 : auto pOutlineRecord = std::make_shared<PackageRecord::OutlineRecord>();
1158 55698 : pOutlineRecord->type = PackageRecord::OutlineRecord::Type::Rectangle;
1159 :
1160 55698 : if (!(lineStream >> pOutlineRecord->lowerLeftX))
1161 : {
1162 0 : throw_parse_error(m_path, line, token, lineNumber);
1163 : }
1164 :
1165 55698 : if (!(lineStream >> pOutlineRecord->lowerLeftY))
1166 : {
1167 0 : throw_parse_error(m_path, line, token, lineNumber);
1168 : }
1169 :
1170 55698 : if (!(lineStream >> pOutlineRecord->width))
1171 : {
1172 0 : throw_parse_error(m_path, line, token, lineNumber);
1173 : }
1174 :
1175 55698 : if (!(lineStream >> pOutlineRecord->height))
1176 : {
1177 0 : throw_parse_error(m_path, line, token, lineNumber);
1178 : }
1179 :
1180 55698 : if (pCurrentPackageRecord != nullptr)
1181 : {
1182 55698 : if (pCurrentPinRecord != nullptr)
1183 : {
1184 50926 : pCurrentPinRecord->m_outlineRecords.push_back(pOutlineRecord);
1185 : }
1186 : else
1187 : {
1188 4772 : pCurrentPackageRecord->m_outlineRecords.push_back(pOutlineRecord);
1189 : }
1190 : }
1191 : else
1192 : {
1193 0 : throw_parse_error(m_path, line, token, lineNumber);
1194 : }
1195 55698 : }
1196 270792 : else if (line.find(PackageRecord::OutlineRecord::CIRCLE_RECORD_TOKEN) == 0)
1197 : {
1198 50460 : std::string token;
1199 50460 : if (!(lineStream >> token))
1200 : {
1201 0 : throw_parse_error(m_path, line, token, lineNumber);
1202 : }
1203 :
1204 50460 : if (token != PackageRecord::OutlineRecord::CIRCLE_RECORD_TOKEN)
1205 : {
1206 0 : throw_parse_error(m_path, line, token, lineNumber);
1207 : }
1208 :
1209 50460 : auto pOutlineRecord = std::make_shared<PackageRecord::OutlineRecord>();
1210 50460 : pOutlineRecord->type = PackageRecord::OutlineRecord::Type::Circle;
1211 :
1212 50460 : if (!(lineStream >> pOutlineRecord->xCenter))
1213 : {
1214 0 : throw_parse_error(m_path, line, token, lineNumber);
1215 : }
1216 :
1217 50460 : if (!(lineStream >> pOutlineRecord->yCenter))
1218 : {
1219 0 : throw_parse_error(m_path, line, token, lineNumber);
1220 : }
1221 :
1222 50460 : if (!(lineStream >> pOutlineRecord->radius))
1223 : {
1224 0 : throw_parse_error(m_path, line, token, lineNumber);
1225 : }
1226 :
1227 50460 : if (pCurrentPackageRecord != nullptr)
1228 : {
1229 50460 : if (pCurrentPinRecord != nullptr)
1230 : {
1231 47872 : pCurrentPinRecord->m_outlineRecords.push_back(pOutlineRecord);
1232 : }
1233 : else
1234 : {
1235 2588 : pCurrentPackageRecord->m_outlineRecords.push_back(pOutlineRecord);
1236 : }
1237 : }
1238 : else
1239 : {
1240 0 : throw_parse_error(m_path, line, token, lineNumber);
1241 : }
1242 50460 : }
1243 220332 : else if (line.find(PackageRecord::OutlineRecord::SQUARE_RECORD_TOKEN) == 0)
1244 : {
1245 1080 : std::string token;
1246 1080 : if (!(lineStream >> token))
1247 : {
1248 0 : throw_parse_error(m_path, line, token, lineNumber);
1249 : }
1250 :
1251 1080 : if (token != PackageRecord::OutlineRecord::SQUARE_RECORD_TOKEN)
1252 : {
1253 0 : throw_parse_error(m_path, line, token, lineNumber);
1254 : }
1255 :
1256 1080 : auto pOutlineRecord = std::make_shared<PackageRecord::OutlineRecord>();
1257 1080 : pOutlineRecord->type = PackageRecord::OutlineRecord::Type::Square;
1258 :
1259 1080 : if (!(lineStream >> pOutlineRecord->xCenter))
1260 : {
1261 0 : throw_parse_error(m_path, line, token, lineNumber);
1262 : }
1263 :
1264 1080 : if (!(lineStream >> pOutlineRecord->yCenter))
1265 : {
1266 0 : throw_parse_error(m_path, line, token, lineNumber);
1267 : }
1268 :
1269 1080 : if (!(lineStream >> pOutlineRecord->halfSide))
1270 : {
1271 0 : throw_parse_error(m_path, line, token, lineNumber);
1272 : }
1273 :
1274 1080 : if (pCurrentPackageRecord != nullptr)
1275 : {
1276 1080 : if (pCurrentPinRecord != nullptr)
1277 : {
1278 468 : pCurrentPinRecord->m_outlineRecords.push_back(pOutlineRecord);
1279 : }
1280 : else
1281 : {
1282 612 : pCurrentPackageRecord->m_outlineRecords.push_back(pOutlineRecord);
1283 : }
1284 : }
1285 : else
1286 : {
1287 0 : throw_parse_error(m_path, line, token, lineNumber);
1288 : }
1289 1080 : }
1290 219252 : else if (line.find(PackageRecord::OutlineRecord::CONTOUR_BEGIN_RECORD_TOKEN) == 0)
1291 : {
1292 17098 : std::string token;
1293 17098 : if (!(lineStream >> token))
1294 : {
1295 0 : throw_parse_error(m_path, line, token, lineNumber);
1296 : }
1297 :
1298 17098 : if (token != PackageRecord::OutlineRecord::CONTOUR_BEGIN_RECORD_TOKEN)
1299 : {
1300 0 : throw_parse_error(m_path, line, token, lineNumber);
1301 : }
1302 :
1303 17098 : pCurrentContourOutlineRecord = std::make_shared<PackageRecord::OutlineRecord>();
1304 17098 : pCurrentContourOutlineRecord->type = PackageRecord::OutlineRecord::Type::Contour;
1305 17098 : }
1306 202154 : else if (line.find(PackageRecord::OutlineRecord::CONTOUR_END_RECORD_TOKEN) == 0)
1307 : {
1308 17098 : std::string token;
1309 17098 : if (!(lineStream >> token))
1310 : {
1311 0 : throw_parse_error(m_path, line, token, lineNumber);
1312 : }
1313 :
1314 17098 : if (token != PackageRecord::OutlineRecord::CONTOUR_END_RECORD_TOKEN)
1315 : {
1316 0 : throw_parse_error(m_path, line, token, lineNumber);
1317 : }
1318 :
1319 17098 : if (pCurrentPackageRecord != nullptr)
1320 : {
1321 17098 : if (pCurrentPinRecord != nullptr)
1322 : {
1323 14256 : pCurrentPinRecord->m_outlineRecords.push_back(pCurrentContourOutlineRecord);
1324 : }
1325 : else
1326 : {
1327 2842 : pCurrentPackageRecord->m_outlineRecords.push_back(pCurrentContourOutlineRecord);
1328 : }
1329 : }
1330 : else
1331 : {
1332 0 : throw_parse_error(m_path, line, token, lineNumber);
1333 : }
1334 :
1335 17098 : pCurrentContourOutlineRecord.reset();
1336 17098 : }
1337 185056 : else if (line.find(ContourPolygon::BEGIN_RECORD_TOKEN) == 0)
1338 : {
1339 17098 : std::string token;
1340 17098 : if (!(lineStream >> token))
1341 : {
1342 0 : throw_parse_error(m_path, line, token, lineNumber);
1343 : }
1344 :
1345 17098 : if (token != ContourPolygon::BEGIN_RECORD_TOKEN)
1346 : {
1347 0 : throw_parse_error(m_path, line, token, lineNumber);
1348 : }
1349 :
1350 17098 : pCurrentContourPolygon = std::make_shared<ContourPolygon>();
1351 :
1352 17098 : if (!(lineStream >> pCurrentContourPolygon->xStart))
1353 : {
1354 0 : throw_parse_error(m_path, line, token, lineNumber);
1355 : }
1356 :
1357 17098 : if (!(lineStream >> pCurrentContourPolygon->yStart))
1358 : {
1359 0 : throw_parse_error(m_path, line, token, lineNumber);
1360 : }
1361 :
1362 17098 : if (!(lineStream >> token))
1363 : {
1364 0 : throw_parse_error(m_path, line, token, lineNumber);
1365 : }
1366 :
1367 17098 : if (token == ContourPolygon::ISLAND_TYPE_TOKEN)
1368 : {
1369 17098 : pCurrentContourPolygon->type = ContourPolygon::Type::Island;
1370 : }
1371 0 : else if (token == ContourPolygon::HOLE_TYPE_TOKEN)
1372 : {
1373 0 : pCurrentContourPolygon->type = ContourPolygon::Type::Hole;
1374 : }
1375 : else
1376 : {
1377 0 : throw_parse_error(m_path, line, token, lineNumber);
1378 : }
1379 17098 : }
1380 167958 : else if (line.find(ContourPolygon::END_RECORD_TOKEN) == 0)
1381 : {
1382 17098 : std::string token;
1383 17098 : if (!(lineStream >> token))
1384 : {
1385 0 : throw_parse_error(m_path, line, token, lineNumber);
1386 : }
1387 :
1388 17098 : if (token != ContourPolygon::END_RECORD_TOKEN)
1389 : {
1390 0 : throw_parse_error(m_path, line, token, lineNumber);
1391 : }
1392 :
1393 17098 : if (pCurrentContourOutlineRecord != nullptr)
1394 : {
1395 17098 : pCurrentContourOutlineRecord->m_contourPolygons.push_back(pCurrentContourPolygon);
1396 17098 : pCurrentContourPolygon.reset();
1397 : }
1398 : else
1399 : {
1400 0 : throw_parse_error(m_path, line, token, lineNumber);
1401 : }
1402 17098 : }
1403 150860 : else if (line.find(ContourPolygon::PolygonPart::ARC_RECORD_TOKEN) == 0)
1404 : {
1405 59028 : std::string token;
1406 59028 : if (!(lineStream >> token))
1407 : {
1408 0 : throw_parse_error(m_path, line, token, lineNumber);
1409 : }
1410 :
1411 59028 : if (token != ContourPolygon::PolygonPart::ARC_RECORD_TOKEN)
1412 : {
1413 0 : throw_parse_error(m_path, line, token, lineNumber);
1414 : }
1415 :
1416 59028 : auto pPolygonPart = std::make_shared<ContourPolygon::PolygonPart>();
1417 59028 : pPolygonPart->type = ContourPolygon::PolygonPart::Type::Arc;
1418 :
1419 59028 : if (!(lineStream >> pPolygonPart->endX))
1420 : {
1421 0 : throw_parse_error(m_path, line, token, lineNumber);
1422 : }
1423 :
1424 59028 : if (!(lineStream >> pPolygonPart->endY))
1425 : {
1426 0 : throw_parse_error(m_path, line, token, lineNumber);
1427 : }
1428 :
1429 59028 : if (!(lineStream >> pPolygonPart->xCenter))
1430 : {
1431 0 : throw_parse_error(m_path, line, token, lineNumber);
1432 : }
1433 :
1434 59028 : if (!(lineStream >> pPolygonPart->yCenter))
1435 : {
1436 0 : throw_parse_error(m_path, line, token, lineNumber);
1437 : }
1438 :
1439 59028 : if (!(lineStream >> token))
1440 : {
1441 0 : throw_parse_error(m_path, line, token, lineNumber);
1442 : }
1443 :
1444 59028 : if (token == "y" || token == "Y")
1445 : {
1446 58776 : pPolygonPart->isClockwise = true;
1447 : }
1448 252 : else if (token == "n" || token == "N")
1449 : {
1450 252 : pPolygonPart->isClockwise = false;
1451 : }
1452 : else
1453 : {
1454 0 : throw_parse_error(m_path, line, token, lineNumber);
1455 : }
1456 :
1457 59028 : if (pCurrentContourPolygon != nullptr)
1458 : {
1459 59028 : pCurrentContourPolygon->m_polygonParts.push_back(pPolygonPart);
1460 : }
1461 : else
1462 : {
1463 0 : throw_parse_error(m_path, line, token, lineNumber);
1464 : }
1465 59028 : }
1466 91832 : else if (line.find(ContourPolygon::PolygonPart::SEGMENT_RECORD_TOKEN) == 0)
1467 : {
1468 91832 : std::string token;
1469 91832 : if (!(lineStream >> token))
1470 : {
1471 0 : throw_parse_error(m_path, line, token, lineNumber);
1472 : }
1473 :
1474 91832 : if (token != ContourPolygon::PolygonPart::SEGMENT_RECORD_TOKEN)
1475 : {
1476 0 : throw_parse_error(m_path, line, token, lineNumber);
1477 : }
1478 :
1479 91832 : auto pPolygonPart = std::make_shared<ContourPolygon::PolygonPart>();
1480 91832 : pPolygonPart->type = ContourPolygon::PolygonPart::Type::Segment;
1481 :
1482 91832 : if (!(lineStream >> pPolygonPart->endX))
1483 : {
1484 0 : throw_parse_error(m_path, line, token, lineNumber);
1485 : }
1486 :
1487 91832 : if (!(lineStream >> pPolygonPart->endY))
1488 : {
1489 0 : throw_parse_error(m_path, line, token, lineNumber);
1490 : }
1491 :
1492 91832 : if (pCurrentContourPolygon != nullptr)
1493 : {
1494 91832 : pCurrentContourPolygon->m_polygonParts.push_back(pPolygonPart);
1495 : }
1496 : else
1497 : {
1498 0 : throw_parse_error(m_path, line, token, lineNumber);
1499 : }
1500 91832 : }
1501 : else
1502 : {
1503 : // unrecognized record line
1504 0 : parse_info pi(m_path, line, lineNumber);
1505 0 : logwarn(pi.toString("unrecognized record line in EDADATA file:"));
1506 0 : }
1507 7290795 : }
1508 : else
1509 : {
1510 : // empty line
1511 0 : continue;
1512 : }
1513 : }
1514 :
1515 : // finish current (previous) net record
1516 : // this is the case where the last line of the file is not a net record (and there are no PKG records)
1517 91 : if (pCurrentNetRecord != nullptr)
1518 : {
1519 : // finish current (previous) subnet record
1520 : // case where we reach the end of the file before a new net record is encountered (and there are no PKG records)
1521 0 : if (pCurrentSubnetRecord != nullptr)
1522 : {
1523 0 : pCurrentNetRecord->m_subnetRecords.push_back(pCurrentSubnetRecord);
1524 0 : pCurrentSubnetRecord.reset();
1525 : }
1526 :
1527 0 : m_netRecords.push_back(pCurrentNetRecord);
1528 : //m_netRecordsByName[pCurrentNetRecord->name] = pCurrentNetRecord;
1529 0 : pCurrentNetRecord.reset();
1530 : }
1531 91 : else if (pCurrentPackageRecord != nullptr)
1532 : {
1533 : // finish up any current (previous) pin records
1534 91 : if (pCurrentPinRecord != nullptr)
1535 : {
1536 : // check for overflow
1537 91 : if (pCurrentPackageRecord->m_pinRecords.size() > UINT_MAX)
1538 : {
1539 0 : throw_parse_error(m_path, line, "", lineNumber);
1540 : }
1541 91 : pCurrentPinRecord->index = static_cast<unsigned>(pCurrentPackageRecord->m_pinRecords.size());
1542 91 : pCurrentPackageRecord->m_pinRecords.push_back(pCurrentPinRecord);
1543 91 : pCurrentPinRecord.reset();
1544 : }
1545 :
1546 : // finish up any current (previous) package records
1547 91 : m_packageRecords.push_back(pCurrentPackageRecord);
1548 : //m_packageRecordsByName[pCurrentPackageRecord->name] = pCurrentPackageRecord;
1549 91 : pCurrentPackageRecord.reset();
1550 : }
1551 0 : else if (pCurrentFeatureGroupRecord != nullptr)
1552 : {
1553 0 : m_featureGroupRecords.push_back(pCurrentFeatureGroupRecord);
1554 0 : pCurrentFeatureGroupRecord.reset();
1555 : }
1556 :
1557 91 : edaDataFile.close();
1558 112 : }
1559 3 : catch (parse_error& pe)
1560 : {
1561 3 : auto m = pe.toString("Parse Error:");
1562 6 : logerror(m);
1563 : // cleanup file
1564 3 : edaDataFile.close();
1565 3 : throw pe;
1566 6 : }
1567 0 : catch (std::exception& e)
1568 : {
1569 0 : parse_info pi(m_path, line, lineNumber);
1570 0 : const auto m = pi.toString();
1571 0 : logexception_msg(e, m);
1572 : // cleanup file
1573 0 : edaDataFile.close();
1574 0 : throw e;
1575 0 : }
1576 :
1577 91 : return true;
1578 97 : }
1579 :
1580 : // Inherited via IProtoBuffable
1581 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord>
1582 8533 : EdaDataFile::PackageRecord::to_protobuf() const
1583 : {
1584 8533 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord> pPackageRecordMessage(new Odb::Lib::Protobuf::EdaDataFile::PackageRecord);
1585 17066 : pPackageRecordMessage->set_name(Odb::Lib::Text::ToUtf8(name));
1586 8533 : pPackageRecordMessage->set_pitch(pitch);
1587 8533 : pPackageRecordMessage->set_xmin(xMin);
1588 8533 : pPackageRecordMessage->set_ymin(yMin);
1589 8533 : pPackageRecordMessage->set_xmax(xMax);
1590 8533 : pPackageRecordMessage->set_ymax(yMax);
1591 8533 : if (id.has_value())
1592 : {
1593 2 : pPackageRecordMessage->set_id(*id);
1594 : }
1595 : //pPackageRecordMessage->set_attributesidstring(attributesIdString);
1596 109602 : for (const auto& pinRecord : m_pinRecords)
1597 : {
1598 101069 : auto pPinRecordMessage = pPackageRecordMessage->add_pinrecords();
1599 101069 : pPinRecordMessage->CopyFrom(*pinRecord->to_protobuf());
1600 : }
1601 8533 : for (const auto& kvPinRecord : m_pinRecordsByName)
1602 : {
1603 0 : (*pPackageRecordMessage->mutable_pinrecordsbyname())[Odb::Lib::Text::ToUtf8(kvPinRecord.first)] = *kvPinRecord.second->to_protobuf();
1604 : }
1605 22257 : for (const auto& propertyRecord : m_propertyRecords)
1606 : {
1607 13724 : auto pPropertyRecordMessage = pPackageRecordMessage->add_propertyrecords();
1608 13724 : pPropertyRecordMessage->CopyFrom(*propertyRecord->to_protobuf());
1609 : }
1610 17064 : for (const auto& outlineRecord : m_outlineRecords)
1611 : {
1612 8531 : auto pOutlineRecordMessage = pPackageRecordMessage->add_outlinerecords();
1613 8531 : pOutlineRecordMessage->CopyFrom(*outlineRecord->to_protobuf());
1614 : }
1615 17064 : for (const auto& kvAttributeAssignment : m_attributeLookupTable)
1616 : {
1617 8531 : (*pPackageRecordMessage->mutable_attributelookuptable())[Odb::Lib::Text::ToUtf8(kvAttributeAssignment.first)] = Odb::Lib::Text::ToUtf8(kvAttributeAssignment.second);
1618 : }
1619 8533 : return pPackageRecordMessage;
1620 0 : }
1621 :
1622 587 : void EdaDataFile::PackageRecord::from_protobuf(const Odb::Lib::Protobuf::EdaDataFile::PackageRecord& message)
1623 : {
1624 587 : name = message.name();
1625 587 : pitch = message.pitch();
1626 587 : xMin = message.xmin();
1627 587 : yMin = message.ymin();
1628 587 : xMax = message.xmax();
1629 587 : yMax = message.ymax();
1630 587 : if (message.has_id())
1631 : {
1632 2 : id = message.id();
1633 : }
1634 : //attributesIdString = message.attributesidstring();
1635 :
1636 6670 : for (const auto& pinRecordMessage : message.pinrecords())
1637 : {
1638 6083 : auto pPinRecord = std::make_shared<PinRecord>();
1639 6083 : pPinRecord->from_protobuf(pinRecordMessage);
1640 6083 : m_pinRecords.push_back(pPinRecord);
1641 6083 : }
1642 :
1643 587 : for (const auto& kvPinRecordMessage : message.pinrecordsbyname())
1644 : {
1645 0 : auto pPinRecord = std::make_shared<PinRecord>();
1646 0 : pPinRecord->from_protobuf(kvPinRecordMessage.second);
1647 0 : m_pinRecordsByName[kvPinRecordMessage.first] = pPinRecord;
1648 0 : }
1649 :
1650 1151 : for (const auto& propertyRecordMessage : message.propertyrecords())
1651 : {
1652 564 : auto pPropertyRecord = std::make_shared<PropertyRecord>();
1653 564 : pPropertyRecord->from_protobuf(propertyRecordMessage);
1654 564 : m_propertyRecords.push_back(pPropertyRecord);
1655 564 : }
1656 :
1657 1172 : for (const auto& outlineRecordMessage : message.outlinerecords())
1658 : {
1659 585 : auto pOutlineRecord = std::make_shared<OutlineRecord>();
1660 585 : pOutlineRecord->from_protobuf(outlineRecordMessage);
1661 585 : m_outlineRecords.push_back(pOutlineRecord);
1662 585 : }
1663 :
1664 1757 : for (const auto& kvAttributeAssignment : message.attributelookuptable())
1665 : {
1666 585 : m_attributeLookupTable[kvAttributeAssignment.first] = kvAttributeAssignment.second;
1667 : }
1668 587 : }
1669 :
1670 : // Inherited via IProtoBuffable
1671 8531 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord::OutlineRecord> EdaDataFile::PackageRecord::OutlineRecord::to_protobuf() const
1672 : {
1673 8531 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord::OutlineRecord> pOutlineRecordMessage(new Odb::Lib::Protobuf::EdaDataFile::PackageRecord::OutlineRecord);
1674 8531 : pOutlineRecordMessage->set_type((Odb::Lib::Protobuf::EdaDataFile::PackageRecord::OutlineRecord::Type)type);
1675 8531 : pOutlineRecordMessage->set_lowerleftx(lowerLeftX);
1676 8531 : pOutlineRecordMessage->set_lowerlefty(lowerLeftY);
1677 8531 : pOutlineRecordMessage->set_width(width);
1678 8531 : pOutlineRecordMessage->set_height(height);
1679 8531 : pOutlineRecordMessage->set_xcenter(xCenter);
1680 8531 : pOutlineRecordMessage->set_ycenter(yCenter);
1681 8531 : pOutlineRecordMessage->set_radius(radius);
1682 8531 : pOutlineRecordMessage->set_halfside(halfSide);
1683 11316 : for (const auto& contourPolygon : m_contourPolygons)
1684 : {
1685 2785 : auto pContourPolygonMessage = pOutlineRecordMessage->add_contourpolygons();
1686 2785 : pContourPolygonMessage->CopyFrom(*contourPolygon->to_protobuf());
1687 : }
1688 8531 : return pOutlineRecordMessage;
1689 0 : }
1690 :
1691 585 : void EdaDataFile::PackageRecord::OutlineRecord::from_protobuf(const Odb::Lib::Protobuf::EdaDataFile::PackageRecord::OutlineRecord& message)
1692 : {
1693 585 : type = (Type)message.type();
1694 585 : lowerLeftX = message.lowerleftx();
1695 585 : lowerLeftY = message.lowerlefty();
1696 585 : width = message.width();
1697 585 : height = message.height();
1698 585 : xCenter = message.xcenter();
1699 585 : yCenter = message.ycenter();
1700 585 : radius = message.radius();
1701 585 : halfSide = message.halfside();
1702 736 : for (const auto& contourPolygonMessage : message.contourpolygons())
1703 : {
1704 151 : auto pContourPolygon = std::make_shared<ContourPolygon>();
1705 151 : pContourPolygon->from_protobuf(contourPolygonMessage);
1706 151 : m_contourPolygons.push_back(pContourPolygon);
1707 151 : }
1708 585 : }
1709 :
1710 : // Inherited via IProtoBuffable
1711 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord>
1712 101069 : EdaDataFile::PackageRecord::PinRecord::to_protobuf() const
1713 : {
1714 101069 : std::unique_ptr<Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord> pPinRecordMessage(new Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord);
1715 202138 : pPinRecordMessage->set_name(Odb::Lib::Text::ToUtf8(name));
1716 101069 : pPinRecordMessage->set_type((Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord::Type)type);
1717 101069 : pPinRecordMessage->set_xcenter(xCenter);
1718 101069 : pPinRecordMessage->set_ycenter(yCenter);
1719 101069 : pPinRecordMessage->set_finishedholesize(finishedHoleSize);
1720 101069 : pPinRecordMessage->set_electricaltype((Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord::ElectricalType)electricalType);
1721 101069 : pPinRecordMessage->set_mounttype((Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord::MountType)mountType);
1722 101069 : pPinRecordMessage->set_id(id);
1723 101069 : pPinRecordMessage->set_index(index);
1724 101069 : return pPinRecordMessage;
1725 0 : }
1726 :
1727 6083 : void EdaDataFile::PackageRecord::PinRecord::from_protobuf(const Odb::Lib::Protobuf::EdaDataFile::PackageRecord::PinRecord& message)
1728 : {
1729 6083 : name = message.name();
1730 6083 : type = (Type)message.type();
1731 6083 : xCenter = message.xcenter();
1732 6083 : yCenter = message.ycenter();
1733 6083 : finishedHoleSize = message.finishedholesize();
1734 6083 : electricalType = (ElectricalType)message.electricaltype();
1735 6083 : mountType = (MountType)message.mounttype();
1736 6083 : id = message.id();
1737 6083 : index = message.index();
1738 6083 : }
1739 : }
|