bug fixes on mstring and jstring.
This commit is contained in:
parent
0d60cce8dc
commit
83e9b8ca99
@ -56,17 +56,18 @@ namespace coreutils {
|
||||
friend std::ostream &operator<<(std::ostream &os, const Proxy &proxy);
|
||||
|
||||
operator coreutils::ZString () {
|
||||
// std::cout << "operator to ZString: " << key << std::endl;
|
||||
return jstring.find(key);
|
||||
}
|
||||
|
||||
operator coreutils::MString () {
|
||||
// std::cout << "operator to MString: " << key << std::endl;
|
||||
return jstring.find(key);
|
||||
}
|
||||
|
||||
operator std::string () {
|
||||
return jstring.find(key).str();
|
||||
}
|
||||
|
||||
Proxy& operator=(coreutils::ZString value) {
|
||||
// std::cout << "proxy operator=" << value << std::endl;
|
||||
jstring.set(key, value);
|
||||
return *this;
|
||||
}
|
||||
@ -77,7 +78,6 @@ namespace coreutils {
|
||||
};
|
||||
|
||||
Proxy operator[](coreutils::ZString key) {
|
||||
// std::cout << "operator[" << key << "]" << std::endl;
|
||||
return Proxy(*this, key);
|
||||
}
|
||||
|
||||
|
17
MString.cpp
17
MString.cpp
@ -165,7 +165,8 @@ namespace coreutils {
|
||||
MString &MString::operator<<(const int value) {
|
||||
std::stringstream temp;
|
||||
temp << value;
|
||||
*this << temp.str();
|
||||
MString temp2 = temp.str();
|
||||
write(temp2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -185,13 +186,13 @@ namespace coreutils {
|
||||
return *this;
|
||||
}
|
||||
|
||||
MString &MString::operator<<(std::string value) {
|
||||
int temp = length;
|
||||
int len = length + value.length();
|
||||
setSize(len);
|
||||
memcpy(data + temp, value.c_str(), value.length());
|
||||
return *this;
|
||||
}
|
||||
// MString &MString::operator<<(std::string value) {
|
||||
// int temp = length;
|
||||
// int len = length + value.length();
|
||||
// setSize(len);
|
||||
// memcpy(data + temp, value.c_str(), value.length());
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
// MString &MString::operator<<(std::ostream (*f)(std::ostream&)) {
|
||||
MString &MString::operator<<(std::basic_ostream<char> (*pf)(std::basic_ostream<char>&)) {
|
||||
|
@ -157,7 +157,7 @@ namespace coreutils {
|
||||
///
|
||||
///
|
||||
|
||||
MString &operator<<(std::string value);
|
||||
// MString &operator<<(std::string value);
|
||||
|
||||
///
|
||||
///
|
||||
|
Binary file not shown.
@ -1,5 +1,7 @@
|
||||
#include <iostream>
|
||||
#include "../JString.h"
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
@ -45,6 +47,13 @@ int main(int argc, char **argv) {
|
||||
std::cout << test1["array[1]"] << std::endl;
|
||||
std::cout << test1["array[2]"] << std::endl;
|
||||
|
||||
std::string string1 = test1["tester"];
|
||||
std::cout << "from string: " << string1 << std::endl;
|
||||
|
||||
coreutils::MString testout;
|
||||
testout << "this is a test: " << test1["comment"];
|
||||
std::cout << testout << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user