mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Refactoring: Create class Collection to hold collection properties
This commit is contained in:
51
headers/modsecurity/transaction/collection.h
Normal file
51
headers/modsecurity/transaction/collection.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* ModSecurity, http://www.modsecurity.org/
|
||||
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
|
||||
*
|
||||
* You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* If any of the files related to licensing are missing or if you have any
|
||||
* other questions related to licensing please contact Trustwave Holdings, Inc.
|
||||
* directly using the email address security@modsecurity.org.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HEADERS_MODSECURITY_TRANSACTION_COLLECTION_H_
|
||||
#define HEADERS_MODSECURITY_TRANSACTION_COLLECTION_H_
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef struct Collection_t Collection;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace ModSecurity {
|
||||
|
||||
class Collection : public transaction::Variables {
|
||||
public:
|
||||
Collection(std::string name, std::string key)
|
||||
: m_name(name),
|
||||
m_key(key) { };
|
||||
|
||||
std::string m_name;
|
||||
clock_t m_createTime;
|
||||
bool m_persisted; /* IS_NEW from the old documentation */
|
||||
std::string m_key;
|
||||
clock_t m_lastUpdateTime;
|
||||
double m_timeout;
|
||||
double m_updateCounter;
|
||||
double m_updateRate;
|
||||
};
|
||||
|
||||
} // namespace ModSecurity
|
||||
#endif
|
||||
|
||||
|
||||
#endif // HEADERS_MODSECURITY_TRANSACTION_COLLECTION_H_
|
||||
|
||||
|
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "modsecurity/transaction/variables.h"
|
||||
#include "modsecurity/transaction/variable.h"
|
||||
#include "modsecurity/transaction/collection.h"
|
||||
|
||||
#ifndef HEADERS_MODSECURITY_TRANSACTION_COLLECTIONS_H_
|
||||
#define HEADERS_MODSECURITY_TRANSACTION_COLLECTIONS_H_
|
||||
@@ -42,11 +43,12 @@ namespace ModSecurity {
|
||||
namespace transaction {
|
||||
|
||||
class Collections :
|
||||
public std::unordered_map<std::string, transaction::Variables *> {
|
||||
public std::unordered_map<std::string, Collection *> {
|
||||
public:
|
||||
Collections();
|
||||
~Collections();
|
||||
|
||||
void init(const std::string& name, const std::string& key);
|
||||
void store(std::string key, std::string value);
|
||||
void storeOrUpdateFirst(const std::string& collectionName,
|
||||
const std::string& variableName,
|
||||
@@ -62,7 +64,6 @@ class Collections :
|
||||
std::list<transaction::Variable *> *l);
|
||||
std::list<transaction::Variable *> *resolve(const std::string& var);
|
||||
|
||||
|
||||
/**
|
||||
* This is a special collection to host the transaction variables.
|
||||
*
|
||||
|
Reference in New Issue
Block a user