add split to string

master
IoTcat 5 years ago
parent 3a09ba398b
commit f81e862202
  1. 22
      src/ovo.cpp
  2. 24
      src/ovo.h

@ -166,8 +166,22 @@ void ovo::file::get_files_info(const string path, const string format, const int
}
/* String class */
void ovo::String::split(const std::string& s, std::vector<std::string>& v, const std::string& c)
{
std::string::size_type pos1, pos2;
pos2 = s.find(c);
pos1 = 0;
while(std::string::npos != pos2){
v.push_back(s.substr(pos1, pos2-pos1));
pos1 = pos2 + c.size();
pos2 = s.find(c, pos1);
}
if(pos1 != s.length()) v.push_back(s.substr(pos1));
}
/****** Class math ******/
@ -1962,7 +1976,7 @@ void ovo::Timer::stop()
* @param string key
* @return void
*/
void ovo::db::pushData(data& data, const string& key){
void ovo::db::pushData(const string& key, data& data){
if(this->_AES) m.aes_ini(key);
this->checkFolder();
@ -1991,7 +2005,7 @@ void ovo::db::pushData(data& data, const string& key){
* @param string key
* @return void
*/
void ovo::db::addData(data& data, const string& key){
void ovo::db::addData(const string& key, data& data){
if(this->_AES) m.aes_ini(key);
this->checkFolder();
@ -2071,7 +2085,7 @@ void ovo::db::classify(const string& key, std::vector<string> v){
d.classify();
if(!v.size()){
this->pushData(d, key);
this->pushData(key, d);
return;
}
@ -2080,7 +2094,7 @@ void ovo::db::classify(const string& key, std::vector<string> v){
d.clear(v[i]);
}
this->pushData(d, key);
this->pushData(key, d);
}

@ -93,6 +93,19 @@ namespace ovo{
void get_all_folders_name(string path, vector<string>& folders);
};
/**
* string tools
*
* @author yimian
* @category ovo
* @package ovo
*/
class String{
public:
void split(const std::string& s, std::vector<std::string>& v, const std::string& c);
};
/**
* Math operation
*
@ -426,9 +439,9 @@ namespace ovo{
/* no-sql */
/* push data to database */
void pushData(data& data, const string& key);
void pushData(const string& key, data& data);
/* add data to database */
void addData(data& data, const string& key);
void addData(const string& key, data& data);
/* get data from database */
data getData(const string& key);
/* classify data in db */
@ -444,10 +457,17 @@ namespace ovo{
/* sql */
void _createTable(const string& tableName, std::vector<string> v){
ovo::data d;
string keysName = "";
for(int i = 0; i < v.size(); i ++){
d[v[i]] = this->generateIndex(v[i]);
}
this->pushData(generateTableName(tableName), d);
};
private:
ovo::math m;
string _path;

Loading…
Cancel
Save