Skip to content

Fix codestyle #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# git config blame.ignoreRevsFile .git-blame-ignore-revs
# ignore codestyle commits
1a6aebd9d208d77f161b50a74fd0c673c1746e70
2 changes: 1 addition & 1 deletion blobstamper/dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
******************************************************************************/

#include"dict.h"
#include "dict.h"


size_t
Expand Down
8 changes: 4 additions & 4 deletions blobstamper/dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#define DICT_H


#include<string>
#include<vector>
#include <string>
#include <vector>


class DictBase
Expand All @@ -31,10 +31,10 @@ class DictBase
public:
size_t size();
std::string get(size_t n); // FIXME May be it would be good to use operator[] later.
DictBase() {data = {};};
DictBase() { data = {}; };
};

class DictLCAlphaSmall : public DictBase
class DictLCAlphaSmall: public DictBase
{
public:
DictLCAlphaSmall();
Expand Down
2 changes: 1 addition & 1 deletion blobstamper/galley.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ GalleySetBase::minSize()
if (unbounded_count > 1) /* One unbounded stamp will take all data. Nothing to predict */
res += ORACLE_SIZE * unbounded_count;

return res;
return res;
}

int
Expand Down
2 changes: 1 addition & 1 deletion blobstamper/galley.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ GalleyVectorV<T>::ExtractValuesVector(std::shared_ptr<Blob> blob)
std::vector<std::shared_ptr<Blob>> blobs = extract_internal(blob);
std::vector<T> res(blobs.size());

for(int i=0; i<blobs.size(); i++)
for (int i = 0; i < blobs.size(); i++)
{
res[i] = std::dynamic_pointer_cast<StampBaseV<T>>(stamp)->ExtractValue(blobs[i]);
}
Expand Down
2 changes: 1 addition & 1 deletion blobstamper/oracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ OracleProportion(ORACLE_TYPE oracle, size_t min, size_t max)
* хвоста диапазона предсказания не попасть никогда и тогда он не округлиться
* в max + 1*/
size_t delta = max - min + 1;
size_t res = floor(((float) oracle) / ((float) ORACLE_MAX + 1) * delta );
size_t res = floor(((float) oracle) / ((float) ORACLE_MAX + 1) * delta);
return min + res;
}

2 changes: 1 addition & 1 deletion blobstamper/stamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ StampBase::Load(std::shared_ptr<Blob> blob)
{
res_size = maxSize();
if (res_size > blob->Size())
res_size = blob->Size();
res_size = blob->Size();
}
bitten_blob = blob->Chop(res_size);
}
10 changes: 5 additions & 5 deletions blobstamper/stamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class StampBase

void Load(std::shared_ptr<Blob> blob);

bool isFixedSize() {return minSize() == maxSize();}
bool isVariated() {return ! isFixedSize() && ! isUnbounded();}
bool isUnbounded() {return maxSize() == -1;}
bool isFixedSize() { return minSize() == maxSize(); }
bool isVariated() { return !isFixedSize() && !isUnbounded(); }
bool isUnbounded() { return maxSize() == -1; }
virtual bool isRecursive() {return is_recursive;}
};

Expand Down Expand Up @@ -90,8 +90,8 @@ StampBasePV<T>::ExtractBin(std::shared_ptr<Blob> blob)
return v;
}

template<class T> class StampBaseV: public StampBasePV<T>
,public virtual StampBase //FIXME I do not understand why do we need it here, but wihtout it, it does not build
template<class T> class StampBaseV: public StampBasePV<T>,
public virtual StampBase //FIXME I do not understand why do we need it here, but wihtout it, it does not build
{
public:
virtual T ExtractValue(std::shared_ptr<Blob> blob) = 0;/* Should be defined by derived classes*/
Expand Down
8 changes: 4 additions & 4 deletions blobstamper/stamp_dict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
int
StampDict::ChooseStampSize(std::shared_ptr<DictBase> dict)
{
if (dict->size() <= UCHAR_MAX+1)
if (dict->size() <= UCHAR_MAX + 1)
{
stamp_max_value = UCHAR_MAX;
return 1;
}
if (dict->size() <= USHRT_MAX+1)
if (dict->size() <= USHRT_MAX + 1)
{
stamp_max_value = USHRT_MAX;
return 2;
}
if (dict->size() <= UINT_MAX+1)
if (dict->size() <= UINT_MAX + 1)
{
stamp_max_value = UINT_MAX;
return 4;
Expand Down Expand Up @@ -76,6 +76,6 @@ StampDict::ExtractStr(std::shared_ptr<Blob> blob)
exit(1);
}
long long actual_index = ((double) index_oracle) / stamp_max_value * dict->size();
if ( actual_index == dict->size()) actual_index--; /* If we hit the boundary step inside a bit*/
if (actual_index == dict->size()) actual_index--; /* If we hit the boundary step inside a bit*/
return dict->get(actual_index);
}
4 changes: 2 additions & 2 deletions blobstamper/stamp_dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class StampDict: public StampBaseStr
int maxSize() override {return stamp_size;}
};

class StampDictLCAlphaSmall : public StampDict
class StampDictLCAlphaSmall: public StampDict
{
public:
StampDictLCAlphaSmall (): StampDict(std::make_shared<DictLCAlphaSmall>()) {};
StampDictLCAlphaSmall(): StampDict(std::make_shared<DictLCAlphaSmall>()) {};
};


Expand Down
6 changes: 3 additions & 3 deletions blobstamper/stamp_enumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ std::string StampStrEnumerator::ExtractStr(std::shared_ptr<Blob> blob)
std::vector<std::string> data = ExtractStrVector(blob);
std::string res = "";

for(std::string s : data)
for (std::string s : data)
{
if (!res.empty())
{
res+= separator;
res += separator;
}
res+= s;
res += s;
}
res = left_bracket + res + right_bracket;
return res;
Expand Down
8 changes: 4 additions & 4 deletions blobstamper/stamp_enumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
#ifndef STAMP_ENUMERATOR_H
#define STAMP_ENUMERATOR_H

#include"galley.h"
#include"stamp.h"
#include"blob.h"
#include "galley.h"
#include "stamp.h"
#include "blob.h"

#include<string>
#include <string>

class StampStrEnumerator: public GalleyVectorStr, public StampBaseStr
{
Expand Down
12 changes: 6 additions & 6 deletions blobstamper/stamp_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
PoolPickerStamp::PoolPickerStamp(std::vector<std::shared_ptr<StampBaseStr>> new_pool)
: pool{new_pool}
{
for(auto stamp : pool)
for (auto stamp : pool)
{
std::weak_ptr<StampBaseStr> wp = stamp;
weak_pool.push_back(wp);
Expand All @@ -37,10 +37,10 @@ PoolPickerStamp::PoolPickerStamp(std::vector<std::shared_ptr<StampBaseStr>> new_
bool
PoolPickerStamp::isRecursive()
{
if(is_recursive || is_in_recursion)
if (is_recursive || is_in_recursion)
return true;
is_in_recursion = true;
for(auto stamp : weak_pool)
for (auto stamp : weak_pool)
{
if (stamp.lock()->isRecursive())
{
Expand All @@ -62,7 +62,7 @@ PoolPickerStamp::ExtractStr(std::shared_ptr<Blob> blob)
std::vector<std::weak_ptr<StampBaseStr>> target_pool;
std::vector<std::weak_ptr<StampBaseStr>> unbounded_pool;

for(auto stamp_w : weak_pool)
for (auto stamp_w : weak_pool)
{
auto stamp = stamp_w.lock();
if (stamp->minSize() <= blob->Size())
Expand All @@ -75,7 +75,7 @@ PoolPickerStamp::ExtractStr(std::shared_ptr<Blob> blob)
}
}
if (unbounded_pool.size()>0)
target_pool = unbounded_pool;
target_pool = unbounded_pool;

size_t index = OracleProportion(oracle, 0, target_pool.size() - 1);
return target_pool[index].lock()->ExtractStr(blob);
Expand Down Expand Up @@ -111,7 +111,7 @@ PoolPickerStamp::maxSize()
if (is_recursive || is_in_recursion)
return -1;
is_in_recursion = true; /* Do not use isRecursive() inside as it uses same flag*/
for(auto stamp : weak_pool)
for (auto stamp : weak_pool)
{
int candidat = stamp.lock()->maxSize();
if (candidat == -1)
Expand Down
20 changes: 10 additions & 10 deletions blobstamper/stamp_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "stamp_dict.h"
#include "stamp_enumerator.h"

class PoolPickerStamp : public virtual StampBaseStr
class PoolPickerStamp: public virtual StampBaseStr
{
protected:
std::vector<std::shared_ptr<StampBaseStr>> pool;
Expand All @@ -44,15 +44,15 @@ class PoolPickerStamp : public virtual StampBaseStr
virtual int maxSize() override;
};

class StampJSONInt : public virtual StampArithm<long int>
class StampJSONInt: public virtual StampArithm<long int>
{
};

class StampJSONFloat : public virtual StampArithm<double>
class StampJSONFloat: public virtual StampArithm<double>
{
};

class StampJSONString : public virtual StampDictT<DictLCAlphaSmall>
class StampJSONString: public virtual StampDictT<DictLCAlphaSmall>
{
protected:
public:
Expand All @@ -66,8 +66,8 @@ class StampJSONArray: public StampStrEnumerator
{
private:
public:
StampJSONArray(std::shared_ptr<PoolPickerStamp> picker)
:StampStrEnumerator(picker, ", ", "[", "]") {};
StampJSONArray(std::shared_ptr<PoolPickerStamp> picker):
StampStrEnumerator(picker, ", ", "[", "]") {};
};

class StampJSONHashEl: public StampBaseStr
Expand All @@ -76,8 +76,8 @@ class StampJSONHashEl: public StampBaseStr
std::shared_ptr<StampJSONString> stamp_name;
std::shared_ptr<PoolPickerStamp> stamp_value;
public:
StampJSONHashEl(std::shared_ptr<PoolPickerStamp> picker)
:stamp_value(picker), stamp_name(std::make_shared<StampJSONString>()) {};
StampJSONHashEl(std::shared_ptr<PoolPickerStamp> picker):
stamp_value(picker), stamp_name(std::make_shared<StampJSONString>()) {};
virtual int minSize() override {return stamp_name->minSize() + stamp_value->minSize();};
virtual int maxSize() override {return -1;};
std::string ExtractStr(std::shared_ptr<Blob> blob) override;
Expand All @@ -88,8 +88,8 @@ class StampJSONHash: public StampStrEnumerator
private:
std::shared_ptr<StampJSONHashEl> stamp_el;
public:
StampJSONHash(std::shared_ptr<PoolPickerStamp> picker)
:StampStrEnumerator(stamp_el = std::make_shared<StampJSONHashEl>(picker), ", ", "{", "}") {};
StampJSONHash(std::shared_ptr<PoolPickerStamp> picker):
StampStrEnumerator(stamp_el = std::make_shared<StampJSONHashEl>(picker), ", ", "{", "}") {};
};


Expand Down
14 changes: 7 additions & 7 deletions blobstamper/stamp_lottery.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ template<class StampT> bool
StampLottery4Recursion<StampT>::
soft_maxsize_filter(StampT &stamp, int data_size)
{
if ( stamp.isUnbounded() || // Unbounded is always ok
stamp.maxSize() > data_size || // Variated that can consume all data is ok
stamp.minSize() + stamp.maxSize() > data_size // Fixed or variated stamp that lefts less data then it's min size will also do
)
if (stamp.isUnbounded() || // Unbounded is always ok
stamp.maxSize() > data_size || // Variated that can consume all data is ok
stamp.minSize() + stamp.maxSize() > data_size // Fixed or variated stamp that lefts less data then it's min size will also do
)
return true;
return false;
}
Expand All @@ -76,7 +76,7 @@ init_stored_min(std::ref_vector<StampT> stamps_arg)
{
int min = std::numeric_limits<int>::max();

for(StampT & stamp : stamps)
for (StampT & stamp : stamps)
{

if (min > stamp.minSize())
Expand All @@ -91,13 +91,13 @@ init_stored_max(std::ref_vector<StampT> stamps_arg)
{
int max = 0;

for(StampT & stamp : stamps)
for (StampT & stamp : stamps)
{
if (stamp.maxSize() == -1)
return -1;

if (max < stamp.maxSize())
max = stamp.maxSize();
max = stamp.maxSize();
}
return max;
}
Expand Down
2 changes: 1 addition & 1 deletion blobstamper/stamp_math_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ std::string
StampMathBinaryOp::ExtractStr(std::shared_ptr<Blob> blob)
{
std::vector<std::shared_ptr<Blob>> blobs = extract_internal(blob);
return (std::string)"(" + stamp1->ExtractStr(blobs[0]) + " "+ op_name + " " + stamp2->ExtractStr(blobs[1]) + ")";
return (std::string)"(" + stamp1->ExtractStr(blobs[0]) + " " + op_name + " " + stamp2->ExtractStr(blobs[1]) + ")";
}

10 changes: 5 additions & 5 deletions blobstamper/stamp_math_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#ifndef STAMP_MATH_OP_H
#define STAMP_MATH_OP_H

#include"blob.h"
#include"stamp.h"
#include"galley.h"
#include "blob.h"
#include "stamp.h"
#include "galley.h"


class StampMathUnaryOp: public StampBaseStr
Expand All @@ -31,7 +31,7 @@ class StampMathUnaryOp: public StampBaseStr
std::shared_ptr<StampBaseStr> stamp;
public:
virtual std::string ExtractStr(std::shared_ptr<Blob> blob) override;
StampMathUnaryOp(std::string arg_op_name, std::shared_ptr<StampBaseStr> arg_stamp) : op_name(arg_op_name), stamp(arg_stamp) {};
StampMathUnaryOp(std::string arg_op_name, std::shared_ptr<StampBaseStr> arg_stamp): op_name(arg_op_name), stamp(arg_stamp) {};
virtual int maxSize() override {return -1;};
virtual int minSize() override {return stamp->minSize();};
};
Expand All @@ -48,7 +48,7 @@ class StampMathBinaryOp: public StampBaseStr, public GalleySetBase
virtual std::string ExtractStr(std::shared_ptr<Blob> blob) override;
StampMathBinaryOp(std::string arg_op_name,
std::shared_ptr<StampBaseStr> arg_stamp1,
std::shared_ptr<StampBaseStr> arg_stamp2) :
std::shared_ptr<StampBaseStr> arg_stamp2):
GalleySetBase({arg_stamp1, arg_stamp2}),
op_name(arg_op_name),
stamp1(arg_stamp1),
Expand Down
4 changes: 2 additions & 2 deletions blobstamper/stamp_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
******************************************************************************/

#include"stamp_text.h"
#include "stamp_text.h"

std::string
StampTextPulp::ExtractStr(std::shared_ptr<Blob> blob)
Expand All @@ -26,7 +26,7 @@ StampTextPulp::ExtractStr(std::shared_ptr<Blob> blob)
std::vector<char>::iterator the_iterator;

the_iterator = data.begin();
std:: string res;
std::string res;
while (the_iterator != data.end())
{
if (*the_iterator == '\0') { *the_iterator = ' '; }
Expand Down
4 changes: 2 additions & 2 deletions blobstamper/stamp_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
class StampTextPulp: public StampBaseStr
{
public:
virtual int minSize() override {return 1;}
virtual int maxSize() override {return -1;}
virtual int minSize() override { return 1; }
virtual int maxSize() override { return -1; }
std::string ExtractStr(std::shared_ptr<Blob> blob) override;
};

Expand Down