Alien-XGBoost
view release on metacpan or search on metacpan
xgboost/dmlc-core/src/io/s3_filesys.cc view on Meta::CPAN
// Copyright by Contributors
extern "C" {
#include <errno.h>
#include <curl/curl.h>
#include <curl/curl.h>
#include <openssl/hmac.h>
#include <openssl/md5.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>
}
#include <dmlc/io.h>
#include <dmlc/logging.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <ctime>
#include <sstream>
#include "./s3_filesys.h"
namespace dmlc {
namespace io {
/*! \brief namespace for helper utils */
namespace s3 {
// simple XML parser
struct XMLIter {
// content of xml
const char *content_;
// end of content
const char *cend_;
XMLIter()
: content_(NULL), cend_(NULL) {
}
// constructor
explicit XMLIter(const char *content)
: content_(content) {
cend_ = content_ + strlen(content_);
}
/*! \brief convert to string */
inline std::string str(void) const {
if (content_ >= cend_) return std::string("");
return std::string(content_, cend_ - content_);
}
/*!
* \brief get next value of corresponding key in xml string
* \param key the key in xml field
* \param value the return value if success
* \return if the get is success
*/
inline bool GetNext(const char *key,
XMLIter *value) {
std::string begin = std::string("<") + key +">";
std::string end = std::string("</") + key +">";
const char *pbegin = strstr(content_, begin.c_str());
if (pbegin == NULL || pbegin > cend_) return false;
content_ = pbegin + begin.size();
const char *pend = strstr(content_, end.c_str());
CHECK(pend != NULL) << "bad xml format";
value->content_ = content_;
value->cend_ = pend;
content_ = pend + end.size();
return true;
}
};
/*!
* \brief return a base64 encodes string
* \param md the data
( run in 0.903 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )