/usr/include/okteta1/valuecodec.h is in okteta-dev 4:4.8.4+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | /*
This file is part of the Okteta Core library, made within the KDE community.
Copyright 2003 Friedrich W. H. Kossebau <kossebau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OKTETA_VALUECODEC_H
#define OKTETA_VALUECODEC_H
// lib
#include "oktetacore.h"
#include "oktetacore_export.h"
#include "byte.h"
class QString;
namespace Okteta
{
/** Class that is able to convert codings to and from
* hexadecimal, decimal, octal, and binary.
*
* The buffer will be always filled up to CodingWidth, if not using shortCodingFunction.
*
*@author Friedrich W. H. Kossebau
*/
class OKTETACORE_EXPORT ValueCodec
{
public:
static ValueCodec* createCodec( ValueCoding valueCoding );
public:
virtual ~ValueCodec();
protected:
ValueCodec();
public: // API to be implemented
/**
* @return number of digits the greatest byte gets decoded into
*/
virtual unsigned int encodingWidth() const = 0;
/**
* @return largest value which could get another digit appended and stay below 256.
*/
virtual Byte digitsFilledLimit() const = 0;
/**
* Encodes the byte using full coding width, prefixing with 0s if needed,
* and writes the result to digits
* @param digits string to write the digits into
* @param pos offset in digits where to write the code to
* @param byte data to encode
*/
virtual void encode( QString& digits, unsigned int pos, Byte byte ) const = 0;
// TODO: make this QString* digits
/**
* Encodes the byte and writes the result to digits, no leading 0s.
* @param digits string to write the digits into
* @param pos offset in digits where to write the code to
* @param byte data to encode
*/
virtual void encodeShort( QString& digits, unsigned int pos, Byte byte ) const = 0;
// TODO: make this QString* digits
/**
* Tries to increase the byte value by appending a digit to the digits of
* the current encoding.
* @param digit digit to append to encoding of current value.
* @param pos offset in digits where to write the code to
* @return true if successful, false otherwise
*/
virtual bool appendDigit( Byte* byte, unsigned char digit ) const = 0;
/**
* Tries to remove the last (least significant) digit from byte.
* @param byte value to remove the last digit from
* @return true if successful, false otherwise
*/
virtual void removeLastDigit( Byte* byte ) const = 0;
/**
* Checks if the given digit is used in the encoding.
* @param digit value to check
* @return true if digit is valid, false otherwise
*/
virtual bool isValidDigit( unsigned char digit ) const = 0;
/**
* Turns the digit into a byte with the value of the digit.
* @param digit digit to turn into the value
* @return true if successful, false otherwise
*/
virtual bool turnToValue( unsigned char* digit ) const = 0;
public:
/**
* Tries to decode the digits in the text into a byte.
* @param byte pointer to the variable to store the result in
* @param text string to turn into the value
* @param pos offset in the text to start with decoding
* @return used chars of the string for the decoding, beginning with pos
*/
unsigned int decode( Byte* byte, const QString& text, unsigned int pos = 0 ) const;
};
inline ValueCodec::ValueCodec() {}
}
#endif
|