diff --git a/example/text_io_ex.cpp b/example/text_io_ex.cpp index 3a87f55..91c35cb 100644 --- a/example/text_io_ex.cpp +++ b/example/text_io_ex.cpp @@ -33,9 +33,14 @@ using namespace gctl; int main(int argc, char const *argv[]) try { text_content tc; - tc.load_text("tmp/sample", ".txt", HasColumnName); + tc.set_delimeter('|'); + tc.load_text("tmp/world_data", ".txt", HasColumnName); tc.info(); + _1s_array name; + tc.get_column("Name_s", name); + name.show(std::cout, ','); + /* text_content tc("tmp/topo", ".txt", HasColumnName); diff --git a/lib/io/text_io2.h b/lib/io/text_io2.h index 6d3fc51..ef4c522 100644 --- a/lib/io/text_io2.h +++ b/lib/io/text_io2.h @@ -39,9 +39,14 @@ namespace gctl template T value() { - T out; - str2type(str_, out); - return out; + // 如果输出也是字符串 就直接赋值即可(避免l_str中含有空格会出现bug) + if constexpr (std::is_same::value) return str_; + else + { + T out; + str2type(str_, out); + return out; + } } template void value(const T &in)