Skip to content
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

[AD-616] [ODBC] Reformat code to adhere to Google style #31

Merged
merged 6 commits into from
Feb 23, 2022
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
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
BreakBeforeBinaryOperators: NonAssignment
IndentWidth: '4'
IndentWidth: '2'
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'true'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
TabWidth: '4'
TabWidth: '2'
UseTab: 'false'

# See https://zed0.co.uk/clang-format-configurator/ for generating this file.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Development Environment

### C/C++ Formatting

- This project uses [Google's C++ Style Guide](https://google.github.io/styleguide/cppguide.htm) as a basis for
C/C++ usage and formatting.
- Some formatting is set using the .clang-format file at the base of repository. Other options for Visual Studio can be imported from the
`VS-C++-Settings-Export.vssettings` file also found at root of repository.

### Environment Variables for Testing Accounts/Secrets
To enable the test environment to run the tests against a live DocumentDB system, set the following environment variables on your development machine.

Expand Down
244 changes: 244 additions & 0 deletions VS-C++-Settings-Export.vssettings

Large diffs are not rendered by default.

198 changes: 90 additions & 108 deletions src/odbc-test/include/complex_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,115 +22,97 @@

#include "ignite/ignite.h"

namespace ignite
{
struct TestObject
{
TestObject() :
f1(412),
f2("Lorem ipsum")
{
// No-op.
}

friend bool operator==(TestObject const& lhs, TestObject const& rhs)
{
return lhs.f1 == rhs.f1 && lhs.f2 == rhs.f2;
}

friend std::ostream& operator<<(std::ostream& str, TestObject const& obj)
{
str << "TestObject::f1: " << obj.f1
<< "TestObject::f2: " << obj.f2;
return str;
}

int32_t f1;
std::string f2;
};

struct ComplexType
{
ComplexType() :
i32Field(0)
{
// No-op.
}

friend bool operator==(ComplexType const& lhs, ComplexType const& rhs)
{
return lhs.i32Field == rhs.i32Field && lhs.objField == rhs.objField && lhs.strField == rhs.strField;
}

friend std::ostream& operator<<(std::ostream& str, ComplexType const& obj)
{
str << "ComplexType::i32Field: " << obj.i32Field
<< "ComplexType::objField: " << obj.objField
<< "ComplexType::strField: " << obj.strField;
return str;
}

int32_t i32Field;
TestObject objField;
std::string strField;
};
namespace ignite {
struct TestObject {
TestObject() : f1(412), f2("Lorem ipsum") {
// No-op.
}

friend bool operator==(TestObject const& lhs, TestObject const& rhs) {
return lhs.f1 == rhs.f1 && lhs.f2 == rhs.f2;
}

friend std::ostream& operator<<(std::ostream& str, TestObject const& obj) {
str << "TestObject::f1: " << obj.f1 << "TestObject::f2: " << obj.f2;
return str;
}

int32_t f1;
std::string f2;
};

struct ComplexType {
ComplexType() : i32Field(0) {
// No-op.
}

friend bool operator==(ComplexType const& lhs, ComplexType const& rhs) {
return lhs.i32Field == rhs.i32Field && lhs.objField == rhs.objField
&& lhs.strField == rhs.strField;
}

friend std::ostream& operator<<(std::ostream& str, ComplexType const& obj) {
str << "ComplexType::i32Field: " << obj.i32Field
<< "ComplexType::objField: " << obj.objField
<< "ComplexType::strField: " << obj.strField;
return str;
}

int32_t i32Field;
TestObject objField;
std::string strField;
};
} // namespace ignite

namespace ignite {
namespace binary {

IGNITE_BINARY_TYPE_START(ignite::TestObject)

typedef ignite::TestObject TestObject;

IGNITE_BINARY_GET_TYPE_ID_AS_HASH(TestObject)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(TestObject)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
IGNITE_BINARY_IS_NULL_FALSE(TestObject)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestObject)

static void Write(BinaryWriter& writer, const TestObject& obj) {
writer.WriteInt32("f1", obj.f1);
writer.WriteString("f2", obj.f2);
}

namespace ignite
{
namespace binary
{

IGNITE_BINARY_TYPE_START(ignite::TestObject)

typedef ignite::TestObject TestObject;

IGNITE_BINARY_GET_TYPE_ID_AS_HASH(TestObject)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(TestObject)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
IGNITE_BINARY_IS_NULL_FALSE(TestObject)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestObject)

static void Write(BinaryWriter& writer, const TestObject& obj)
{
writer.WriteInt32("f1", obj.f1);
writer.WriteString("f2", obj.f2);
}

static void Read(BinaryReader& reader, TestObject& dst)
{
dst.f1 = reader.ReadInt32("f1");
dst.f2 = reader.ReadString("f2");
}

IGNITE_BINARY_TYPE_END

IGNITE_BINARY_TYPE_START(ignite::ComplexType)

typedef ignite::ComplexType ComplexType;

IGNITE_BINARY_GET_TYPE_ID_AS_HASH(ComplexType)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(ComplexType)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
IGNITE_BINARY_IS_NULL_FALSE(ComplexType)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ComplexType)

static void Write(BinaryWriter& writer, const ComplexType& obj)
{
writer.WriteInt32("i32Field", obj.i32Field);
writer.WriteObject("objField", obj.objField);
writer.WriteString("strField", obj.strField);
}

static void Read(BinaryReader& reader, ComplexType& dst)
{
dst.i32Field = reader.ReadInt32("i32Field");
dst.objField = reader.ReadObject<TestObject>("objField");
dst.strField = reader.ReadString("strField");
}

IGNITE_BINARY_TYPE_END
}
static void Read(BinaryReader& reader, TestObject& dst) {
dst.f1 = reader.ReadInt32("f1");
dst.f2 = reader.ReadString("f2");
}

#endif // _IGNITE_ODBC_TEST_COMPLEX_TYPE
IGNITE_BINARY_TYPE_END

IGNITE_BINARY_TYPE_START(ignite::ComplexType)

typedef ignite::ComplexType ComplexType;

IGNITE_BINARY_GET_TYPE_ID_AS_HASH(ComplexType)
IGNITE_BINARY_GET_TYPE_NAME_AS_IS(ComplexType)
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
IGNITE_BINARY_IS_NULL_FALSE(ComplexType)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ComplexType)

static void Write(BinaryWriter& writer, const ComplexType& obj) {
writer.WriteInt32("i32Field", obj.i32Field);
writer.WriteObject("objField", obj.objField);
writer.WriteString("strField", obj.strField);
}

static void Read(BinaryReader& reader, ComplexType& dst) {
dst.i32Field = reader.ReadInt32("i32Field");
dst.objField = reader.ReadObject< TestObject >("objField");
dst.strField = reader.ReadString("strField");
}

IGNITE_BINARY_TYPE_END
} // namespace binary
} // namespace ignite

#endif // _IGNITE_ODBC_TEST_COMPLEX_TYPE
Loading