mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
Reformat the world
This commit is contained in:
parent
194cb24547
commit
b2f171ec69
714 changed files with 35149 additions and 35203 deletions
|
@ -2,15 +2,15 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "zeek/zeek-config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace zeek {
|
||||
namespace zeek
|
||||
{
|
||||
|
||||
// Forward declaration, for helper functions that convert (sub)string vectors
|
||||
// to and from policy-level representations.
|
||||
|
@ -25,7 +25,8 @@ typedef u_char* byte_vec;
|
|||
* methods for rendering byte data into character strings, including
|
||||
* conversions of non-printable characters into other representations.
|
||||
*/
|
||||
class String {
|
||||
class String
|
||||
{
|
||||
public:
|
||||
typedef std::vector<String*> Vec;
|
||||
typedef Vec::iterator VecIt;
|
||||
|
@ -50,15 +51,15 @@ public:
|
|||
String(bool arg_final_NUL, byte_vec str, int arg_n);
|
||||
|
||||
String();
|
||||
~String() { Reset(); }
|
||||
~String() { Reset(); }
|
||||
|
||||
const String& operator=(const String& bs);
|
||||
bool operator==(const String& bs) const;
|
||||
bool operator<(const String& bs) const;
|
||||
bool operator==(std::string_view s) const;
|
||||
|
||||
byte_vec Bytes() const { return b; }
|
||||
int Len() const { return n; }
|
||||
byte_vec Bytes() const { return b; }
|
||||
int Len() const { return n; }
|
||||
|
||||
// Releases the string's current contents, if any, and
|
||||
// adopts the byte vector of given length. The string will
|
||||
|
@ -70,13 +71,12 @@ public:
|
|||
// current contents, if any, and then set the string's
|
||||
// contents to a copy of the string given by the arguments.
|
||||
//
|
||||
void Set(const u_char* str, int len, bool add_NUL=true);
|
||||
void Set(const u_char* str, int len, bool add_NUL = true);
|
||||
void Set(const char* str);
|
||||
void Set(const std::string& str);
|
||||
void Set(const String &str);
|
||||
void Set(const String& str);
|
||||
|
||||
void SetUseFreeToDelete(int use_it)
|
||||
{ use_free_to_delete = use_it; }
|
||||
void SetUseFreeToDelete(int use_it) { use_free_to_delete = use_it; }
|
||||
|
||||
/**
|
||||
* Returns a character-string representation of the stored bytes. This
|
||||
|
@ -87,21 +87,22 @@ public:
|
|||
*/
|
||||
const char* CheckString() const;
|
||||
|
||||
enum render_style {
|
||||
enum render_style
|
||||
{
|
||||
ESC_NONE = 0,
|
||||
ESC_ESC = (1 << 1), // '\' -> "\\"
|
||||
ESC_QUOT = (1 << 2), // '"' -> "\"", ''' -> "\'"
|
||||
ESC_HEX = (1 << 3), // Not in [32, 126]? -> "\xXX"
|
||||
ESC_DOT = (1 << 4), // Not in [32, 126]? -> "."
|
||||
ESC_ESC = (1 << 1), // '\' -> "\\"
|
||||
ESC_QUOT = (1 << 2), // '"' -> "\"", ''' -> "\'"
|
||||
ESC_HEX = (1 << 3), // Not in [32, 126]? -> "\xXX"
|
||||
ESC_DOT = (1 << 4), // Not in [32, 126]? -> "."
|
||||
|
||||
// For serialization: '<string len> <string>'
|
||||
ESC_SER = (1 << 7),
|
||||
};
|
||||
ESC_SER = (1 << 7),
|
||||
};
|
||||
|
||||
static constexpr int EXPANDED_STRING = // the original style
|
||||
static constexpr int EXPANDED_STRING = // the original style
|
||||
ESC_HEX;
|
||||
|
||||
static constexpr int BRO_STRING_LITERAL = // as in a Bro string literal
|
||||
static constexpr int BRO_STRING_LITERAL = // as in a Bro string literal
|
||||
ESC_ESC | ESC_QUOT | ESC_HEX;
|
||||
|
||||
// Renders a string into a newly allocated character array that
|
||||
|
@ -130,8 +131,9 @@ public:
|
|||
// XXX and to_upper; the latter doesn't use String::ToUpper().
|
||||
void ToUpper();
|
||||
|
||||
[[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See GHI-572.")]]
|
||||
unsigned int MemoryAllocation() const;
|
||||
[[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See "
|
||||
"GHI-572.")]] unsigned int
|
||||
MemoryAllocation() const;
|
||||
|
||||
// Returns new string containing the substring of this string,
|
||||
// starting at @start >= 0 for going up to @length elements,
|
||||
|
@ -162,22 +164,23 @@ protected:
|
|||
|
||||
byte_vec b;
|
||||
int n;
|
||||
bool final_NUL; // whether we have added a final NUL
|
||||
bool use_free_to_delete; // free() vs. operator delete
|
||||
};
|
||||
bool final_NUL; // whether we have added a final NUL
|
||||
bool use_free_to_delete; // free() vs. operator delete
|
||||
};
|
||||
|
||||
// A comparison class that sorts pointers to String's according to
|
||||
// the length of the pointed-to strings. Sort order can be specified
|
||||
// through the constructor.
|
||||
//
|
||||
class StringLenCmp {
|
||||
class StringLenCmp
|
||||
{
|
||||
public:
|
||||
explicit StringLenCmp(bool increasing = true) { _increasing = increasing; }
|
||||
bool operator()(String*const& bst1, String*const& bst2);
|
||||
bool operator()(String* const& bst1, String* const& bst2);
|
||||
|
||||
private:
|
||||
private:
|
||||
unsigned int _increasing;
|
||||
};
|
||||
};
|
||||
|
||||
// Default output stream operator, using rendering mode EXPANDED_STRING.
|
||||
std::ostream& operator<<(std::ostream& os, const String& bs);
|
||||
|
@ -192,14 +195,15 @@ extern int Bstr_cmp(const String* s1, const String* s2);
|
|||
//
|
||||
// "BroConstString" might be a better name here.
|
||||
|
||||
struct data_chunk_t {
|
||||
struct data_chunk_t
|
||||
{
|
||||
int length;
|
||||
const char* data;
|
||||
};
|
||||
};
|
||||
|
||||
extern String* concatenate(std::vector<data_chunk_t>& v);
|
||||
extern String* concatenate(String::Vec& v);
|
||||
extern String* concatenate(String::CVec& v);
|
||||
extern void delete_strings(std::vector<const String*>& v);
|
||||
|
||||
} // namespace zeek
|
||||
} // namespace zeek
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue