Fesapi 2.13.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
Loading...
Searching...
No Matches
Package.h
1/*-----------------------------------------------------------------------
2Licensed to the Apache Software Foundation (ASF) under one
3or more contributor license agreements. See the NOTICE file
4distributed with this work for additional information
5regarding copyright ownership. The ASF licenses this file
6to you under the Apache License, Version 2.0 (the
7"License"; you may not use this file except in compliance
8with the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12Unless required by applicable law or agreed to in writing,
13software distributed under the License is distributed on an
14"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15KIND, either express or implied. See the License for the
16specific language governing permissions and limitations
17under the License.
18-----------------------------------------------------------------------*/
19#ifndef PACKAGE_H
20#define PACKAGE_H
21
22#include <vector>
23#include <string>
24
25#include <unordered_map>
26
27#include "FileCoreProperties.h"
28#include "FileContentType.h"
29#include "FileRelationship.h"
30#include "FilePart.h"
31
32namespace epc
33{
35 class Package
36 {
37
38 private :
39 class CheshireCat; // Not defined here but in the cpp
41 CheshireCat * d_ptr;
43 typedef std::unordered_map<std::string, FilePart> PartMap;
44
52 void writeStringIntoNewPart(const std::string &input, const std::string & partPath);
53
54 static constexpr char const* CORE_PROP_REL_TYPE = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
55 static constexpr char const* EXTENDED_CORE_PROP_REL_TYPE = "http://schemas.f2i-consulting.com/package/2014/relationships/extended-core-properties";
56
57 public:
60 Package(const Package&) = delete;
61
62
73 Package(const FileCoreProperties & pkgFileCP, const FileContentType & pkgFileCT, const FileRelationship & pkgFileRS, const PartMap & pkgFileP, const std::string & pkgPathName);
74
75 Package& operator=(const Package&) = delete;
76
79
90 void openForWriting(const std::string & pkgPathName, int append);
91
95 bool isOpenedForWriting() const;
96
104 std::vector<std::string> openForReading(const std::string & pkgPathName);
105
109 bool isOpenedForReading() const;
110
112 void close();
113
120
127
134
140 const PartMap & getAllFilePart() const;
141
147 const std::string & getPathname() const;
148
155
163 std::unordered_map< std::string, std::string > & getExtendedCoreProperty();
164
171 void addProperty(const CoreProperty::TypeProperty & pkgTypeProperty, const std::string & pkgPropertyValue);
172
178 void setFileContentType(const FileContentType & pkgFileCT);
179
185 void addContentType(const ContentType & contentType);
186
193
199 void addRelationship(const Relationship & relationship);
200
210 FilePart* createPart(const std::string & inputContent, const std::string & outputPartPath);
211
219 const FilePart* findPart(const std::string & outputPartPath) const;
220
228 bool fileExists(const std::string & filename) const;
229
237 std::string extractFile(const std::string & filename);
238
241 };
242}
243
244#endif
Definition ContentType.h:28
TypeProperty
Definition CoreProperty.h:33
Definition FileContentType.h:30
Definition FileCoreProperties.h:28
Definition FilePart.h:29
Definition FileRelationship.h:30
std::vector< std::string > openForReading(const std::string &pkgPathName)
void setPrincipalRelationship(const FileRelationship &pkgFileRS)
const FileContentType & getFileContentType() const
void openForWriting(const std::string &pkgPathName, int append)
void writePackage()
void addProperty(const CoreProperty::TypeProperty &pkgTypeProperty, const std::string &pkgPropertyValue)
FilePart * createPart(const std::string &inputContent, const std::string &outputPartPath)
std::unordered_map< std::string, std::string > & getExtendedCoreProperty()
Package(const FileCoreProperties &pkgFileCP, const FileContentType &pkgFileCT, const FileRelationship &pkgFileRS, const PartMap &pkgFileP, const std::string &pkgPathName)
const FileRelationship & getPrincipalRelationship() const
void setFileFileCoreProperties(const FileCoreProperties &pkgFileCP)
void addContentType(const ContentType &contentType)
const std::string & getPathname() const
void setFileContentType(const FileContentType &pkgFileCT)
bool isOpenedForReading() const
const PartMap & getAllFilePart() const
std::string extractFile(const std::string &filename)
void addRelationship(const Relationship &relationship)
bool isOpenedForWriting() const
const FilePart * findPart(const std::string &outputPartPath) const
const FileCoreProperties & getFileCoreProperties() const
bool fileExists(const std::string &filename) const
Definition Relationship.h:28
The epc namespace.
Definition ContentType.h:25