LibreOffice Module connectivity (master) 1
dbcharset.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_CONNECTIVITY_DBCHARSET_HXX
21#define INCLUDED_CONNECTIVITY_DBCHARSET_HXX
22
23#include <sal/config.h>
24
25#include <set>
26
27#include <rtl/textenc.h>
28#include <rtl/tencinfo.h>
29#include <rtl/ustring.hxx>
31
32
33namespace dbtools
34{
35
36
37 //= OCharsetMap
38
54 {
55 protected:
56 typedef std::set<rtl_TextEncoding> TextEncBag;
57
59
60 public:
61 class CharsetIterator;
63 typedef CharsetIterator iterator;
64 typedef CharsetIterator const_iterator;
65
67 virtual ~OCharsetMap();
68
72 CharsetIterator find(const rtl_TextEncoding _eEncoding) const;
76 CharsetIterator findIanaName(std::u16string_view _rIanaName) const;
77
79 CharsetIterator begin() const;
81 CharsetIterator end() const;
82
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(); }
87
88 virtual bool approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const;
89 };
90
91
92 //- CharsetIteratorDerefHelper
93
95 {
97
98 rtl_TextEncoding m_eEncoding;
99 OUString m_aIanaName;
100
101 public:
103
104 rtl_TextEncoding getEncoding() const { return m_eEncoding; }
105 const OUString& getIanaName() const { return m_aIanaName; }
106
107 protected:
108 CharsetIteratorDerefHelper( const rtl_TextEncoding _eEncoding, OUString _sIanaName );
109
110 };
111
112
113 //- OCharsetMap::CharsetIterator
114
115 class OOO_DLLPUBLIC_DBTOOLS OCharsetMap::CharsetIterator
116 {
117 friend class OCharsetMap;
118
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); }
121
122// friend sal_Int32 operator-(const CharsetIterator& lhs, const CharsetIterator& rhs);
123
125 OCharsetMap::TextEncBag::const_iterator m_aPos;
126
127 public:
129 // no -> operator
130 // this would require us to a) store CharsetIteratorDerefHelper instances ourself so that we
131 // can return a pointer or b) introduce a -> operator on the CharsetIteratorDerefHelper, too.
132
134 const CharsetIterator& operator++();
135
137 const CharsetIterator& operator--();
138
139 protected:
140 CharsetIterator(const OCharsetMap* _pContainer, OCharsetMap::TextEncBag::const_iterator _aPos );
141 };
142
143
144} // namespace dbtools
145
146
147#endif // INCLUDED_CONNECTIVITY_DBCHARSET_HXX
148
149/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
rtl_TextEncoding getEncoding() const
Definition: dbcharset.hxx:104
const OUString & getIanaName() const
Definition: dbcharset.hxx:105
is a class which translates between different charset representations.
Definition: dbcharset.hxx:54
CharsetIterator const_iterator
Definition: dbcharset.hxx:64
void ensureConstructed() const
Definition: dbcharset.hxx:86
friend OOO_DLLPUBLIC_DBTOOLS bool operator==(const CharsetIterator &lhs, const CharsetIterator &rhs)
OCharsetMap::TextEncBag::const_iterator m_aPos
Definition: dbcharset.hxx:125
CharsetIterator(const OCharsetMap *_pContainer, OCharsetMap::TextEncBag::const_iterator _aPos)
const CharsetIterator & operator++()
prefix increment
CharsetIteratorDerefHelper operator*() const
CharsetIterator iterator
Definition: dbcharset.hxx:63
TextEncBag m_aEncodings
Definition: dbcharset.hxx:58
std::set< rtl_TextEncoding > TextEncBag
Definition: dbcharset.hxx:56
const CharsetIterator & operator--()
prefix decrement
friend bool operator!=(const CharsetIterator &lhs, const CharsetIterator &rhs)
Definition: dbcharset.hxx:120
const OCharsetMap * m_pContainer
Definition: dbcharset.hxx:124
#define OOO_DLLPUBLIC_DBTOOLS
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
Definition: dbtools.cxx:1958
enumrange< T >::Iterator begin(enumrange< T >)
end