-
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.
Merge pull request #32 from Adamska1008/31-refactor-project-naming-co…
…nvention 31 refactor project naming convention
- Loading branch information
Showing
34 changed files
with
1,054 additions
and
850 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--- |
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,3 @@ | ||
Start testing: Sep 05 15:55 CST | ||
---------------------------------------------------------- | ||
End testing: Sep 05 15:55 CST |
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,91 @@ | ||
# Examples | ||
|
||
## Document | ||
|
||
### Simple | ||
|
||
```C++ | ||
using namespace myxml; | ||
// `std::string xml` | ||
document doc = document::parse(xml); | ||
// or | ||
doc = document::load(path); | ||
// get root elem | ||
std::optional<element> elem = doc.root().first_elem(); | ||
// or directly query elem in root | ||
elem = doc.first_elem(); | ||
// or query by name | ||
elem = doc.first_elem("elem"); | ||
``` | ||
|
||
### Element | ||
|
||
#### Basic | ||
|
||
```C++ | ||
using namespace myxml; | ||
element elem("root"); | ||
fmt::println(root->name()); | ||
root->set_name("far"); | ||
``` | ||
#### Attributes | ||
```C++ | ||
using namespace myxml; | ||
// create an element with name 'root' | ||
element elem("root"); | ||
// or get an element from parsing | ||
element elem = element::parse(xml); | ||
// or do it by custom string literal | ||
element elem = "<root/>"_elem; | ||
// query attributes, it returns an string reference | ||
fmt::println(elem["hello"]); | ||
// modify attribute, will create new attribute if not found one | ||
elem["hello"] = "world!"; | ||
// if key not exist, query it will create an empty attribute | ||
elem["hello"]; // == elem["hello"] = ""; | ||
``` | ||
|
||
#### Children | ||
|
||
```C++ | ||
using namespace myxml; | ||
// element root; | ||
element child = root.first_elem(); | ||
// or first element with name "child" | ||
element child = root.first_elem("child"); | ||
// elements == vector<element> | ||
std::vector<element> children = root.elems(); | ||
// or elements with same name | ||
std::vector<element> children = root.elems("child"); | ||
``` | ||
|
||
### Text | ||
|
||
```C++ | ||
using namespace myxml; | ||
// create from string | ||
text txt = "Hello"; | ||
// or from query | ||
text txt = root.first_text(); | ||
// print raw | ||
fmt::println(txt); | ||
// print trimmed text, it returns std::string and will not modify it | ||
fmt::println(txt.trimmed()); | ||
// yet it will modify. return a new text | ||
fmt::println(txt.trim()); | ||
``` | ||
### CData | ||
```C++ | ||
// similar to text | ||
using namespace myxml; | ||
// create from string | ||
cdata txt = "Hello"; | ||
// or from query | ||
cdata txt = root.first_cdata(); | ||
// print raw | ||
fmt::println(txt); | ||
``` |
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 |
---|---|---|
@@ -1,19 +1,40 @@ | ||
#pragma once | ||
#include "myxml/node.hpp" | ||
#include "myxml/printable.hpp" | ||
|
||
namespace myxml | ||
{ | ||
class CData : public Node | ||
class cdata_impl; | ||
|
||
class cdata : public printable | ||
{ | ||
friend class element; | ||
private: | ||
std::string inner; | ||
std::shared_ptr<cdata_impl> _impl; | ||
|
||
cdata(std::shared_ptr<cdata_impl>); | ||
|
||
public: | ||
cdata(std::string &&); | ||
cdata(std::string_view); | ||
|
||
virtual void entity_encoding(bool) override {} | ||
virtual void platform_specific_newline(bool) override {} | ||
virtual void print(std::ostream &) const override; | ||
}; | ||
|
||
class cdata_impl : public node | ||
{ | ||
public: | ||
explicit CData(std::string); | ||
std::string _inner; | ||
|
||
cdata_impl() {}; | ||
explicit cdata_impl(std::string_view); | ||
explicit cdata_impl(std::string &&); | ||
virtual ~cdata_impl() = default; | ||
|
||
virtual ~CData() = default; | ||
virtual std::string ExportRaw() const override; | ||
virtual std::string ExportFormatted(int indentLevel = 0, int indentSize = 4) const override; | ||
virtual void SetEntityEncoding(bool) override; | ||
virtual void entity_encoding(bool) override {} | ||
virtual void platform_specific_newline(bool) override {} | ||
virtual void print(std::ostream &) const override; | ||
}; | ||
} |
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
Oops, something went wrong.