Merge pull request #81 from Douwanna/release/2.4

Update notes.
This commit is contained in:
FrankLee 2020-05-25 23:28:12 +08:00 committed by GitHub
commit 590dae2272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 121 additions and 1 deletions

View File

@ -28,6 +28,7 @@ namespace tars
/**
* @file tc_consistent_hash.h
* @brief hash算法类.
* @brief Consistency hash algorithm class.
*/
/////////////////////////////////////////////////
@ -35,11 +36,13 @@ struct node_T
{
/**
*hash值
*node hash value
*/
unsigned int iHashCode;
/**
*
*node subscript
*/
unsigned int iIndex;
};
@ -48,6 +51,7 @@ struct node_T
/**
* @brief hash算法类
* @brief Consistency hash algorithm class.
*/
class TC_ConsistentHash
{
@ -55,6 +59,7 @@ class TC_ConsistentHash
/**
* @brief
* @brief Constructor
*/
TC_ConsistentHash()
{
@ -62,10 +67,14 @@ class TC_ConsistentHash
/**
* @brief .
* @brief Node comparison.
*
* @param m1 node_T类型的对象
* @param m1 node_T type object, one of the compared nodes
* @param m2 node_T类型的对象
* @param m2 node_T type object, one of the compared nodes
* @return less or not less返回turefalse
* @return less or not. The result. If the result is 'less', returns true, else returns false.
*/
static bool less_hash(const node_T & m1, const node_T & m2)
{
@ -74,10 +83,14 @@ class TC_ConsistentHash
/**
* @brief .
* @brief the added node
*
* @param node
* @param node node name
* @param index
* @param index the node subscript
* @return hash值
* @return node hash value
*/
unsigned addNode(const string & node, unsigned int index)
{
@ -93,9 +106,12 @@ class TC_ConsistentHash
/**
* @brief .
* @brief Delete the node.
*
* @param node
* @param node node name
* @return 0 : -1 :
* @return 0 : delete successfully -1 : no corresponding nodes
*/
int removeNode(const string & node)
{
@ -114,10 +130,14 @@ class TC_ConsistentHash
/**
* @brief key对应到的节点node的下标.
* @brief Get the node subscript which corresponds to a certain key.
*
* @param key key名称
* @param key key name
* @param iIndex
* @param iIndex the corresponding node subscript
* @return 0: -1:
* @return 0:obtain successfully -1:no added nodes
*/
int getIndex(const string & key, unsigned int & iIndex)
{
@ -156,9 +176,12 @@ class TC_ConsistentHash
protected:
/**
* @brief md5值的hash 0 -- 2^32-1.
* @brief Calculate the hash of the MD5 value, and the distribution range is 0--2^32-1.
*
* @param sMd5 md5值
* @param sNd5 md5 value
* @return hash值
* @return hash value
*/
unsigned int hash_md5(const string & sMd5)
{

View File

@ -34,6 +34,7 @@ enum TC_HashAlgorithmType
/**
* @brief hash
* @brief hash Algorithmic Virtual Base Class
*/
class TC_HashAlgorithm : public TC_HandleBase
{
@ -50,6 +51,7 @@ typedef TC_AutoPtr<TC_HashAlgorithm> TC_HashAlgorithmPtr;
/**
* @brief ketama hash
* @brief Ketama Hash Algorithm
*/
class TC_KetamaHashAlg : public TC_HashAlgorithm
{
@ -60,6 +62,7 @@ public:
/**
* @brief hash
* @brief Default Hash Algorithm
*/
class TC_DefaultHashAlg : public TC_HashAlgorithm
{
@ -70,6 +73,7 @@ public:
/**
* @brief hash alg
* @brief Hash Algorithm Factory
*/
class TC_HashAlgFactory
{
@ -79,6 +83,7 @@ public:
/**
* @brief hash算法类
* @brief Consistency Hash Algorithm Class
*/
class TC_ConsistentHashNew
{
@ -88,76 +93,99 @@ public:
{
/**
*hash值
*node hash value
*/
int32_t iHashCode;
/**
*
* node subscript
*/
unsigned int iIndex;
};
/**
* @brief
* @brief Constructor
*/
TC_ConsistentHashNew();
/**
* @brief
* @brief Constructor
*/
TC_ConsistentHashNew(TC_HashAlgorithmType hashType);
/**
* @brief
* @brief Sort
*
* @param node
* @param node node name
* @param index
* @param index node subscript value
*/
void sortNode();
/**
* @brief
* @brief print node info
*
*/
void printNode();
/**
* @brief .
* @brief add nodes
*
* @param node
* @param node node name
* @param index
* @param index node subscript value
* @param weight 1
* @param weight node weight, default value is 1
* @return
* @return whether it is successfull or not
*/
int addNode(const string & node, unsigned int index, int weight = 1);
/**
* @brief key对应到的节点node的下标.
* @brief Gets the subscript of the node to which a key corresponds.
*
* @param key key名称
* @param key key name
* @param iIndex
* @param iIndex the subscript of the node to which corresponds.
* @return 0: -1:
* @return 0:obtain successfully -1:no nodes added
*/
int getIndex(const string & key, unsigned int & iIndex);
/**
* @brief hashcode对应到的节点node的下标.
* @brief Gets the subscript of the node to which a certain hashcode corresponds
*
* @param hashcode hashcode
* @param iIndex
* @param iIndex the subscript of the node to which corresponds
* @return 0: -1:
* @return 0:obtain successfully -1:no nodes added
*/
int getIndex(int32_t hashcode, unsigned int & iIndex);
/**
* @brief hash列表的长度.
* @brief Get the length of the current hash list
*
* @return
* @return length
*/
size_t size() { return _vHashList.size(); }
/**
* @brief hash列表.
* @brief Empty the current hash list.
*
*/
void clear() { _vHashList.clear(); }

View File

@ -43,10 +43,14 @@ public:
public:
/**
* @brief cron对象
* @brief Create a cron object
* @return cron
* @return cron object
*/
// 字段分别为 <seconds> <minutes> <hours> <days of month> <months> <days of week>
// The fields are: <seconds> <minutes> <hours> <days of month> <months> <days of week>
// 通配符以及含义
// Wildcards and their meanings:
// * all values selects all values within a field
// - range specify ranges
// , comma specify additional values
@ -54,6 +58,7 @@ public:
// DAYS = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
// MONTHS = { "NIL", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };
// 各类例子
// Examples:
// CRON Description
// * * * * * * Every second
// */5 * * * * * Every 5 seconds
@ -69,15 +74,21 @@ public:
/**
* @brief cron对象的下一个时间点
* @brief Get the next point in time for the cron object
* @param cron
* @param cron object
* @return INVALID_TIME
* @return If INVALID_TIME is returned, it is the wrong time. Otherwise the correct timestamp is returned.
*/
static std::time_t nextcron( const TC_Cron& cron, std::time_t timestamp);
/**
* @brief cron对象的下一个时间点
* @brief Get the next point in time for the cron object.
* @param cron
* @param cron object
* @return INVALID_TIME
* @return If INVALID_TIME is returned, it is the wrong time. Otherwise the correct timestamp is returned.
*/
static std::time_t nextcron(const TC_Cron& cron);
@ -117,18 +128,22 @@ public:
protected:
/**
* @brief
* @brief Determine whether it includes characters.
* @return true ;false
* @return true include; false not include
*/
static bool contains(const std::string &text, char ch) ;
/**
* @brief crontab合法数字
* @brief Convert to crontab legal number
* @return cron_int
*/
static cron_int to_cron_int(const std::string& text);
/**
* @brief
* @brief Time format conversion function
*/
static std::time_t tm_to_time(std::tm& tmt);
static std::tm* time_to_tm(std::time_t const* date, std::tm* const out);
@ -136,16 +151,19 @@ protected:
protected:
/**
* @brief /
* @brief Replace week/month characters as Subscripts
*/
static std::string replaceOrdinals(std::string text, const std::vector<std::string> & replacement);
/**
* @brief
* @brief Gets the time range for calculating wildcards.
*/
static std::pair<cron_int, cron_int> makeRange(std::string field, cron_int minval, cron_int maxval);
/**
* @brief crontab不同的位置标记
* @brief Set different crontab location tags
*/
template <size_t N>
static void setCronField(std::string value, std::bitset<N>& target, cron_int minval, cron_int maxval);
@ -155,6 +173,7 @@ protected:
/**
* @brief
* @brief Calculate the next timestamp
*/
template <size_t N>
static size_t findNext(const std::bitset<N> & target, std::tm& tmt, unsigned int minimum, unsigned int maximum, unsigned int value,
@ -164,6 +183,7 @@ protected:
/**
* @brief
* @brief Bitmap control function
*/
template <size_t N>
static size_t nextSetbit(const std::bitset<N> & target, size_t minimum, size_t maximum, size_t offset);

View File

@ -13,6 +13,7 @@ namespace tars
/**
* @file tc_des.h
* @brief des加解密类(c代码)
* @brief DES encryption and decryption class (translated to C code)
*
* @author ruanshudong@qq.com
*/
@ -21,6 +22,7 @@ namespace tars
/**
* @brief des异常.
* @brief des exception
*/
struct TC_DES_Exception : public TC_Exception
{
@ -31,24 +33,34 @@ struct TC_DES_Exception : public TC_Exception
/**
* @brief des/3des加密解密源码, .
* @brief Use des/3des to encrypt and decrypt the source code, independent of any library.
*
* d3des.h d3des.c修改完成.
* It is modified by the popular 'd3des.h' and 'd3des.c' on the web.
*
* des加密,8,80x00,8,8.
* des加密,8,80x00,8,8.
* For des encryption, use 8-bit key. If it is less than 8 bits, right complete 0x00. If it is more than 8 bits, only the left 8 bits are valid.
*
* 8,:10x01,20x02,...
* The encrypted content follow 8-bit completion, the completion method is: less 1 bit to complete one 0x01, less 2 bits to complete two 0x02,...
*
* 8,0x08.
* If itself is 8-bit aligned, complete eight '0x08' at the tail.
*
* 3des加解密,:3des-ecb加密方式
* For 3des encryption and decryption, only 3des-ecb encryption is supported;
*
* 24,240x00,24,24;
* For 24-bit key, if it is less than 24 bits, right complete 0x00. If it is more than 24 bits, only the left 24 bits are valid.
*
* 810x01,20x02,...
* The encrypted content follow 8-bit completion, the completion method is: less 1 bit to complete one 0x01, less 2 bits to complete two 0x02,...
*
* 80x08.
* If itself is 8-bit aligned, complete eight '0x08' at the tail.
*
* Key必须是null结束的字符串.
* The key must be a null-terminated string.
*
*/
class TC_Des
@ -56,82 +68,117 @@ class TC_Des
public:
/**
* @brief des加密.
* @brief des encryption
*
* @param key key, 8
* @param key key, 8 bits
* @param sIn buffer
* @param sIn input buffer
* @param iInLen buffer长度
* @param iInLen input buffer length
* @return string
* @return string, the encrypted content
*/
static string encrypt(const char *key, const char *sIn, size_t iInlen);
/**
* @brief des解密.
* @brief des decryption
*
* @param key key, 8
* @param key key, 8 bits
* @param sIn buffer
* @param sIn input buffer
* @param iInlen buffer长度
* @param iInLen input buffer length
* @return string , ,
* @return string, the decrypted content, if decryption failed, return null.
*/
static string decrypt(const char *key, const char *sIn, size_t iInlen);
/**
* @brief 3des加密.
* @brief 3des encryption
*
* @param key key, 24
* @param key key, 24 bits
* @param sIn buffer
* @param sIn input buffer
* @param iInLen buffer长度
* @param iInLen input buffer length
* @return string
* @return string, the encrypted content
*/
static string encrypt3(const char *key, const char *sIn, size_t iInlen);
/**
* @brief 3des解密.
* @brief 3des decryption
* @param key key, 24
* @param key key, 24 bits
* @param sIn buffer
* @param sIn input buffer
* @param iInlen buffer长度
* @param iInLen input buffer length
* @return string解码后的内容, ,
* @return string, the dcrypted content, if decryption failed, return null.
*/
static string decrypt3(const char *key, const char *sIn, size_t iInlen);
/**
* @brief / .
* @brief Define Encryption/Decryption
*/
enum
{
/**Encryption*/
EN0 = 0, /**加密*/
/**Decryption*/
DE1 = 1 /**解密*/
};
protected:
/**
* @brief key.
* @brief Get key.
*
* @param key key值
* @param key key value
* @param mode 0, 1
* @param mode mode : 0(encryption), 1(decryption)
*/
static void deskey(const char *key, short mode, uint32_t *k);
/**
* @brief des加密/.
* @brief DES Encryption/Decryption
*
* @param from 8
* @param from 8 bits
* @param to 8
* @param to encrypt and decrypt the only 8 bits.
*/
static void des(const char *from, char *to, uint32_t *KnL);
/**
* @brief key.
* @brief Get key.
*
* @param key key值
* @param key key value
* @param mode 0, 1
* @param mode mode : 0(encryption), 1(decryption)
*/
static void des3key(const char *key, short mode, uint32_t *KnL, uint32_t *KnR, uint32_t *Kn3);
/**
* @brief 3des.
* @brief 3DES
*
* @param from 8
* @param from 8 bits
* @param into 8
* @param to encrypt and decrypt the only 8 bits.
*/
static void des3(const char *from, char *into, uint32_t *KnL, uint32_t *KnR, uint32_t *Kn3);

View File

@ -25,12 +25,14 @@ namespace tars
/**
* @file tc_dyn_object.h
* @brief .
* @brief Dynamic Generation Class.
*/
/////////////////////////////////////////////////
/**
* @brief
* @brief Dynamic Generation Class.
*/
class TC_DYN_Object;
struct TC_DYN_RuntimeClass;