Files

42 lines
1.1 KiB
C
Raw Permalink Normal View History

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>
#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)
: PycObject(type) { }
2009-07-24 08:35:21 +00:00
bool isEqual(PycRef<PycObject> obj) const override;
bool isEqual(const std::string& str) const { return m_value == str; }
2009-07-24 21:15:51 +00:00
bool startsWith(const std::string& str) const
{
return m_value.substr(0, str.size()) == str;
}
void load(class PycData* stream, class PycModule* mod) override;
2009-07-24 08:35:21 +00:00
int length() const { return (int)m_value.size(); }
const char* value() const { return m_value.c_str(); }
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
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:
std::string m_value;
2009-07-24 08:35:21 +00:00
};
#endif