サポート用関数を実装
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#include "cocoatweet/util/util.h"
|
||||
#include <cctype>
|
||||
|
||||
namespace CocoaTweet::Util{
|
||||
std::string urlEncode(const std::string& _str){
|
||||
std::stringstream out;
|
||||
|
||||
for(const auto c : _str){
|
||||
if(std::isalpha(c) || std::isdigit(c) || (c == '.' || (c == '_') || (c == '-' || (c == '~')))){
|
||||
out << c;
|
||||
}else{
|
||||
out << '%' << std::hex << std::uppercase << static_cast<int>(c);
|
||||
}
|
||||
}
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::string join(const std::vector<T> _vec){}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef COCOATWEET_UTIL_UTIL_H_
|
||||
#define COCOATWEET_UTIL_UTIL_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace CocoaTweet::Util{
|
||||
std::string urlEncode(const std::string& _str);
|
||||
template<typename T>
|
||||
std::string join(const std::vector<T> _vec);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user