UEFITool/common/treeitem.h

117 lines
4.6 KiB
C
Raw Permalink Normal View History

2013-10-08 15:07:03 +08:00
/* treeitem.h
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
2013-10-08 15:07:03 +08:00
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
2013-10-08 15:07:03 +08:00
*/
#ifndef TREEITEM_H
#define TREEITEM_H
2013-10-08 15:07:03 +08:00
#include <list>
2016-07-16 14:59:29 +08:00
#include <iterator>
2013-10-08 15:07:03 +08:00
#include "basetypes.h"
#include "ubytearray.h"
#include "ustring.h"
2013-10-08 15:07:03 +08:00
class TreeItem
{
public:
2016-10-28 00:31:15 +08:00
TreeItem(const UINT32 offset, const UINT8 type, const UINT8 subtype, const UString &name, const UString &text, const UString &info,
const UByteArray & header, const UByteArray & body, const UByteArray & tail,
2016-10-28 00:31:15 +08:00
const bool fixed, const bool compressed,
TreeItem *parent = 0);
~TreeItem(); // Non-trivial implementation in CPP file
2013-10-08 15:07:03 +08:00
// Operations with items
void appendChild(TreeItem *item) { childItems.push_back(item); }
void prependChild(TreeItem *item) { childItems.push_front(item); };
UINT8 insertChildBefore(TreeItem *item, TreeItem *newItem); // Non-trivial implementation in CPP file
UINT8 insertChildAfter(TreeItem *item, TreeItem *newItem); // Non-trivial implementation in CPP file
// Model support operations
2016-07-16 15:08:41 +08:00
TreeItem *child(int row); // Non-trivial implementation in CPP file
int childCount() const {return (int)childItems.size(); }
int columnCount() const { return 5; }
UString data(int column) const; // Non-trivial implementation in CPP file
int row() const; // Non-trivial implementation in CPP file
TreeItem *parent() { return parentItem; }
2013-10-08 15:07:03 +08:00
2016-07-16 15:08:41 +08:00
// Getters and setters for item parameters
2019-01-07 21:05:57 +08:00
UINT32 offset() const { return itemOffset; }
2016-10-28 00:31:15 +08:00
void setOffset(const UINT32 offset) { itemOffset = offset; }
UINT8 type() const { return itemType; }
void setType(const UINT8 type) { itemType = type; }
UINT8 subtype() const { return itemSubtype; }
void setSubtype(const UINT8 subtype) { itemSubtype = subtype; }
2016-10-28 00:31:15 +08:00
UString name() const { return itemName; }
void setName(const UString &text) { itemName = text; }
UString text() const { return itemText; }
void setText(const UString &text) { itemText = text; }
UByteArray header() const { return itemHeader; }
bool hasEmptyHeader() const { return itemHeader.isEmpty(); }
UByteArray body() const { return itemBody; };
bool hasEmptyBody() const { return itemBody.isEmpty(); }
UByteArray tail() const { return itemTail; };
bool hasEmptyTail() const { return itemTail.isEmpty(); }
UString info() const { return itemInfo; }
void addInfo(const UString &info, const bool append) { if (append) itemInfo += info; else itemInfo = info + itemInfo; }
void setInfo(const UString &info) { itemInfo = info; }
UINT8 action() const {return itemAction; }
void setAction(const UINT8 action) { itemAction = action; }
bool fixed() const { return itemFixed; }
void setFixed(const bool fixed) { itemFixed = fixed; }
bool compressed() const { return itemCompressed; }
void setCompressed(const bool compressed) { itemCompressed = compressed; }
2013-10-08 15:07:03 +08:00
2016-10-28 00:31:15 +08:00
UByteArray parsingData() const { return itemParsingData; };
bool hasEmptyParsingData() const { return itemParsingData.isEmpty(); }
void setParsingData(const UByteArray & pdata) { itemParsingData = pdata; }
UByteArray uncompressedData() const { return itemUncompressedData; };
bool hasEmptyUncompressedData() const { return itemUncompressedData.isEmpty(); }
void setUncompressedData(const UByteArray & ucdata) { itemUncompressedData = ucdata; }
UINT8 marking() const { return itemMarking; }
void setMarking(const UINT8 marking) { itemMarking = marking; }
private:
std::list<TreeItem*> childItems;
2016-10-28 00:31:15 +08:00
UINT32 itemOffset;
UINT8 itemAction;
UINT8 itemType;
UINT8 itemSubtype;
UINT8 itemMarking;
UString itemName;
UString itemText;
UString itemInfo;
UByteArray itemHeader;
UByteArray itemBody;
UByteArray itemTail;
bool itemFixed;
bool itemCompressed;
2016-10-28 00:31:15 +08:00
UByteArray itemParsingData;
UByteArray itemUncompressedData;
TreeItem* parentItem;
2013-10-08 15:07:03 +08:00
};
#endif // TREEITEM_H