• 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
  • srec
bytearraysrecstreamencoder.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 BYTEARRAYSRECSTREAMENCODER_H
24 #define BYTEARRAYSRECSTREAMENCODER_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 SRecStreamEncoderSettings
40 {
41  public:
42  enum AddressSizeId { FourBytesId = 0, ThreeBytesId = 1, TwoBytesId = 2 };
43 
44  public:
45  SRecStreamEncoderSettings();
46  public:
47  AddressSizeId addressSizeId;
48 };
49 
50 
51 class ByteArraySRecStreamEncoder : public AbstractByteArrayStreamEncoder
52 {
53  Q_OBJECT
54 
55  private:
56  enum RecordType
57  {
58  BlockHeader=0,
59  DataSequence2B=1,
60  DataSequence3B=2,
61  DataSequence4B=3,
62  RecordCount=5,
63  EndOfBlock4B=7,
64  EndOfBlock3B=8,
65  EndOfBlock2B=9
66  };
67 
68  static const char startCode = 'S';
69 
70  static const int byteCountLineOffset = 0;
71  static const int byteCountLineSize = 1;
72  static const int addressLineOffset = byteCountLineOffset + byteCountLineSize;
73 
74  static const char hexDigits[16];
75 
76  private:
77  static char charOfRecordType( RecordType type );
78  static char hexValueOfNibble( int nibble );
79  static void writeBigEndian( unsigned char* line, quint32 value, int byteSize );
80  static void streamLine( QTextStream& textStream, RecordType recordType,
81  const unsigned char* line );
82  static void streamBlockHeader( QTextStream& textStream, unsigned char* line );
83  static void streamRecordCount( QTextStream& textStream, unsigned char* line,
84  quint16 recordCount );
85  static void streamBlockEnd( QTextStream& textStream, unsigned char* line,
86  RecordType recordType, quint32 startAddress = 0 ); // TODO: make address
87 
88  public:
89  ByteArraySRecStreamEncoder();
90  virtual ~ByteArraySRecStreamEncoder();
91 
92  public:
93  SRecStreamEncoderSettings settings() const;
94  void setSettings( const SRecStreamEncoderSettings& 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  SRecStreamEncoderSettings mSettings;
104 };
105 
106 
107 inline SRecStreamEncoderSettings ByteArraySRecStreamEncoder::settings() const { return mSettings; }
108 inline void ByteArraySRecStreamEncoder::setSettings( const SRecStreamEncoderSettings& settings )
109 {
110  mSettings = settings;
111  emit settingsChanged();
112 }
113 
114 inline char ByteArraySRecStreamEncoder::charOfRecordType( RecordType type )
115 { return (char)('0'+type); }
116 inline char ByteArraySRecStreamEncoder::hexValueOfNibble( int nibble )
117 { return hexDigits[nibble & 0xF]; }
118 
119 inline void ByteArraySRecStreamEncoder::writeBigEndian( unsigned char* line,
120  quint32 value, int byteSize )
121 {
122  while( byteSize > 0 )
123  {
124  --byteSize;
125  line[byteSize] = value;
126  value >>= 8;
127  }
128 }
129 
130 }
131 
132 #endif
Okteta::AbstractByteArrayModel
could it be useful to hide the data access behind an iterator? * class KDataBufferIterator { public: ...
Definition: abstractbytearraymodel.h:79
Kasten2::ByteArraySRecStreamEncoder::setSettings
void setSettings(const SRecStreamEncoderSettings &settings)
Definition: bytearraysrecstreamencoder.h:108
KDE::NumberRange< Address, Size >
Kasten2::SRecStreamEncoderSettings::TwoBytesId
Definition: bytearraysrecstreamencoder.h:42
Kasten2::AbstractByteArrayStreamEncoder
Definition: abstractbytearraystreamencoder.h:45
Kasten2::ByteArraySRecStreamEncoder::~ByteArraySRecStreamEncoder
virtual ~ByteArraySRecStreamEncoder()
Definition: bytearraysrecstreamencoder.cpp:207
Kasten2::SRecStreamEncoderSettings
Definition: bytearraysrecstreamencoder.h:39
oktetacore.h
Kasten2::ByteArraySRecStreamEncoder::encodeDataToStream
virtual bool encodeDataToStream(QIODevice *device, const ByteArrayView *byteArrayView, const Okteta::AbstractByteArrayModel *byteArrayModel, const Okteta::AddressRange &range)
Definition: bytearraysrecstreamencoder.cpp:136
Kasten2::SRecStreamEncoderSettings::addressSizeId
AddressSizeId addressSizeId
Definition: bytearraysrecstreamencoder.h:47
Kasten2::SRecStreamEncoderSettings::FourBytesId
Definition: bytearraysrecstreamencoder.h:42
Kasten2::ByteArraySRecStreamEncoder::ByteArraySRecStreamEncoder
ByteArraySRecStreamEncoder()
Definition: bytearraysrecstreamencoder.cpp:131
Kasten2::ByteArraySRecStreamEncoder
Definition: bytearraysrecstreamencoder.h:51
Kasten2::SRecStreamEncoderSettings::AddressSizeId
AddressSizeId
Definition: bytearraysrecstreamencoder.h:42
Kasten2::SRecStreamEncoderSettings::SRecStreamEncoderSettings
SRecStreamEncoderSettings()
Definition: bytearraysrecstreamencoder.cpp:40
Kasten2::ByteArraySRecStreamEncoder::mSettings
SRecStreamEncoderSettings mSettings
Definition: bytearraysrecstreamencoder.h:103
abstractbytearraystreamencoder.h
Kasten2::AbstractByteArrayStreamEncoder::settingsChanged
void settingsChanged()
QIODevice
Kasten2::ByteArrayView
Definition: bytearrayview.h:51
Kasten2::SRecStreamEncoderSettings::ThreeBytesId
Definition: bytearraysrecstreamencoder.h:42
Kasten2::ByteArraySRecStreamEncoder::settings
SRecStreamEncoderSettings settings() const
Definition: bytearraysrecstreamencoder.h:107
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