Navigation Menu

Skip to content

Commit

Permalink
Run clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeder committed Mar 22, 2014
1 parent e40ed4f commit 9b4db06
Show file tree
Hide file tree
Showing 78 changed files with 22,004 additions and 21,819 deletions.
13 changes: 7 additions & 6 deletions include/yaml-cpp/anchor.h
@@ -1,16 +1,17 @@
#ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66

#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif

#include <cstddef>

namespace YAML
{
typedef std::size_t anchor_t;
const anchor_t NullAnchor = 0;
namespace YAML {
typedef std::size_t anchor_t;
const anchor_t NullAnchor = 0;
}

#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
104 changes: 53 additions & 51 deletions include/yaml-cpp/binary.h
@@ -1,62 +1,64 @@
#ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66

#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif

#include <string>
#include <vector>

namespace YAML
{
std::string EncodeBase64(const unsigned char *data, std::size_t size);
std::vector<unsigned char> DecodeBase64(const std::string& input);
class Binary {
public:
Binary(): m_unownedData(0), m_unownedSize(0) {}
Binary(const unsigned char *data_, std::size_t size_): m_unownedData(data_), m_unownedSize(size_) {}
bool owned() const { return !m_unownedData; }
std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; }
const unsigned char *data() const { return owned() ? &m_data[0] : m_unownedData; }
void swap(std::vector<unsigned char>& rhs) {
if(m_unownedData) {
m_data.swap(rhs);
rhs.clear();
rhs.resize(m_unownedSize);
std::copy(m_unownedData, m_unownedData + m_unownedSize, &rhs[0]);
m_unownedData = 0;
m_unownedSize = 0;
} else {
m_data.swap(rhs);
}
}
bool operator == (const Binary& rhs) const {
const std::size_t s = size();
if(s != rhs.size())
return false;
const unsigned char *d1 = data();
const unsigned char *d2 = rhs.data();
for(std::size_t i=0;i<s;i++) {
if(*d1++ != *d2++)
return false;
}
return true;
}
bool operator != (const Binary& rhs) const {
return !(*this == rhs);
}
private:
std::vector<unsigned char> m_data;
const unsigned char *m_unownedData;
std::size_t m_unownedSize;
};
namespace YAML {
std::string EncodeBase64(const unsigned char *data, std::size_t size);
std::vector<unsigned char> DecodeBase64(const std::string &input);

class Binary {
public:
Binary() : m_unownedData(0), m_unownedSize(0) {}
Binary(const unsigned char *data_, std::size_t size_)
: m_unownedData(data_), m_unownedSize(size_) {}

bool owned() const { return !m_unownedData; }
std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; }
const unsigned char *data() const {
return owned() ? &m_data[0] : m_unownedData;
}

void swap(std::vector<unsigned char> &rhs) {
if (m_unownedData) {
m_data.swap(rhs);
rhs.clear();
rhs.resize(m_unownedSize);
std::copy(m_unownedData, m_unownedData + m_unownedSize, &rhs[0]);
m_unownedData = 0;
m_unownedSize = 0;
} else {
m_data.swap(rhs);
}
}

bool operator==(const Binary &rhs) const {
const std::size_t s = size();
if (s != rhs.size())
return false;
const unsigned char *d1 = data();
const unsigned char *d2 = rhs.data();
for (std::size_t i = 0; i < s; i++) {
if (*d1++ != *d2++)
return false;
}
return true;
}

bool operator!=(const Binary &rhs) const { return !(*this == rhs); }

private:
std::vector<unsigned char> m_data;
const unsigned char *m_unownedData;
std::size_t m_unownedSize;
};
}

#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66
53 changes: 24 additions & 29 deletions include/yaml-cpp/contrib/anchordict.h
@@ -1,42 +1,37 @@
#ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66

#if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#if defined(_MSC_VER) || \
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
#pragma once
#endif

#include <vector>

#include "../anchor.h"

namespace YAML
{
/// AnchorDict
/// . An object that stores and retrieves values correlating to anchor_t
/// values.
/// . Efficient implementation that can make assumptions about how anchor_t
/// values are assigned by the Parser class.
template <class T>
class AnchorDict
{
public:
void Register(anchor_t anchor, T value)
{
if (anchor > m_data.size())
{
m_data.resize(anchor);
}
m_data[anchor - 1] = value;
namespace YAML {
/// AnchorDict
/// . An object that stores and retrieves values correlating to anchor_t
/// values.
/// . Efficient implementation that can make assumptions about how anchor_t
/// values are assigned by the Parser class.
template <class T>
class AnchorDict {
public:
void Register(anchor_t anchor, T value) {
if (anchor > m_data.size()) {
m_data.resize(anchor);
}

T Get(anchor_t anchor) const
{
return m_data[anchor - 1];
}

private:
std::vector<T> m_data;
};
m_data[anchor - 1] = value;
}

T Get(anchor_t anchor) const { return m_data[anchor - 1]; }

private:
std::vector<T> m_data;
};
}

#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66

0 comments on commit 9b4db06

Please sign in to comment.