2018-08-12 18:07:22 +00:00
|
|
|
#ifndef QPDF_NAME_HH
|
|
|
|
#define QPDF_NAME_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2022-08-02 20:35:04 +00:00
|
|
|
#include <qpdf/QPDFValue.hh>
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2022-08-02 20:35:04 +00:00
|
|
|
class QPDF_Name: public QPDFValue
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2023-06-01 14:21:32 +00:00
|
|
|
~QPDF_Name() override = default;
|
2022-09-08 15:29:23 +00:00
|
|
|
static std::shared_ptr<QPDFObject> create(std::string const& name);
|
2023-06-01 14:21:32 +00:00
|
|
|
std::shared_ptr<QPDFObject> copy(bool shallow = false) override;
|
|
|
|
std::string unparse() override;
|
2024-02-09 13:09:08 +00:00
|
|
|
void writeJSON(int json_version, JSON::Writer& p) override;
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
// Put # into strings with characters unsuitable for name token
|
|
|
|
static std::string normalizeName(std::string const& name);
|
2024-02-10 12:03:28 +00:00
|
|
|
|
|
|
|
// Check whether name is valid utf-8 and whether it contains characters that require escaping.
|
|
|
|
// Return {false, false} if the name is not valid utf-8, otherwise return {true, true} if no
|
|
|
|
// characters require or {true, false} if escaping is required.
|
|
|
|
static std::pair<bool, bool> analyzeJSONEncoding(std::string const& name);
|
2023-06-01 14:21:32 +00:00
|
|
|
std::string
|
|
|
|
getStringValue() const override
|
2022-12-21 13:14:05 +00:00
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
private:
|
2022-06-16 16:45:04 +00:00
|
|
|
QPDF_Name(std::string const& name);
|
2008-04-29 12:55:25 +00:00
|
|
|
std::string name;
|
|
|
|
};
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#endif // QPDF_NAME_HH
|