Bump version to 6.4-15
[LibreOffice.git] / include / connectivity / dbcharset.hxx
blob79e8c8ec48cfa79872a1ddcc25817e3d4ef3a781
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CONNECTIVITY_DBCHARSET_HXX
21 #define INCLUDED_CONNECTIVITY_DBCHARSET_HXX
23 #include <sal/config.h>
25 #include <set>
27 #include <rtl/textenc.h>
28 #include <rtl/tencinfo.h>
29 #include <rtl/ustring.hxx>
30 #include <connectivity/dbtoolsdllapi.hxx>
33 namespace dbtools
37 //= OCharsetMap
39 /** is a class which translates between different charset representations.
41 <p>The set of recognized charsets is very limited: only the ones which are database relevant are
42 implemented at the moment</p>
44 <p>Possible representations are:
45 <ul>
46 <li><b>IANA names.</b>
47 Have a look at <A href="http://www.iana.org/assignments/character-sets">this document</A> for
48 more details</li>
49 <li><b>rtl_TextEncoding</b></li>
50 </ul>
51 </p>
53 class OOO_DLLPUBLIC_DBTOOLS OCharsetMap
55 protected:
56 typedef std::set<rtl_TextEncoding> TextEncBag;
58 TextEncBag m_aEncodings;
60 public:
61 class CharsetIterator;
62 friend class OCharsetMap::CharsetIterator;
63 typedef CharsetIterator iterator;
64 typedef CharsetIterator const_iterator;
66 OCharsetMap();
67 virtual ~OCharsetMap();
69 /** find the given text encoding in the map.
70 @return the <em>end</em> iterator if the encoding could not be found.
72 CharsetIterator find(const rtl_TextEncoding _eEncoding) const;
73 /** find the given IANA name in the map.
74 @return the <em>end</em> iterator if the IANA name could not be found.
76 CharsetIterator findIanaName(const OUString& _rIanaName) const;
78 /// get access to the first element of the charset collection
79 CharsetIterator begin() const;
80 /// get access to the (last + 1st) element of the charset collection
81 CharsetIterator end() const;
83 protected:
84 // needed because we want to call a virtual method during construction
85 void lateConstruct();
86 void ensureConstructed( ) const { if ( m_aEncodings.empty() ) const_cast< OCharsetMap* >( this )->lateConstruct(); }
88 virtual bool approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const;
92 //- CharsetIteratorDerefHelper
94 class OOO_DLLPUBLIC_DBTOOLS CharsetIteratorDerefHelper
96 friend class OCharsetMap::CharsetIterator;
98 rtl_TextEncoding m_eEncoding;
99 OUString m_aIanaName;
101 public:
102 CharsetIteratorDerefHelper(const CharsetIteratorDerefHelper& _rSource);
104 rtl_TextEncoding getEncoding() const { return m_eEncoding; }
105 const OUString& getIanaName() const { return m_aIanaName; }
107 protected:
108 CharsetIteratorDerefHelper( const rtl_TextEncoding _eEncoding, const OUString& _rIanaName );
113 //- OCharsetMap::CharsetIterator
115 class OOO_DLLPUBLIC_DBTOOLS OCharsetMap::CharsetIterator
117 friend class OCharsetMap;
119 friend OOO_DLLPUBLIC_DBTOOLS bool operator==(const CharsetIterator& lhs, const CharsetIterator& rhs);
120 friend bool operator!=(const CharsetIterator& lhs, const CharsetIterator& rhs) { return !(lhs == rhs); }
122 // friend sal_Int32 operator-(const CharsetIterator& lhs, const CharsetIterator& rhs);
124 protected:
125 const OCharsetMap* m_pContainer;
126 OCharsetMap::TextEncBag::const_iterator m_aPos;
128 public:
129 CharsetIteratorDerefHelper operator*() const;
130 // no -> operator
131 // this would require us to a) store CharsetIteratorDerefHelper instances ourself so that we
132 // can return a pointer or b) introduce a -> operator on the CharsetIteratorDerefHelper, too.
134 /// prefix increment
135 const CharsetIterator& operator++();
137 /// prefix decrement
138 const CharsetIterator& operator--();
140 protected:
141 CharsetIterator(const OCharsetMap* _pContainer, OCharsetMap::TextEncBag::const_iterator const & _aPos );
145 } // namespace dbtools
148 #endif // INCLUDED_CONNECTIVITY_DBCHARSET_HXX
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */