libdigidocpp
ADoc.h
Go to the documentation of this file.
1 /*
2  * libdigidocpp
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  */
19 
20 #pragma once
21 
22 #include "Exception.h"
23 
24 #include <memory>
25 
26 namespace digidoc
27 {
28 
29 EXP_DIGIDOC std::string appInfo();
30 EXP_DIGIDOC void initialize(const std::string &appInfo = "");
31 EXP_DIGIDOC void terminate();
32 EXP_DIGIDOC std::string version();
33 
34 class Document;
35 class Signature;
36 class Signer;
37 
39 {
40 public:
42  {
43  UnknownType = 0,
44  BDocType = 1,
45  DDocType = 2
46  };
47 
48  virtual ~ADoc() {}
49  virtual void save() throw(IOException, BDocException) = 0;
50  virtual void saveTo(const std::string &path) throw(IOException, BDocException) = 0;
51  virtual void addDocument(const Document& document) throw(BDocException) = 0;
52  virtual Document getDocument(unsigned int id) const throw(BDocException) = 0;
53  virtual void removeDocument(unsigned int id) throw(BDocException) = 0;
54  virtual unsigned int documentCount() const = 0;
55  virtual DocumentType documentType() const;
56  virtual void addSignature(const std::vector<unsigned char> &signature) throw(BDocException) = 0;
57  unsigned int newSignatureId() const;
58  virtual const Signature* getSignature(unsigned int id) const throw(BDocException) = 0;
59  virtual void removeSignature(unsigned int id) throw(BDocException) = 0;
60  virtual unsigned int signatureCount() const = 0;
61  virtual void sign(Signer* signer) throw(BDocException) = 0;
62  virtual std::vector<unsigned char> getFileDigest( unsigned int id ) throw(BDocException) = 0;
63 };
64 
65 }