mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-05 05:17:47 +08:00
46 lines
871 B
C++
46 lines
871 B
C++
/*
|
|
* arithmetic.h
|
|
*
|
|
* Copyright (c) 2019 hikyuu.org
|
|
*
|
|
* Created on: 2019-7-15
|
|
* Author: fasiondog
|
|
*/
|
|
|
|
#pragma once
|
|
#ifndef HIKYUU_UTILITIES_ARITHMETIC_H
|
|
#define HIKYUU_UTILITIES_ARITHMETIC_H
|
|
|
|
#include <cctype>
|
|
#include <string>
|
|
#include <algorithm>
|
|
|
|
namespace hku {
|
|
|
|
/**
|
|
* @ingroup Utilities
|
|
* @{
|
|
*/
|
|
|
|
/** 转小写字符串 */
|
|
void to_lower(std::string& s);
|
|
|
|
/** 转大写字符串 */
|
|
void to_upper(std::string& s);
|
|
|
|
inline void to_lower(std::string& s) {
|
|
std::transform(s.begin(), s.end(), s.begin(),
|
|
[](unsigned char c){ return std::tolower(c); }
|
|
);
|
|
}
|
|
|
|
inline void to_upper(std::string& s) {
|
|
std::transform(s.begin(), s.end(), s.begin(),
|
|
[](unsigned char c){ return std::toupper(c); }
|
|
);
|
|
}
|
|
|
|
/** @} */
|
|
} /* namespace hku */
|
|
|
|
#endif /* HIKYUU_UTILITIES_ARITHMETIC_H */ |