ALIGN_ASSIGN_SPAN
align_assign_span.cpp
// align_assign_span = 0
// 代入式の'='の位置揃えは行わない。
{
float dddd = 4.3f;
double eeeeee = 6.32;
int a = -32;
char bbb = 'a';
long ccc = 12325123423;
unsigned int ff = 23;
unsigned char gggg = 0;
}
// align_assign_span = 1
// 行が連続した代入式の範囲だけ一緒に'='の位置揃えを行う。
{
float dddd = 4.3f; // aligned 1
double eeeeee = 6.32; // aligned 1
int a = -32; // aligned 2
char bbb = 'a'; // aligned 2
long ccc = 12325123423; // aligned 2
unsigned int ff = 23; // aligned 3
unsigned char gggg = 0; // aligned 3
}
// align_assign_span = 2
// 空行が1行開いている代入式でも一緒に'='を位置揃えを行う。
{
float dddd = 4.3f; // aligned 1
double eeeeee = 6.32; // aligned 1
int a = -32; // aligned 1
char bbb = 'a'; // aligned 1
long ccc = 12325123423; // aligned 1
unsigned int ff = 23; // aligned 2
unsigned char gggg = 0; // aligned 2
}
// align_assign_span = 3
// 空行が2行開いている代入式でも一緒に'='を位置揃えを行う。
{
float dddd = 4.3f; // aligned with all
double eeeeee = 6.32; // aligned with all
int a = -32; // aligned with all
char bbb = 'a'; // aligned with all
long ccc = 12325123423; // aligned with all
unsigned int ff = 23; // aligned with all
unsigned char gggg = 0; // aligned withall
}
ALIGN_ASSIGN_THRESH
align_assign_thresh.cpp
// align_assign_thresh = 1 (&& align_assign_span = 1)
// 変数名の長さのカラム差が1文字以下の場合、位置揃えが行われる。
// この例は少しトリッキーだ。なぜ、'gggg'に'bbb'や'ff'が揃えられるのかが分かるだろうか?
{
float dddd = 4.3f;
double eeeeee = 6.32;
int a = -32;
char bbb = 'a';
long ccc = 12325123423;
unsigned int ff = 23;
unsigned char gggg = 0;
}
// aligned_assign_thresh = 4 (&& align_assign_span = 1)
// 変数名の長さのカラム差が4文字以下の場合、位置揃えされる。
// 'eeeeee'(6)と'a'(1)のカラム差は、5文字なので位置が揃わない。
{
float dddd = 4.3f;
double eeeeee = 6.32;
int a = -32;
char bbb = 'a';
long ccc = 12325123423;
unsigned int ff = 23;
unsigned char gggg = 0;
}
ALIGN_ENUM_EQU_SPAN
align_enum_equ_span.cpp
// align_enum_equ_span = 2
// 列挙子定義の式との間に2行の空行があるので、位置揃えが分かれる。
enum MAC_OS_X_NAMME
{
/* unlabeled */
CHEETAH = 1000,
PUMA = 1001,
JAGUAR = 1002,
/* labeled */
PANTHER = 1003,
TIGER = 1004,
LEOPARD = 1005,
SNOW_LEOPARD = 1006,
LION = 1007,
MOUNTAIN_LION = 1008,
};
// align_enum_equ_span = 3
// 列挙子定義の式との間が3行未満なので、すべて位置揃えされる。
enum MAC_OS_X_NAMME
{
/* unlabeled */
CHEETAH = 1000,
PUMA = 1001,
JAGUAR = 1002,
/* labeled */
PANTHER = 1003,
TIGER = 1004,
LEOPARD = 1005,
SNOW_LEOPARD = 1006,
LION = 1007,
MOUNTAIN_LION = 1008,
};
ALIGN_ENUM_EQU_THRESH
align_enum_equ_thresh.cpp
// align_enum_equ_thresh = 3
// 列挙子の定義式の各名前のカラム差が3文字以下の場合、位置揃えが行われる。
enum MAC_OS_X_NAMME
{
/* unlabeled */
CHEETAH = 1000,
PUMA = 1001,
JAGUAR = 1002,
/* labeled */
PANTHER = 1003,
TIGER = 1004,
LEOPARD = 1005,
SNOW_LEOPARD = 1006,
LION = 1007,
MOUNTAIN_LION = 1008,
};
// align_enum_equ_thresh = 2
// 列挙子の定義式の各名前のカラム差が2文字以下の場合、位置揃えが行われる。
enum MAC_OS_X_NAMME
{
/* unlabeled */
CHEETAH = 1000,
PUMA = 1001,
JAGUAR = 1002,
/* labeled */
PANTHER = 1003,
TIGER = 1004,
LEOPARD = 1005,
SNOW_LEOPARD = 1006,
LION = 1007,
MOUNTAIN_LION = 1008,
};
ALIGN_VAR_STRUCT_SPAN
align_var_struct_span.cpp
// align_var_struct_span = 0
// 構造体のメンバ変数定義の位置揃えは行わない。
struct Foo
{
int a;
char bbb;
long ccc;
float dddd;
double eeeeee;
unsigned int ff;
unsigned char gggg;
};
// align_var_struct_span = 1
// 行が連続した構造体のメンバ変数定義の範囲だけ一緒に位置揃えを行う。
struct Foo
{
int a; // aligned 1
char bbb; // aligned 1
long ccc; // aligned 1
float dddd; // aligned 2
double eeeeee; // aligned 2
unsigned int ff; // aligned 3
unsigned char gggg; // aligned 3
};
// align_var_struct_span = 2
// 空行が1行開いている構造体のメンバ変数定義でも一緒に位置揃えを行う。
struct Foo
{
int a; // aligned 1
char bbb; // aligned 1
long ccc; // aligned 1
float dddd; // aligned 1
double eeeeee; // aligned 1
unsigned int ff; // aligned 2
unsigned char gggg; // aligned 2
};
// align_var_struct_span = 3
// 空行が2行開いている構造体のメンバ変数定義でも一緒に位置揃えを行う。
struct Foo
{
int a; // aligned with all
char bbb; // aligned with all
long ccc; // aligned with all
float dddd; // aligned with all
double eeeeee; // aligned with all
unsigned int ff; // aligned with all
unsigned char gggg; // aligned with all
};
ALIGN_VAR_STRUCT_THRESH
align_var_struct_thresh.cpp
// align_var_struct_thresh = 3
// double(6文字)とint(3文字)のカラム差(3文字)は位置揃えされるが、
// long(4文字)とunsigned char(13文字)のカラム差(9文字)は位置揃えされない。
struct Foo
{
float dddd;
double eeeeee;
int a;
char bbb;
long ccc;
unsigned int ff;
unsigned char gggg;
};
// align_var_struct_thresh = 2
// floatとdouble、intとcharとlong、unsigned intとunsigned charは揃えられるが、
// doubleとint、longとunsigned charは位置揃えされない。
struct Foo
{
float dddd;
double eeeeee;
int a;
char bbb;
long ccc;
unsigned int ff;
unsigned char gggg;
};
ALIGN_STRUCT_INIT_SPAN
align_struct_init_span.cpp
// align_struct_init_span = 1
// 構造体メンバの指定初期化の位置揃えが行われる。
// なお、align_assign_xxxが優先されるような感じがする。
{
struct Foo foo = {
.m_long = 41,
.m_int = -32,
.m_unsigned_long_long = 134123432,
.m_double = -3.251,
.m_float = 3.2f
};
}
// align_struct_init_span = 0
// 構造体メンバの指定初期化は位置揃えされない。
{
struct Foo foo = {
.m_long = 41,
.m_int = -32,
.m_unsigned_long_long = 134123432,
.m_double = -3.251,
.m_float = 3.2f
};
}
ALIGN_TYPEDEF_GAP
align_typedef_gap.cpp
// align_typedef_gap = 10
// 型と変数名の間に最低で半角空白10個分のスペースが挿入される。
typedef int myInt;
typedef double myDouble;
typedef unsigned long long myULongLong;
ALIGN_TYPEDEF_SPAN
align_typedef_span.cpp
// align_typedef_span = 2
// 途中にコメントがあるがラインスパンが2行になっているので、それぞれの型定義が位置揃えされる。
/** myInt is .... */
typedef int myInt;
/** myDouble is ... */
typedef double myDouble;
/** myULongLong is ... */
typedef unsigned long long myULongLong;
ALIGN_TYPEDEF_FUNC
align_typedef_func.cpp
// 関数ポインタ型については、他の型定義とは位置揃えされない。
// align_typedef_func = 0
typedef int myInt;
typedef double myDouble;
typedef unsigned long long myULongLong;
typedef int (*MyFunc)(int, float);
// align_typedef_func = 1
// 関数ポインタ型は'*'を含めて、他の型シノニムと位置揃えされる。
typedef int myInt;
typedef double myDouble;
typedef unsigned long long myULongLong;
typedef int (*MyFunc)(int, float);
// align_typedef_func = 2
// 関数ポインタ型は'*'は、型の方にへ寄せられ、型シノニムだけが位置揃えされる。
typedef int myInt;
typedef double myDouble;
typedef unsigned long long myULongLong;
typedef int (* MyFunc)(int, float);
ALIGN_TYPEDEF_STAR_STYLE
align_typedef_star_style.cpp
// align_typedef_star_style = 0
// ポインタ型の'*'は、型の方へ寄せられる。
typedef int integer;
typedef void* pointer;
typedef int* ipointer;
typedef short* spointer;
typedef double* dpointer;
// align_typedef_star_style = 1
// ポインタ型の'*'は、型シノニムの方へ寄せられる。
typedef int integer;
typedef void *pointer;
typedef int *ipointer;
typedef short *spointer;
typedef double *dpointer;
// align_typedef_star_style = 2
// ポインタ型の'*'は、型シノニムの方へ寄せられ、さらにダングリングされる。
typedef int integer;
typedef void *pointer;
typedef int *ipointer;
typedef short *spointer;
typedef double *dpointer;
ALIGN_TYPEDEF_AMP_STYLE
align_typedef_amp_style.cpp
// align_typedef_amp_style = 0
// 参照型の'&'は、型の方へ寄せられる。
typedef int integer;
typedef void& pointer;
typedef int& ipointer;
typedef short& spointer;
typedef double& dpointer;
// align_typedef_amp_style = 1
// 参照型の'&'は、型シノニムの方へ寄せられる。
typedef int integer;
typedef void &pointer;
typedef int &ipointer;
typedef short &spointer;
typedef double &dpointer;
// align_typedef_amp_style = 2
// 参照型の'&'は、型シノニムの方へ寄せられ、さらにダングリングされる。
typedef int integer;
typedef void &pointer;
typedef int &ipointer;
typedef short &spointer;
typedef double &dpointer;
ALIGN_RIGHT_CMT_SPAN
align_right_cmt_span.cpp
// align_right_cmt_span = 1
// 本当は行末コメントが位置揃えされるはずなのに。。。位置合わせされない。どうして???
{
const int WIDTH = 1024; // screen width
const int HEIGHT = 768; // screen height
const int DEPTH = 24; // color depth
}
// align_right_cmt_span = 2
// ラインスパンを2行にすると、位置揃えが行われる。他のラインスパンと仕様が異なる。
{
const int WIDTH = 1024; // screen width
const int HEIGHT = 768; // screen height
const int DEPTH = 24; // color depth
}
ALIGN_RIGHT_CMT_MIX
align_right_cmt_mix.cpp
// これがtrueのときにどんな効果がおこるのか分からねー
ALIGN_RIGHT_CMT_GAP
align_right_cmt_gap.cpp
// align_right_cmt_gap = 5
// 行末コメントとコードの末尾とのギャップカラムが1文字しかないので、揃えられない。
{
const int WIDTH = 1024; // screen width
const int HEIGHT = 768; // screen height
const int DEPTH = 24; // color depth
}
// 行末コメントとコードの末尾とのギャップカラムが5文字以上あるので、位置揃えが行われる。
{
const int WIDTH = 1024; // screen width
const int HEIGHT = 768; // screen height
const int DEPTH = 24; // color depth
}
ALIGN_RIGHT_CMT_AT_COL
align_right_cmt_at_col.cpp
// align_right_cmt_at_col = 48
// 行末コメントが48カラム目から位置揃えされる。
{
const int WIDTH = 1024; // screen width
const int HEIGHT = 768; // screen height
const int DEPTH = 24; // bitdepth
}
ALIGN_FUNC_PROTO_SPAN
align_func_proto_span.cpp
// align_func_proto_span = 0
// 特に位置揃えは行われない。
char func1(char param1, char param2);
short func2(short param1, short param2);
int func3(int param1, int param2);
double func4(double param1, double param2);
// align_func_proto_span = 1
// 返値のところと関数名の間が位置揃えされる。
char func1(char param1, char param2);
short func2(short param1, short param2);
int func3(int param1, int param2);
double func4(double param1, double param2);
ALIGN_FUNC_PROTO_GAP
align_func_proto_gap.cpp
// align_func_proto_gap = 4
// カラムギャップが4となるので、double(最もカラムが多いトークン)から半角空白4個のスペースを入れて位置揃えされる。
char func1(char param1, char param2);
short func2(short param1, short param2);
int func3(int param1, int param2);
double func4(double param1, double param2);
ALIGN_ON_OPERATOR
align_on_operator.cpp
// align_on_operator = true
// 'operator'キーワードで位置揃えがされる。
class Foo
{
Foo*();
type1 operator=(const type1& rhs);
type12 operator+(const type12& rhs);
type123 operator-(const type123& rhs);
type1234 operator*(const type1234& rhs);
};
// align_on_operator = false
// 'operator'の次の演算子トークンで位置揃えされる。
class Foo
{
Foo*();
type1 operator =(const type1& rhs);
type12 operator +(const type12& rhs);
type123 operator -(const type123& rhs);
type1234 operator*(const type1234& rhs);
};
ALIGN_MIX_VAR_PROTO
align_mix_var_proto.cpp
// align_mix_var_proto = true
// 変数宣言と関数プロトタイプ宣言を一緒に位置揃えをする。
const char var1;
const short var2;
const int var3;
char func1(void);
short func2(void);
int func3(void);
// align_mix_var_proto = false
// 変数宣言と関数プロトタイプ宣言はそれぞれ別々に位置揃えする。
const char var1;
const short var2;
const int var3;
char func1(void);
short func2(void);
int func3(void);
ALIGN_SINGLE_LINE_FUNC
align_single_line_func.cpp
// align_single_line_func = true
// func1からfunc6までが位置揃えされる。
// nl_func_leave_one_linersをtrueが必要なり。
char func1(char param) { return '0'; };
short func2(short param) { return 32000; };
int func3(int param) { return 1235123; };
long func4(long param) { return 125123; };
float func5(float param) { return 0.0f; };
double func6(double param) { return 0.0; };
ALIGN_SINGLE_LINE_BRACE
align_single_line_brace.cpp
// align_single_line_brace = true
// func1からfunc6までの'{'が位置揃えされる。
// nl_func_leave_one_linersをtrueが必要なり。
char func1(char param) { return '0'; };
short func2(short param) { return 32000; };
int func3(int param) { return 1235123; };
long func4(long param) { return 125123; };
float func5(float param) { return 0.0f; };
double func6(double param) { return 0.0; };
ALIGN_SINGLE_LINE_BRACE_GAP
align_single_line_brace_gap.cpp
// align_single_line_brace_gap = 10
// 関数プロトタイプと'{'のカラムギャップが10カラムになる。
char func1(char param) { return '0'; };
char func1(char param) { return '0'; };
short func2(short param) { return 32000; };
int func3(int param) { return 1235123; };
long func4(long param) { return 125123; };
float func5(float param) { return 0.0f; };
double func6(double param) { return 0.0; };
ALIGN_NL_CONT
align_nl_cont.cpp
// align_nl_cont = true
// マクロの改行の'\'を位置揃えしてくれる。
# define MACRO(a) do { \
int i = 1; \
int j = 3; \
a = a * i; \
a = a * j; \
} while (0)
ALIGN_PP_DEFINE_SPAN
align_pp_define_span.cpp
// align_pp_define_span = 2
// 空行があっても一応位置揃えされる。ラインスパンが3行だから。
# define FOO 1
# define BAR 2
# define VERSION 3
// align_pp_define_span = 0
// 位置揃えされない
# define FOO 1
# define BAR 2
# define VERSION 3
ALIGN_PP_DEFINE_GAP
align_pp_define_gap.cpp
// align_pp_define_gap = 4
// カラムギャップが4なので、VERSIONのあと半角空白4個分に位置揃えされる。
# define FOO 1
# define BAR 2
# define VERSION 3
ALIGN_PP_DEFINE_TOGETHER
align_pp_define_together.cpp
// align_pp_define_together = false
// 定数マクロと関数マクロはそれぞれ別に位置揃えされる。
# define FOO 1
# define BAR 2
# define VERSION 3
# define MULTIPLY_ADD(a, b, c) ((a) * (b) + (c))
// align_pp_define_together = true
// 定数マクロと関数マクロを一緒に位置揃えする。
# define FOO 1
# define BAR 2
# define VERSION 3
# define MULTIPLY_ADD(a, b, c) ((a) * (b) + (c))
ALIGN_LEFT_SHIFT
align_left_shift.cpp
// align_left_shift = true
// 改行直後の行頭の'<<'の位置を前の行の'<<'の位置に揃える。
{
cout << "hello world."
<< " My name is "
<< "Daichi "
<< "Furusaka.";
}
// align_left_shift = false
// 特に揃えない。
{
cout << "hello world."
<< " My name is "
<< "Daichi "
<< "Furusaka.";
}