Use std::string instead of manual character buffers where applicable.

This commit is contained in:
Michael Hansen
2019-10-02 16:01:54 -07:00
parent 8d3752b4f0
commit f88869fb17
5 changed files with 45 additions and 78 deletions

View File

@@ -4,25 +4,23 @@
#include "pyc_object.h"
#include "data.h"
#include <cstdio>
#include <string>
class PycString : public PycObject {
public:
PycString(int type = TYPE_STRING)
: PycObject(type), m_value(0), m_length(0) { }
~PycString() { delete[] m_value; }
: PycObject(type) { }
bool isEqual(PycRef<PycObject> obj) const override;
bool isEqual(const char* str) const;
bool isEqual(const std::string& str) const { return m_value == str; }
void load(class PycData* stream, class PycModule* mod) override;
int length() const { return m_length; }
const char* value() const { return m_value; }
int length() const { return (int)m_value.size(); }
const char* value() const { return m_value.c_str(); }
private:
char* m_value;
int m_length;
std::string m_value;
};
void OutputString(PycRef<PycString> str, char prefix = 0,