forked from ossimlabs/ossim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
3,656 additions
and
1,612 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#ifndef ossimKwlNode_HEADER | ||
#define ossimKwlNode_HEADER | ||
#include <ossim/base/ossimString.h> | ||
#include <ossim/base/ossimKeywordlist.h> | ||
#include <map> | ||
#include <memory> | ||
namespace ossim | ||
{ | ||
class KwlNode | ||
{ | ||
public: | ||
typedef std::map<ossimString, std::shared_ptr<KwlNode> > ChildMap; | ||
|
||
KwlNode(const ossimString &key = ossimString(), | ||
const ossimString &value = ossimString()) | ||
: m_key(key), | ||
m_value(value), | ||
m_isArray(false) | ||
{ | ||
} | ||
|
||
void setKey(const ossimString &key) | ||
{ | ||
m_key = key; | ||
} | ||
void setValue(const ossimString &value) | ||
{ | ||
m_value = value; | ||
} | ||
void setArrayFlag(bool flag) | ||
{ | ||
m_isArray = flag; | ||
} | ||
const ossimString getKey() const | ||
{ | ||
return m_key; | ||
} | ||
const ossimString getValue() const | ||
{ | ||
return m_value; | ||
} | ||
|
||
const ChildMap &getChildren() const | ||
{ | ||
return m_children; | ||
} | ||
ChildMap &getChildren() | ||
{ | ||
return m_children; | ||
} | ||
const ChildMap &getAttributes() const | ||
{ | ||
return m_attributes; | ||
} | ||
ChildMap &getAttributes() | ||
{ | ||
return m_attributes; | ||
} | ||
bool hasChildren() const | ||
{ | ||
return !m_children.empty(); | ||
} | ||
bool hasAttributes() const | ||
{ | ||
return !m_attributes.empty(); | ||
} | ||
bool getIsArray() const | ||
{ | ||
return m_isArray; | ||
} | ||
std::shared_ptr<KwlNode> findChild(const ossimString &key) | ||
{ | ||
return findChild(m_children, key); | ||
} | ||
std::shared_ptr<const KwlNode> findChild(const ossimString &key) const | ||
{ | ||
return findChild(m_children, key); | ||
} | ||
|
||
std::shared_ptr<KwlNode> findAttribute(const ossimString &key) | ||
{ | ||
return findChild(m_attributes, key); | ||
} | ||
|
||
std::shared_ptr<const KwlNode> findAttribute(const ossimString &key) const | ||
{ | ||
return findChild(m_attributes, key); | ||
} | ||
static std::shared_ptr<KwlNode> createTree(const ossimKeywordlist &kwl, | ||
const ossimString &rootTag = ossimString("")); | ||
|
||
protected: | ||
ossimString m_key; | ||
ossimString m_value; | ||
|
||
ChildMap m_children; | ||
ChildMap m_attributes; | ||
bool m_isArray; | ||
|
||
static std::shared_ptr<KwlNode> findChild(ChildMap &childMap, | ||
const ossimString &key); | ||
|
||
static std::shared_ptr<const KwlNode> findChild(const ChildMap &childMap, | ||
const ossimString &key); | ||
bool checkIfAttribute(const ossimString &value)const; | ||
bool checkIfArray(const ossimString &value)const; | ||
void extractKeyAndIndex(const ossimString &value, | ||
ossimString &key, | ||
ossimString &idx)const; | ||
void loadPath(std::vector<ossimString> &q, const ossimString &value); | ||
void addOrSetAttribute(const ossimString &key, const ossimString &value); | ||
void loadPath(const ossimString &key, const ossimString &value); | ||
}; | ||
} // namespace ossim | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#ifndef ossimKwlNodeFormatter_HEADER | ||
#define ossimKwlNodeFormatter_HEADER | ||
#include <ossim/base/KwlNode.h> | ||
|
||
namespace ossim | ||
{ | ||
class KwlNodeFormatter | ||
{ | ||
public: | ||
class FormatHints | ||
{ | ||
public: | ||
enum FormatFlags | ||
{ | ||
FORMAT_HINTS_NO_OPTION_FLAGS = 0, | ||
FORMAT_HINTS_PRETTY_PRINT_FLAG = 1, | ||
FORMAT_HINTS_OUTPUT_DOCUMENT_HEADER_FLAG = 2, | ||
FORMAT_HINTS_UPCASE_PARENT_TAGS_FLAG = 4, | ||
FORMAT_HINTS_ALL = (FORMAT_HINTS_PRETTY_PRINT_FLAG | FORMAT_HINTS_OUTPUT_DOCUMENT_HEADER_FLAG | FORMAT_HINTS_UPCASE_PARENT_TAGS_FLAG) | ||
}; | ||
FormatHints(ossim_uint32 indent = 3, | ||
FormatFlags formatFlags = FORMAT_HINTS_NO_OPTION_FLAGS) | ||
: m_indent(indent), | ||
m_formatFlags(formatFlags) | ||
{ | ||
} | ||
ossim_uint32 indent()const { return m_indent; } | ||
void setIndent(ossim_uint32 indent) { m_indent = indent; } | ||
bool prettyPrint() const { return m_formatFlags & FORMAT_HINTS_PRETTY_PRINT_FLAG; } | ||
bool outputDocumentHeader() const { return m_formatFlags & FORMAT_HINTS_OUTPUT_DOCUMENT_HEADER_FLAG; } | ||
bool upcaseParentTag() const { return m_formatFlags & FORMAT_HINTS_UPCASE_PARENT_TAGS_FLAG; } | ||
void setFormatFlags(FormatFlags flags) { m_formatFlags = flags;} | ||
FormatFlags getFormatFlags()const { return m_formatFlags;} | ||
protected: | ||
ossim_uint32 m_indent; | ||
FormatFlags m_formatFlags; | ||
}; | ||
KwlNodeFormatter(std::shared_ptr<KwlNode> kwlNode) : m_kwlNode(kwlNode) | ||
{ | ||
} | ||
KwlNodeFormatter(const ossimKeywordlist &kwl) | ||
{ | ||
m_kwlNode = KwlNode::createTree(kwl); | ||
} | ||
virtual void write(ossimString &result, const FormatHints &hints = FormatHints()) const; | ||
virtual void write(std::ostream &out, const FormatHints &hints = FormatHints()) const = 0; | ||
|
||
protected: | ||
std::shared_ptr<KwlNode> m_kwlNode; | ||
}; | ||
} | ||
#endif |
Oops, something went wrong.