fw4spl
Encoding.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWGDCMIO_HELPER_ENCODING_HPP__
8 #define __FWGDCMIO_HELPER_ENCODING_HPP__
9 
10 #include "fwGdcmIO/config.hpp"
11 
12 #include <fwCore/Exception.hpp>
13 #include <fwCore/macros.hpp>
14 
15 #include <boost/locale/encoding_errors.hpp>
16 
17 #include <map>
18 #include <string>
19 #include <vector>
20 
21 namespace fwLog
22 {
23 class Logger;
24 }
25 
26 namespace fwGdcmIO
27 {
28 namespace helper
29 {
30 
34 class FWGDCMIO_CLASS_API Encoding
35 {
36 public:
37 
47  FWGDCMIO_API static std::string convertString(const std::string& source,
48  const std::string& definedCharsetTerm,
49  const SPTR(::fwLog::Logger)& logger = nullptr)
50  throw(::fwCore::Exception, ::boost::locale::conv::invalid_charset_error);
51 
52 private:
53 
61  static std::string convertStringWithoutCodeExtensions(const std::string& source,
62  const std::string& definedTerm,
63  const SPTR(::fwLog::Logger)& logger);
73  static std::string convertSequenceWithCodeExtensions(const std::string& sequence,
74  const std::vector<std::string>& definedTermList,
75  const SPTR(::fwLog::Logger)& logger)
76  throw(::fwCore::Exception, ::boost::locale::conv::invalid_charset_error);
77 
81  typedef std::map< std::string, std::string> DefinedTermToCharsetMapType;
82  static const DefinedTermToCharsetMapType s_DEFINED_TERM_TO_CHARSET;
85  typedef std::pair< char, char> EscapeSequenceType;
87 
89  typedef std::pair< std::string, std::string > DefinedTermAndCharsetPairType;
90 
94  typedef std::map< EscapeSequenceType, DefinedTermAndCharsetPairType> EscapeSequenceToCharsetMapType;
95  static const EscapeSequenceToCharsetMapType s_ESCAPE_SEQUENCE_TO_CHARSET;
98 };
99 
100 } // namespace helper
101 } // namespace fwGdcmIO
102 
103 #endif //__FWGDCMIO_HELPER_ENCODING_HPP__
104 
#define SPTR(_cls_)
This file defines fwCore base macros.
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
fwLog contains classes used to manage logs.
Definition: Log.hpp:16
Logger class used to store logs.
Helper class for encoding management.
Definition: Encoding.hpp:34