• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • kasten
  • gui
  • liboktetawidgets
bytearrayvalidator.h
Go to the documentation of this file.
1 /*
2  This file is part of the Okteta Kasten module, made within the KDE community.
3 
4  Copyright 2006,2009,2011 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) version 3, or any
10  later version accepted by the membership of KDE e.V. (or its
11  successor approved by the membership of KDE e.V.), which shall
12  act as a proxy defined in Section 6 of version 3 of the license.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #ifndef BYTEARRAYVALIDATOR_H
24 #define BYTEARRAYVALIDATOR_H
25 
26 // Okteta core
27 #include <oktetacore.h>
28 // Qt
29 #include <QtGui/QValidator>
30 
31 
32 namespace Okteta
33 {
34 class ValueCodec;
35 class CharCodec;
36 
37 
38 class ByteArrayValidator : public QValidator
39 {
40  Q_OBJECT
41 
42  public:
43  // matching Okteta::ValueCoding
44  enum Coding {
45  InvalidCoding = -1,
46  HexadecimalCoding = 0,
47  DecimalCoding = 1,
48  OctalCoding = 2,
49  BinaryCoding = 3,
50  CharCoding = 4,
51  Utf8Coding = 5
52  };
53 
54  public:
55  explicit ByteArrayValidator( QObject* parent = 0,
56  Coding codecId = CharCoding,
57  int charCodecId = LocalEncoding );
58 
59  virtual ~ByteArrayValidator();
60 
61  public: // QValidator API
62  virtual QValidator::State validate( QString& input, int& pos ) const;
63 
64  public:
66  void setCodec( Coding codecId );
68  void setCharCodec( const QString& charCodecName );
71  void setMaxLength( int maxLength );
74  void setMinLength( int minLength );
75 
76  public:
77  int maxLength() const;
78  int minLength() const;
79 
80  public:
81  QByteArray toByteArray( const QString& string ) const;
82  QString toString( const QByteArray& byteArray ) const;
83 
84  private:
91 // QString zeroExtend( const QString &src, int destLen ) const;
92 
93  Coding mCodecId;
94  ValueCodec* mValueCodec;
95  CharCodec* mCharCodec;
96  int mMaxLength;
97  int mMinLength;
98 };
99 
100 
101 inline int ByteArrayValidator::maxLength() const { return mMaxLength; }
102 inline int ByteArrayValidator::minLength() const { return mMinLength; }
103 
104 }
105 
106 #endif
Okteta::ByteArrayValidator::DecimalCoding
Definition: bytearrayvalidator.h:47
Okteta::ByteArrayValidator::setCharCodec
void setCharCodec(const QString &charCodecName)
Sets the char codec to use. Does not change the current codec.
Definition: bytearrayvalidator.cpp:47
Okteta::ByteArrayValidator::setMaxLength
void setMaxLength(int maxLength)
Sets the maximal length of the edited bytearray to maxLength.
Definition: bytearrayvalidator.cpp:71
Okteta::ByteArrayValidator::toString
QString toString(const QByteArray &byteArray) const
Definition: bytearrayvalidator.cpp:185
Okteta::ByteArrayValidator::maxLength
int maxLength() const
Definition: bytearrayvalidator.h:101
Okteta::CharCoding
CharCoding
Definition: oktetacore.h:39
Okteta::ByteArrayValidator::minLength
int minLength() const
Definition: bytearrayvalidator.h:102
Okteta::ByteArrayValidator
Definition: bytearrayvalidator.h:38
Okteta::ByteArrayValidator::OctalCoding
Definition: bytearrayvalidator.h:48
QObject
Okteta::ByteArrayValidator::~ByteArrayValidator
virtual ~ByteArrayValidator()
Definition: bytearrayvalidator.cpp:213
Okteta::ByteArrayValidator::HexadecimalCoding
Definition: bytearrayvalidator.h:46
Okteta::ByteArrayValidator::BinaryCoding
Definition: bytearrayvalidator.h:49
QValidator
Okteta::CharCodec
Definition: charcodec.h:42
oktetacore.h
Okteta::ByteArrayValidator::ByteArrayValidator
ByteArrayValidator(QObject *parent=0, Coding codecId=CharCoding, int charCodecId=LocalEncoding)
Definition: bytearrayvalidator.cpp:34
Okteta::ByteArrayValidator::InvalidCoding
Definition: bytearrayvalidator.h:45
Okteta::ValueCodec
Class that is able to convert codings to and from hexadecimal, decimal, octal, and binary...
Definition: valuecodec.h:45
Okteta::ByteArrayValidator::Utf8Coding
Definition: bytearrayvalidator.h:51
Okteta::ByteArrayValidator::setCodec
void setCodec(Coding codecId)
Sets one of the value codecs or the current char codec.
Definition: bytearrayvalidator.cpp:56
Okteta::ByteArrayValidator::validate
virtual QValidator::State validate(QString &input, int &pos) const
Definition: bytearrayvalidator.cpp:85
Okteta::LocalEncoding
the coding of your shell
Definition: oktetacore.h:42
Okteta::ByteArrayValidator::setMinLength
void setMinLength(int minLength)
Sets the maximal length of the edited bytearray to minLength.
Definition: bytearrayvalidator.cpp:78
Okteta::ByteArrayValidator::Coding
Coding
Definition: bytearrayvalidator.h:44
Okteta::ByteArrayValidator::toByteArray
QByteArray toByteArray(const QString &string) const
Definition: bytearrayvalidator.cpp:146
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:07 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal