Reformat the WebRTC code base
Running clang-format with chromium's style guide.
The goal is n-fold:
* providing consistency and readability (that's what code guidelines are for)
* preventing noise with presubmit checks and git cl format
* building on the previous point: making it easier to automatically fix format issues
* you name it
Please consider using git-hyper-blame to ignore this commit.
Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
diff --git a/rtc_base/stringencode.h b/rtc_base/stringencode.h
index e5395b7..7042c4a 100644
--- a/rtc_base/stringencode.h
+++ b/rtc_base/stringencode.h
@@ -24,8 +24,10 @@
//////////////////////////////////////////////////////////////////////
// Note: in-place decoding (buffer == source) is allowed.
-size_t url_decode(char * buffer, size_t buflen,
- const char * source, size_t srclen);
+size_t url_decode(char* buffer,
+ size_t buflen,
+ const char* source,
+ size_t srclen);
// Convert an unsigned value from 0 to 15 to the hex character equivalent...
char hex_encode(unsigned char val);
@@ -33,45 +35,60 @@
bool hex_decode(char ch, unsigned char* val);
// hex_encode shows the hex representation of binary data in ascii.
-size_t hex_encode(char* buffer, size_t buflen,
- const char* source, size_t srclen);
+size_t hex_encode(char* buffer,
+ size_t buflen,
+ const char* source,
+ size_t srclen);
// hex_encode, but separate each byte representation with a delimiter.
// |delimiter| == 0 means no delimiter
// If the buffer is too short, we return 0
-size_t hex_encode_with_delimiter(char* buffer, size_t buflen,
- const char* source, size_t srclen,
+size_t hex_encode_with_delimiter(char* buffer,
+ size_t buflen,
+ const char* source,
+ size_t srclen,
char delimiter);
// Helper functions for hex_encode.
std::string hex_encode(const std::string& str);
std::string hex_encode(const char* source, size_t srclen);
-std::string hex_encode_with_delimiter(const char* source, size_t srclen,
+std::string hex_encode_with_delimiter(const char* source,
+ size_t srclen,
char delimiter);
// hex_decode converts ascii hex to binary.
-size_t hex_decode(char* buffer, size_t buflen,
- const char* source, size_t srclen);
+size_t hex_decode(char* buffer,
+ size_t buflen,
+ const char* source,
+ size_t srclen);
// hex_decode, assuming that there is a delimiter between every byte
// pair.
// |delimiter| == 0 means no delimiter
// If the buffer is too short or the data is invalid, we return 0.
-size_t hex_decode_with_delimiter(char* buffer, size_t buflen,
- const char* source, size_t srclen,
+size_t hex_decode_with_delimiter(char* buffer,
+ size_t buflen,
+ const char* source,
+ size_t srclen,
char delimiter);
// Helper functions for hex_decode.
size_t hex_decode(char* buffer, size_t buflen, const std::string& source);
-size_t hex_decode_with_delimiter(char* buffer, size_t buflen,
- const std::string& source, char delimiter);
+size_t hex_decode_with_delimiter(char* buffer,
+ size_t buflen,
+ const std::string& source,
+ char delimiter);
// Apply any suitable string transform (including the ones above) to an STL
// string. Stack-allocated temporary space is used for the transformation,
// so value and source may refer to the same string.
-typedef size_t (*Transform)(char * buffer, size_t buflen,
- const char * source, size_t srclen);
-size_t transform(std::string& value, size_t maxlen, const std::string& source,
+typedef size_t (*Transform)(char* buffer,
+ size_t buflen,
+ const char* source,
+ size_t srclen);
+size_t transform(std::string& value,
+ size_t maxlen,
+ const std::string& source,
Transform t);
// Return the result of applying transform t to source.
@@ -88,12 +105,14 @@
// Splits the source string into multiple fields separated by delimiter,
// with duplicates of delimiter creating empty fields.
-size_t split(const std::string& source, char delimiter,
+size_t split(const std::string& source,
+ char delimiter,
std::vector<std::string>* fields);
// Splits the source string into multiple fields separated by delimiter,
// with duplicates of delimiter ignored. Trailing delimiter ignored.
-size_t tokenize(const std::string& source, char delimiter,
+size_t tokenize(const std::string& source,
+ char delimiter,
std::vector<std::string>* fields);
// Tokenize, including the empty tokens.
@@ -102,7 +121,8 @@
std::vector<std::string>* fields);
// Tokenize and append the tokens to fields. Return the new size of fields.
-size_t tokenize_append(const std::string& source, char delimiter,
+size_t tokenize_append(const std::string& source,
+ char delimiter,
std::vector<std::string>* fields);
// Splits the source string into multiple fields separated by delimiter, with
@@ -112,8 +132,11 @@
// \"/Library/Application Support/media content.txt\"", delimiter is ' ', and
// the start_mark and end_mark are '"', this method returns two fields:
// "filename" and "/Library/Application Support/media content.txt".
-size_t tokenize(const std::string& source, char delimiter, char start_mark,
- char end_mark, std::vector<std::string>* fields);
+size_t tokenize(const std::string& source,
+ char delimiter,
+ char start_mark,
+ char end_mark,
+ std::vector<std::string>* fields);
// Extract the first token from source as separated by delimiter, with
// duplicates of delimiter ignored. Return false if the delimiter could not be
@@ -126,7 +149,7 @@
// Convert arbitrary values to/from a string.
template <class T>
-static bool ToString(const T &t, std::string* s) {
+static bool ToString(const T& t, std::string* s) {
RTC_DCHECK(s);
std::ostringstream oss;
oss << std::boolalpha << t;
@@ -144,19 +167,25 @@
// Inline versions of the string conversion routines.
-template<typename T>
+template <typename T>
static inline std::string ToString(const T& val) {
- std::string str; ToString(val, &str); return str;
+ std::string str;
+ ToString(val, &str);
+ return str;
}
-template<typename T>
+template <typename T>
static inline T FromString(const std::string& str) {
- T val; FromString(str, &val); return val;
+ T val;
+ FromString(str, &val);
+ return val;
}
-template<typename T>
+template <typename T>
static inline T FromString(const T& defaultValue, const std::string& str) {
- T val(defaultValue); FromString(str, &val); return val;
+ T val(defaultValue);
+ FromString(str, &val);
+ return val;
}
//////////////////////////////////////////////////////////////////////