• 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
  • io
  • streamencoder
  • values
bytearrayvaluesstreamencoder.cpp
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 2007 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 #include "bytearrayvaluesstreamencoder.h"
24 
25 // lib
26 #include <bytearrayview.h>
27 // Okteta core
28 #include <abstractbytearraymodel.h>
29 #include <valuecodec.h>
30 // KDE
31 #include <KLocale>
32 // Qt
33 #include <QtCore/QTextStream>
34 
35 
36 namespace Kasten2
37 {
38 
39 ValuesStreamEncoderSettings::ValuesStreamEncoderSettings()
40  : valueCoding( Okteta::HexadecimalCoding), separation( QLatin1String(" ") )
41 {}
42 
43 ByteArrayValuesStreamEncoder::ByteArrayValuesStreamEncoder()
44  : AbstractByteArrayStreamEncoder( i18nc("name of the encoding target","Values"), QString::fromLatin1("text/plain") )
45 {}
46 
47 
48 bool ByteArrayValuesStreamEncoder::encodeDataToStream( QIODevice *device,
49  const ByteArrayView* byteArrayView,
50  const Okteta::AbstractByteArrayModel* byteArrayModel,
51  const Okteta::AddressRange& range )
52 {
53  bool success = true;
54 
55  // settings
56  mSettings.undefinedChar = byteArrayView->undefinedChar();
57  mSettings.substituteChar = byteArrayView->substituteChar();
58  mSettings.valueCoding = (Okteta::ValueCoding)byteArrayView->valueCoding();
59 
60  // encode
61  QTextStream textStream( device );
62 
63  Okteta::ValueCodec* valueCodec = Okteta::ValueCodec::createCodec( mSettings.valueCoding );
64 
65  // prepare
66  QString valueString;
67  valueString.resize( valueCodec->encodingWidth() );
68 
69  for( Okteta::Address i=range.start(); i<=range.end(); ++i )
70  {
71  if( i > range.start() )
72  textStream << mSettings.separation;
73 
74  valueCodec->encode( valueString, 0, byteArrayModel->byte(i) );
75 
76  textStream << valueString;
77  }
78  // clean up
79  delete valueCodec;
80 
81  return success;
82 }
83 
84 ByteArrayValuesStreamEncoder::~ByteArrayValuesStreamEncoder() {}
85 
86 }
Kasten2::ValuesStreamEncoderSettings::ValuesStreamEncoderSettings
ValuesStreamEncoderSettings()
Definition: bytearrayvaluesstreamencoder.cpp:39
Okteta::Address
qint32 Address
Definition: address.h:34
Okteta::AbstractByteArrayModel
could it be useful to hide the data access behind an iterator? * class KDataBufferIterator { public: ...
Definition: abstractbytearraymodel.h:79
Okteta::ValueCodec::createCodec
static ValueCodec * createCodec(ValueCoding valueCoding)
Definition: valuecodec.cpp:36
Kasten2::ValuesStreamEncoderSettings::substituteChar
QChar substituteChar
Definition: bytearrayvaluesstreamencoder.h:45
abstractbytearraymodel.h
Kasten2::ByteArrayValuesStreamEncoder::mSettings
ValuesStreamEncoderSettings mSettings
Definition: bytearrayvaluesstreamencoder.h:68
Kasten2::ValuesStreamEncoderSettings::undefinedChar
QChar undefinedChar
Definition: bytearrayvaluesstreamencoder.h:44
Kasten2::ByteArrayView::valueCoding
int valueCoding() const
Definition: bytearrayview.cpp:250
Kasten2::ValuesStreamEncoderSettings::separation
QString separation
Definition: bytearrayvaluesstreamencoder.h:43
KDE::NumberRange< Address, Size >
KDE::Range::start
T start() const
Definition: range.h:86
Kasten2::AbstractByteArrayStreamEncoder
Definition: abstractbytearraystreamencoder.h:45
Kasten2::ByteArrayValuesStreamEncoder::encodeDataToStream
virtual bool encodeDataToStream(QIODevice *device, const ByteArrayView *byteArrayView, const Okteta::AbstractByteArrayModel *byteArrayModel, const Okteta::AddressRange &range)
Definition: bytearrayvaluesstreamencoder.cpp:48
bytearrayvaluesstreamencoder.h
KDE::Range::end
T end() const
Definition: range.h:88
Okteta::ValueCodec
Class that is able to convert codings to and from hexadecimal, decimal, octal, and binary...
Definition: valuecodec.h:45
valuecodec.h
Okteta::AbstractByteArrayModel::byte
virtual Byte byte(Address offset) const =0
locates working range The idea behind is to tell buffer which range will be requested in the followin...
Kasten2::ByteArrayValuesStreamEncoder::ByteArrayValuesStreamEncoder
ByteArrayValuesStreamEncoder()
Definition: bytearrayvaluesstreamencoder.cpp:43
Kasten2::ByteArrayView::undefinedChar
QChar undefinedChar() const
Definition: bytearrayview.cpp:373
Kasten2::ByteArrayView::substituteChar
QChar substituteChar() const
Definition: bytearrayview.cpp:369
Kasten2::ByteArrayValuesStreamEncoder::~ByteArrayValuesStreamEncoder
virtual ~ByteArrayValuesStreamEncoder()
Definition: bytearrayvaluesstreamencoder.cpp:84
Okteta::ValueCoding
ValueCoding
Definition: oktetacore.h:34
Okteta::ValueCodec::encodingWidth
virtual unsigned int encodingWidth() const =0
QIODevice
Kasten2::ValuesStreamEncoderSettings::valueCoding
Okteta::ValueCoding valueCoding
Definition: bytearrayvaluesstreamencoder.h:42
Kasten2::ByteArrayView
Definition: bytearrayview.h:51
Okteta::HexadecimalCoding
Definition: oktetacore.h:34
bytearrayview.h
Okteta::ValueCodec::encode
virtual void encode(QString &digits, unsigned int pos, Byte byte) const =0
Encodes the byte using full coding width, prefixing with 0s if needed, and writes the result to digit...
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