• 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
  • ihex
bytearrayihexstreamencoder.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 2010 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 BYTEARRAYIHEXSTREAMENCODER_H
24 #define BYTEARRAYIHEXSTREAMENCODER_H
25 
26 // lib
27 #include "abstractbytearraystreamencoder.h"
28 // Okteta core
29 #include <oktetacore.h>
30 // Qt
31 #include <QtCore/QString>
32 
33 class QTextStream;
34 
35 
36 namespace Kasten2
37 {
38 
39 class IHexStreamEncoderSettings
40 {
41  public:
42  enum AddressSizeId { Bits32Id = 0, Bits16Id = 1, Bits8Id = 2 };
43 
44  public:
45  IHexStreamEncoderSettings();
46  public:
47  AddressSizeId addressSizeId;
48 };
49 
50 
51 class ByteArrayIHexStreamEncoder : public AbstractByteArrayStreamEncoder
52 {
53  Q_OBJECT
54 
55  private:
56  enum IHexRecordType
57  {
58  DataRecord=0,
59  EndOfFileRecord=1,
60  ExtendedSegmentAddressRecord=2,
61  StartSegmentAddressRecord=3,
62  ExtendedLinearAddressRecord=4,
63  StartLinearAddressRecord=5
64  };
65 
66  static const char startCode = ':';
67 
68  static const int byteCountLineOffset = 0;
69  static const int byteCountLineSize = 1;
70  static const int addressLineOffset = byteCountLineOffset + byteCountLineSize;
71  static const int addressLineSize = 2;
72  static const int recordTypeLineOffset = addressLineOffset + addressLineSize;
73  static const int recordTypeLineSize = 1;
74  static const int dataLineOffset = recordTypeLineOffset + recordTypeLineSize;
75  static const char hexDigits[16];
76  private:
77  static char hexValueOfNibble( int nibble );
78  static void writeBigEndian( unsigned char* line, quint32 value, int byteSize );
79 
80  static void streamLine( QTextStream& textStream, const unsigned char* line );
81  static void streamExtendedSegmentAddress( QTextStream& textStream, unsigned char* line,
82  quint16 upperSegmentBaseAddress );
83  static void streamExtendedLinearAddress( QTextStream& textStream, unsigned char* line,
84  quint16 upperLinearBaseAddress );
85  static void streamEndOfFile( QTextStream& textStream, unsigned char* line,
86  quint16 startAddress = 0 );
87 
88  public:
89  ByteArrayIHexStreamEncoder();
90  virtual ~ByteArrayIHexStreamEncoder();
91 
92  public:
93  IHexStreamEncoderSettings settings() const;
94  void setSettings( const IHexStreamEncoderSettings& settings );
95 
96  protected: // AbstractByteArrayStreamEncoder API
97  virtual bool encodeDataToStream( QIODevice* device,
98  const ByteArrayView* byteArrayView,
99  const Okteta::AbstractByteArrayModel* byteArrayModel,
100  const Okteta::AddressRange& range );
101 
102  protected:
103  IHexStreamEncoderSettings mSettings;
104 };
105 
106 
107 inline IHexStreamEncoderSettings ByteArrayIHexStreamEncoder::settings() const { return mSettings; }
108 inline void ByteArrayIHexStreamEncoder::setSettings( const IHexStreamEncoderSettings& settings )
109 {
110  mSettings = settings;
111  emit settingsChanged();
112 }
113 
114 inline char ByteArrayIHexStreamEncoder::hexValueOfNibble( int nibble )
115 { return hexDigits[nibble & 0xF]; }
116 
117 inline void ByteArrayIHexStreamEncoder::writeBigEndian( unsigned char* line, quint32 value, int byteSize )
118 {
119  while( byteSize > 0 )
120  {
121  --byteSize;
122  line[byteSize] = value;
123  value >>= 8;
124  }
125 }
126 
127 }
128 
129 #endif
Kasten2::IHexStreamEncoderSettings::Bits32Id
Definition: bytearrayihexstreamencoder.h:42
Kasten2::ByteArrayIHexStreamEncoder::~ByteArrayIHexStreamEncoder
virtual ~ByteArrayIHexStreamEncoder()
Definition: bytearrayihexstreamencoder.cpp:210
Okteta::AbstractByteArrayModel
could it be useful to hide the data access behind an iterator? * class KDataBufferIterator { public: ...
Definition: abstractbytearraymodel.h:79
KDE::NumberRange< Address, Size >
Kasten2::ByteArrayIHexStreamEncoder::mSettings
IHexStreamEncoderSettings mSettings
Definition: bytearrayihexstreamencoder.h:103
Kasten2::AbstractByteArrayStreamEncoder
Definition: abstractbytearraystreamencoder.h:45
Kasten2::IHexStreamEncoderSettings::Bits16Id
Definition: bytearrayihexstreamencoder.h:42
Kasten2::IHexStreamEncoderSettings
Definition: bytearrayihexstreamencoder.h:39
Kasten2::IHexStreamEncoderSettings::addressSizeId
AddressSizeId addressSizeId
Definition: bytearrayihexstreamencoder.h:47
Kasten2::ByteArrayIHexStreamEncoder::ByteArrayIHexStreamEncoder
ByteArrayIHexStreamEncoder()
Definition: bytearrayihexstreamencoder.cpp:117
oktetacore.h
Kasten2::IHexStreamEncoderSettings::AddressSizeId
AddressSizeId
Definition: bytearrayihexstreamencoder.h:42
Kasten2::IHexStreamEncoderSettings::IHexStreamEncoderSettings
IHexStreamEncoderSettings()
Definition: bytearrayihexstreamencoder.cpp:40
Kasten2::ByteArrayIHexStreamEncoder
Definition: bytearrayihexstreamencoder.h:51
abstractbytearraystreamencoder.h
Kasten2::ByteArrayIHexStreamEncoder::encodeDataToStream
virtual bool encodeDataToStream(QIODevice *device, const ByteArrayView *byteArrayView, const Okteta::AbstractByteArrayModel *byteArrayModel, const Okteta::AddressRange &range)
Definition: bytearrayihexstreamencoder.cpp:122
Kasten2::AbstractByteArrayStreamEncoder::settingsChanged
void settingsChanged()
QIODevice
Kasten2::ByteArrayView
Definition: bytearrayview.h:51
Kasten2::ByteArrayIHexStreamEncoder::settings
IHexStreamEncoderSettings settings() const
Definition: bytearrayihexstreamencoder.h:107
Kasten2::IHexStreamEncoderSettings::Bits8Id
Definition: bytearrayihexstreamencoder.h:42
Kasten2::ByteArrayIHexStreamEncoder::setSettings
void setSettings(const IHexStreamEncoderSettings &settings)
Definition: bytearrayihexstreamencoder.h:108
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