| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,144 @@ |
| 1 |
+/* |
|
| 2 |
+ * Author: Pawel Jablonski |
|
| 3 |
+ * E-mail: pj@xirx.net |
|
| 4 |
+ * WWW: xirx.net |
|
| 5 |
+ * GIT: git.xirx.net |
|
| 6 |
+ * |
|
| 7 |
+ * License: You can use this code however you like |
|
| 8 |
+ * but leave information about the original author. |
|
| 9 |
+ * Code is free for non-commercial and commercial use. |
|
| 10 |
+ */ |
|
| 11 |
+ |
|
| 12 |
+#include "data.h" |
|
| 13 |
+ |
|
| 14 |
+/** |
|
| 15 |
+ * Constructor for creating a data |
|
| 16 |
+ * |
|
| 17 |
+ * @param fileName Name of the source file |
|
| 18 |
+ */ |
|
| 19 |
+Data::Data(const QString &fileName) |
|
| 20 |
+{
|
|
| 21 |
+ this->fileName = fileName; |
|
| 22 |
+} |
|
| 23 |
+ |
|
| 24 |
+/** |
|
| 25 |
+ * Get the source file name |
|
| 26 |
+ * |
|
| 27 |
+ * @return Source file name |
|
| 28 |
+ */ |
|
| 29 |
+const QString &Data::getFileName() const |
|
| 30 |
+{
|
|
| 31 |
+ return(this->fileName); |
|
| 32 |
+} |
|
| 33 |
+ |
|
| 34 |
+/** |
|
| 35 |
+ * Add a code section to the data |
|
| 36 |
+ * |
|
| 37 |
+ * @param codeSection Code section |
|
| 38 |
+ * |
|
| 39 |
+ * @return Status of adding the item |
|
| 40 |
+ */ |
|
| 41 |
+bool Data::addCodeSection(const QSharedPointer<CodeSection> &codeSection) |
|
| 42 |
+{
|
|
| 43 |
+ for(const QSharedPointer<CodeSection> &codeSectionFor : this->codeSectionList) |
|
| 44 |
+ {
|
|
| 45 |
+ if(!codeSectionFor->getName().compare(codeSection->getName(), Qt::CaseInsensitive)) |
|
| 46 |
+ {
|
|
| 47 |
+ return(false); |
|
| 48 |
+ } |
|
| 49 |
+ } |
|
| 50 |
+ |
|
| 51 |
+ this->codeSectionList.append(codeSection); |
|
| 52 |
+ |
|
| 53 |
+ return(true); |
|
| 54 |
+} |
|
| 55 |
+ |
|
| 56 |
+/** |
|
| 57 |
+ * Add a RAM item to the data |
|
| 58 |
+ * |
|
| 59 |
+ * @param ramItem RAM item |
|
| 60 |
+ * |
|
| 61 |
+ * @return Status of adding the item |
|
| 62 |
+ */ |
|
| 63 |
+bool Data::addRamItem(const QSharedPointer<RamItem> &ramItem) |
|
| 64 |
+{
|
|
| 65 |
+ for(const QSharedPointer<RamItem> &ramItemFor : this->ramItemList) |
|
| 66 |
+ {
|
|
| 67 |
+ if(!ramItemFor->getName().compare(ramItem->getName(), Qt::CaseInsensitive)) |
|
| 68 |
+ {
|
|
| 69 |
+ return(false); |
|
| 70 |
+ } |
|
| 71 |
+ } |
|
| 72 |
+ |
|
| 73 |
+ for(const QSharedPointer<FlashItem> &flashItemFor : this->flashItemList) |
|
| 74 |
+ {
|
|
| 75 |
+ if(!flashItemFor->getName().compare(ramItem->getName(), Qt::CaseInsensitive)) |
|
| 76 |
+ {
|
|
| 77 |
+ return(false); |
|
| 78 |
+ } |
|
| 79 |
+ } |
|
| 80 |
+ |
|
| 81 |
+ this->ramItemList.append(ramItem); |
|
| 82 |
+ |
|
| 83 |
+ return(true); |
|
| 84 |
+} |
|
| 85 |
+ |
|
| 86 |
+/** |
|
| 87 |
+ * Add a Flash item to the data |
|
| 88 |
+ * |
|
| 89 |
+ * @param flashItem Flash item |
|
| 90 |
+ * |
|
| 91 |
+ * @return Status of adding the item |
|
| 92 |
+ */ |
|
| 93 |
+bool Data::addFlashItem(const QSharedPointer<FlashItem> &flashItem) |
|
| 94 |
+{
|
|
| 95 |
+ for(const QSharedPointer<FlashItem> &flashItemFor : this->flashItemList) |
|
| 96 |
+ {
|
|
| 97 |
+ if(!flashItemFor->getName().compare(flashItem->getName(), Qt::CaseInsensitive)) |
|
| 98 |
+ {
|
|
| 99 |
+ return(false); |
|
| 100 |
+ } |
|
| 101 |
+ } |
|
| 102 |
+ |
|
| 103 |
+ for(const QSharedPointer<RamItem> &ramItemFor : this->ramItemList) |
|
| 104 |
+ {
|
|
| 105 |
+ if(!ramItemFor->getName().compare(flashItem->getName(), Qt::CaseInsensitive)) |
|
| 106 |
+ {
|
|
| 107 |
+ return(false); |
|
| 108 |
+ } |
|
| 109 |
+ } |
|
| 110 |
+ |
|
| 111 |
+ this->flashItemList.append(flashItem); |
|
| 112 |
+ |
|
| 113 |
+ return(true); |
|
| 114 |
+} |
|
| 115 |
+ |
|
| 116 |
+/** |
|
| 117 |
+ * Get the code section list |
|
| 118 |
+ * |
|
| 119 |
+ * @return Code section list |
|
| 120 |
+ */ |
|
| 121 |
+QList<QSharedPointer<CodeSection>> &Data::getCodeSectionList() |
|
| 122 |
+{
|
|
| 123 |
+ return(this->codeSectionList); |
|
| 124 |
+} |
|
| 125 |
+ |
|
| 126 |
+/** |
|
| 127 |
+ * Get the RAM item list |
|
| 128 |
+ * |
|
| 129 |
+ * @return RAM item list |
|
| 130 |
+ */ |
|
| 131 |
+QList<QSharedPointer<RamItem>> &Data::getRamItemList() |
|
| 132 |
+{
|
|
| 133 |
+ return(this->ramItemList); |
|
| 134 |
+} |
|
| 135 |
+ |
|
| 136 |
+/** |
|
| 137 |
+ * Get the Flash item list |
|
| 138 |
+ * |
|
| 139 |
+ * @return Flash item list |
|
| 140 |
+ */ |
|
| 141 |
+QList<QSharedPointer<FlashItem>> &Data::getFlashItemList() |
|
| 142 |
+{
|
|
| 143 |
+ return(this->flashItemList); |
|
| 144 |
+} |