Fesapi  2.0.0.0
This project provides C++ classes which allow an easy access in import and export to the Energistics standards.
Package.h
1 /*-----------------------------------------------------------------------
2 Licensed to the Apache Software Foundation (ASF) under one
3 or more contributor license agreements. See the NOTICE file
4 distributed with this work for additional information
5 regarding copyright ownership. The ASF licenses this file
6 to you under the Apache License, Version 2.0 (the
7 "License"; you may not use this file except in compliance
8 with the License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12 Unless required by applicable law or agreed to in writing,
13 software distributed under the License is distributed on an
14 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 KIND, either express or implied. See the License for the
16 specific language governing permissions and limitations
17 under 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 
32 namespace 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 
55  static const char* CORE_PROP_REL_TYPE;
57  static const char* EXTENDED_CORE_PROP_REL_TYPE;
58 
59  public:
62 
73  Package(const FileCoreProperties & pkgFileCP, const FileContentType & pkgFileCT, const FileRelationship & pkgFileRS, const PartMap & pkgFileP, const std::string & pkgPathName);
74 
77 
89  void openForWriting(const std::string & pkgPathName, int append, bool useZip64 = false);
90 
94  bool isOpenedForWriting() const;
95 
103  std::vector<std::string> openForReading(const std::string & pkgPathName);
104 
108  bool isOpenedForReading() const;
109 
111  void close();
112 
119 
126 
133 
139  const PartMap & getAllFilePart() const;
140 
146  const std::string & getPathname() const;
147 
154 
162  std::unordered_map< std::string, std::string > & getExtendedCoreProperty();
163 
170  void addProperty(const CoreProperty::TypeProperty & pkgTypeProperty, const std::string & pkgPropertyValue);
171 
177  void setFileContentType(const FileContentType & pkgFileCT);
178 
184  void addContentType(const ContentType & contentType);
185 
192 
198  void addRelationship(const Relationship & relationship);
199 
209  FilePart* createPart(const std::string & inputContent, const std::string & outputPartPath);
210 
218  const FilePart* findPart(const std::string & outputPartPath) const;
219 
227  bool fileExists(const std::string & filename) const;
228 
237  std::string extractFile(const std::string & filename, const std::string & password = "");
238 
240  void writePackage();
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
Definition: Package.h:36
void setPrincipalRelationship(const FileRelationship &pkgFileRS)
std::unordered_map< std::string, std::string > & getExtendedCoreProperty()
void writePackage()
void addProperty(const CoreProperty::TypeProperty &pkgTypeProperty, const std::string &pkgPropertyValue)
Package(const FileCoreProperties &pkgFileCP, const FileContentType &pkgFileCT, const FileRelationship &pkgFileRS, const PartMap &pkgFileP, const std::string &pkgPathName)
void openForWriting(const std::string &pkgPathName, int append, bool useZip64=false)
void setFileFileCoreProperties(const FileCoreProperties &pkgFileCP)
const FileContentType & getFileContentType() const
void addContentType(const ContentType &contentType)
const std::string & getPathname() const
void setFileContentType(const FileContentType &pkgFileCT)
const PartMap & getAllFilePart() const
bool isOpenedForReading() const
std::string extractFile(const std::string &filename, const std::string &password="")
const FileCoreProperties & getFileCoreProperties() const
void addRelationship(const Relationship &relationship)
const FilePart * findPart(const std::string &outputPartPath) const
bool isOpenedForWriting() const
const FileRelationship & getPrincipalRelationship() const
std::vector< std::string > openForReading(const std::string &pkgPathName)
FilePart * createPart(const std::string &inputContent, const std::string &outputPartPath)
bool fileExists(const std::string &filename) const
Definition: Relationship.h:28
The epc namespace.
Definition: ContentType.h:25