diff options
author | tmt <alkaloid.btx@gmail.com> | 2016-01-28 15:58:39 +0100 |
---|---|---|
committer | tmt <alkaloid.btx@gmail.com> | 2016-01-28 23:20:18 +0100 |
commit | 2447c3171ffae5d8ecf34883475907c8b20c2f9c (patch) | |
tree | bcb678fc20819c461bfbbe9c50c8b49db905bb0a /core/os | |
parent | 0c7e7e2c2880565ef3b2d7455e89aee9373b7b8f (diff) |
File: Added delimiter to get_csv_line
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/file_access.cpp | 6 | ||||
-rw-r--r-- | core/os/file_access.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index d82d0b63c5..68c9dee84d 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -277,7 +277,9 @@ String FileAccess::get_line() const { return String::utf8(line.get_data()); } -Vector<String> FileAccess::get_csv_line() const { +Vector<String> FileAccess::get_csv_line(String delim) const { + + ERR_FAIL_COND_V(delim.length()!=1,Vector<String>()); String l; int qc=0; @@ -303,7 +305,7 @@ Vector<String> FileAccess::get_csv_line() const { CharType s[2]={0,0}; - if (!in_quote && c==',') { + if (!in_quote && c==delim[0]) { strings.push_back(current); current=String(); } else if (c=='"') { diff --git a/core/os/file_access.h b/core/os/file_access.h index 51cf839117..3249e21ffb 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -102,7 +102,7 @@ public: virtual int get_buffer(uint8_t *p_dst,int p_length) const; ///< get an array of bytes virtual String get_line() const; - virtual Vector<String> get_csv_line() const; + virtual Vector<String> get_csv_line(String delim=",") const; /**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac) * It's not about the current CPU type but file formats. |