Skip to main content

Common Fluids Format 2023 R2

Iterator

Last update: 16.07.2025
1#ifndef CFFSDK_PROJECT_ITERATOR_H
2#define CFFSDK_PROJECT_ITERATOR_H
3
4#include "Project/LibraryType.hpp"
5#include "Project/Path.hpp"
6#include "Project/URL.hpp"
7#include "Project/Error.hpp"
8#include <memory>
9
10namespace ansys {
11namespace Project {
12
13class PItem;
14class Visitor;
15class Metadata;
16class Query;
17
18enum PItemType { PIUndefined=0, PIFolder=1, PIFile=2, PILink=3, PIPropertyTree=4 };
19
20class ANSYS_PROJECT_DLL Iterator {
21public:
22 Iterator();
23 Iterator(const Error& pError);
24 Iterator(const std::shared_ptr<PItem>& pItem);
25
26 bool ok() const;
27 void setError(const Error& pError);
28 const Error& getError() const;
29
30 bool operator==(const Iterator& pObj) const;
31 bool operator!=(const Iterator& pObj) const {
32 return !(*this == pObj);
33 }
34
35 //FileRef fileRef();
36
37 PItemType getType() const;
38 std::string getTypeAsString() const ;
39 std::string getSubclass() const;
40
41 std::string getName() const;
42 Error rename(const std::string& pName);
43
44 Path getPath() const;
45 Iterator getParent() const;
46 Iterator getParentOfType(const std::string& pType) const;
47 Iterator getParentOfSubclass(const std::string& pSubclass) const;
48 void accept(Visitor& pVisitor);
49
50 int getProjectId() const;
51 bool isReadOnly() const;
52
53 Metadata& getMeta();
54 const Metadata& getMeta() const;
55
56 Metadata& getRuntimeMeta();
57 const Metadata& getRuntimeMeta() const;
58
59 std::vector<Iterator> find(const Query& pQuery,bool pFollowSymlink=false) const;
60
61 // Type actions
62 bool isFile() const;
63 bool isLink() const;
64 bool isFolder() const;
65 bool isPropertyTree() const;
66 PItem* asItem() const;
67
68 // Folder actions
69 Iterator newFolder(const std::string& pName);
70 Iterator newFolder(const std::string& pName,const URL& pURL);
71 Iterator newFile(const std::string& pName);
72 Iterator newFile(const std::string& pName,const URL& pURL,bool pImport=false);
73 Iterator newLink(const std::string& pName,const Iterator& pTarget);
74 Iterator newPropertyTree(const std::string& pName);
75 Iterator getChild(const std::string& pName) const;
76 Iterator get(const Path& pName) const;
77 Iterator getByURL(const URL& pRelativeURL) const;
78 std::vector<std::string> getChildNames() const;
79 std::vector<Iterator> getChildList() const;
80 std::vector<Iterator> getChildListOfSubclass(std::string pSubclass) const;
81 std::vector<std::string> getFolderOtherURLSubItems(bool pFolders) const;
82 Error removeItem(const std::string& pName,bool pFlagRecursive=false);
83 Error moveTo(Iterator pTargetFolder);
84
85 // File actions
86 void setURL(const URL& pURL);
87 URL getURL() const;
88 URL getURLFromRoot() const;
89 URL getFullURL() const;
90 bool urlExists() const;
91 bool isURLEditable() const;
92
93 void clearChecksum();
94 Error computeChecksum(std::string& pChecksum,bool pFlagStore);
95 Error getStoredChecksum(std::string& pChecksum) const;
96
97 // Link actions
98 Iterator getTarget() const;
99 std::string getTargetStr() const;
100 void setTarget(const Iterator& pIter);
101 bool isSubProject() const;
102
103 // Container
104 bool operator<(const Iterator& pObj) const {
105 return getPath().str() < pObj.getPath().str();
106 }
107
108protected:
109 std::weak_ptr<PItem> aRef;
110 Error aError;
111};
112
113}
114}
115
116#endif // CFFSDK_PROJECT_ITERATOR_H
The return state / error value of a Project function call.
Definition: Error.hpp:11
Pointer to a project location.
Definition: Iterator.hpp:20
Path getPath() const
Return the item full Path in the project.
Definition: Iterator.cpp:251
Dictionary of values associated with an Iterator.
Definition: Metadata.hpp:19
Paths used for internal Project filesystem.
Definition: Path.hpp:11
const std::string & str() const
Return as string.
Definition: Path.cpp:181
Set of conditions used in search within the Project. See Iterator::find()
Definition: Query.hpp:13
The address of a local or remote file, using the URI format.
Definition: URL.hpp:12
Definition: API.dox:1

Connect with Ansys