/usr/include/podofo/base/PdfName.h is in libpodofo-dev 0.9.0-1.2+b2.
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | /***************************************************************************
* Copyright (C) 2006 by Dominik Seichter *
* domseichter@web.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef _PDF_NAME_H_
#define _PDF_NAME_H_
#include "PdfDefines.h"
#include "PdfDataType.h"
namespace PoDoFo {
class PdfOutputDevice;
class PdfName;
//std::size_t hash_value(PdfName const& name);
/** This class represents a PdfName.
* Whenever a key is required you have to use a PdfName object.
*
* PdfName are required as keys in PdfObject and PdfVariant objects.
*
* PdfName may have a maximum length of 127 characters.
*
* \see PdfObject \see PdfVariant
*/
class PODOFO_API PdfName : public PdfDataType {
public:
/** Constructor to create NULL strings.
* use PdfName::KeyNull instead of this constructor
*/
PdfName()
: PdfDataType(), m_Data("")
{
}
/** Create a new PdfName object.
* \param sName the unescaped value of this name. Please specify
* the name without the leading '/'.
*/
PdfName( const std::string& sName )
: PdfDataType(), m_Data(sName)
{
}
/** Create a new PdfName object.
* \param pszName the unescaped value of this name. Please specify
* the name without the leading '/'.
* Has to be a zero terminated string.
*/
PdfName( const char* pszName )
: PdfDataType()
{
if (pszName) m_Data.assign( pszName );
}
/** Create a new PdfName object.
* \param pszName the unescaped value of this name. Please specify
* the name without the leading '/'.
* \param lLen length of the name
*/
PdfName( const char* pszName, long lLen )
: PdfDataType()
{
if( pszName ) m_Data.assign( pszName, lLen );
}
/** Create a new PdfName object from a string containing an escaped
* name string without the leading / .
*
* \param sName A string containing the escaped name
* \return A new PdfName
*/
static PdfName FromEscaped( const std::string& sName );
/** Create a new PdfName object from a string containing an escaped
* name string without the leading / .
* \param pszName A string containing the escaped name
* \param ilength length of the escaped string data. If a length
* of 0 is passed, the string data is expected to
* be a zero terminated string.
* \return A new PdfName
*/
static PdfName FromEscaped( const char * pszName, pdf_long ilength = 0 );
/** \return an escaped representation of this name
* without the leading / .
*
* There is no corresponding GetEscapedLength(), since
* generating the return value is somewhat expensive.
*/
std::string GetEscapedName() const;
/** Create a copy of an existing PdfName object.
* \param rhs another PdfName object
*/
PdfName( const PdfName & rhs )
: PdfDataType(), m_Data(rhs.m_Data)
{
}
virtual ~PdfName();
/** Write the name to an output device in PDF format.
* This is an overloaded member function.
*
* \param pDevice write the object to this device
* \param eWriteMode additional options for writing this object
* \param pEncrypt an encryption object which is used to encrypt this object
* or NULL to not encrypt this object
*/
void Write( PdfOutputDevice* pDevice, EPdfWriteMode eWriteMode, const PdfEncrypt* pEncrypt = NULL) const;
/** \returns the unescaped value of this name object
* without the leading slash
*/
PODOFO_NOTHROW inline const std::string& GetName() const;
/** \returns the unescaped length of this
* name object
*/
PODOFO_NOTHROW inline size_t GetLength() const;
/** Assign another name to this object
* \param rhs another PdfName object
*/
PODOFO_NOTHROW inline const PdfName& operator=( const PdfName & rhs );
/** compare to PdfName objects.
* \returns true if both PdfNames have the same value.
*/
PODOFO_NOTHROW inline bool operator==( const PdfName & rhs ) const;
/** overloaded operator for convinience
*
* The string argument is treated as an unescaped name.
*
* \param rhs a name
* \returns true if this objects name is equal to pszName
*/
bool operator==( const char* rhs ) const;
/** overloaded operator for convinience
*
* The string argument is treated as an unescaped name.
*
* \param rhs a name
* \returns true if this objects name is equal to pszName
*/
PODOFO_NOTHROW inline bool operator==( const std::string& rhs ) const;
/** compare two PdfName objects.
* \returns true if both PdfNames have different values.
*/
PODOFO_NOTHROW inline bool operator!=( const PdfName & rhs ) const;
/** overloaded operator for convinience
*
* The string argument is treated as an unescaped name.
*
* \param rhs a name
* \returns true if this objects name is not equal to pszName
*/
inline bool operator!=( const char* rhs ) const;
/** compare two PdfName objects.
* Used for sorting in lists
* \returns true if this object is smaller than rhs
*/
PODOFO_NOTHROW inline bool operator<( const PdfName & rhs ) const;
static const PdfName KeyContents;
static const PdfName KeyFlags;
static const PdfName KeyLength;
static const PdfName KeyNull;
static const PdfName KeyRect;
static const PdfName KeySize;
static const PdfName KeySubtype;
static const PdfName KeyType;
static const PdfName KeyFilter;
private:
// The _unescaped_ name, without leading /
std::string m_Data;
};
// -----------------------------------------------------
//
// -----------------------------------------------------
const std::string & PdfName::GetName() const
{
return m_Data;
}
// -----------------------------------------------------
//
// -----------------------------------------------------
size_t PdfName::GetLength() const
{
return m_Data.length();
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfName::operator!=( const PdfName & rhs ) const
{
return !this->operator==( rhs );
}
// -----------------------------------------------------
//
// -----------------------------------------------------
bool PdfName::operator!=( const char* rhs ) const
{
return !this->operator==( rhs );
}
bool PdfName::operator<( const PdfName & rhs ) const
{
return m_Data < rhs.m_Data;
}
bool PdfName::operator==( const PdfName & rhs ) const
{
return ( m_Data == rhs.m_Data );
}
bool PdfName::operator==( const std::string & rhs ) const
{
return ( m_Data == rhs );
}
const PdfName& PdfName::operator=( const PdfName & rhs )
{
m_Data = rhs.m_Data;
return *this;
}
};
#endif /* _PDF_NAME_H_ */
|