2009-07-24 08:35:21 +00:00
|
|
|
#ifndef _PYC_STRING_H
|
|
|
|
#define _PYC_STRING_H
|
|
|
|
|
2011-10-23 17:48:10 -07:00
|
|
|
#include "pyc_object.h"
|
2011-10-23 19:33:24 -07:00
|
|
|
#include "data.h"
|
2009-07-24 19:52:47 +00:00
|
|
|
#include <cstdio>
|
2019-10-02 16:01:54 -07:00
|
|
|
#include <string>
|
2009-07-24 19:52:47 +00:00
|
|
|
|
2009-07-24 08:35:21 +00:00
|
|
|
class PycString : public PycObject {
|
|
|
|
public:
|
|
|
|
PycString(int type = TYPE_STRING)
|
2019-10-02 16:01:54 -07:00
|
|
|
: PycObject(type) { }
|
2009-07-24 08:35:21 +00:00
|
|
|
|
2019-10-02 14:40:25 -07:00
|
|
|
bool isEqual(PycRef<PycObject> obj) const override;
|
2019-10-02 16:01:54 -07:00
|
|
|
bool isEqual(const std::string& str) const { return m_value == str; }
|
2009-07-24 21:15:51 +00:00
|
|
|
|
2019-10-10 14:47:48 -07:00
|
|
|
bool startsWith(const std::string& str) const
|
|
|
|
{
|
|
|
|
return m_value.substr(0, str.size()) == str;
|
|
|
|
}
|
|
|
|
|
2019-10-02 14:40:25 -07:00
|
|
|
void load(class PycData* stream, class PycModule* mod) override;
|
2009-07-24 08:35:21 +00:00
|
|
|
|
2019-10-02 16:01:54 -07:00
|
|
|
int length() const { return (int)m_value.size(); }
|
|
|
|
const char* value() const { return m_value.c_str(); }
|
2019-10-10 14:47:48 -07:00
|
|
|
const std::string &strValue() const { return m_value; }
|
|
|
|
|
|
|
|
void setValue(std::string str) { m_value = std::move(str); }
|
2009-07-24 08:35:21 +00:00
|
|
|
|
2023-06-09 09:09:03 -07:00
|
|
|
void print(std::ostream& stream, class PycModule* mod, bool triple = false,
|
|
|
|
const char* parent_f_string_quote = nullptr);
|
|
|
|
|
2025-03-02 23:48:24 +08:00
|
|
|
void dasPrintAndDecrypt(std::ostream& stream, class PycModule* mod,
|
|
|
|
bool triple = false,
|
|
|
|
const char* parent_f_string_quote = nullptr);
|
|
|
|
|
2009-07-24 08:35:21 +00:00
|
|
|
private:
|
2019-10-02 16:01:54 -07:00
|
|
|
std::string m_value;
|
2009-07-24 08:35:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|