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

[clang-doc] Add another test project to clang-doc #97518

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"directory": "$test_dir/Inputs/advance-project",
"command": "clang++ -o Array.o -I./include ./src/Array.cpp",
"file": "./src/Array.cpp"
},
{
"directory": "$test_dir/Inputs/advance-project",
"command": "clang++ -o Circle.o -I./include ./src/Circle.cpp",
"file": "./src/Circle.cpp"
},
{
"directory": "$test_dir/Inputs/advance-project",
"command": "clang++ -o Shape.o -I./include ./src/Shape.cpp",
"file": "./src/Shape.cpp"
},
{
"directory": "$test_dir/Inputs/advance-project",
"command": "clang++ -o Utils.o -I./include ./src/Utils.cpp",
"file": "./src/Utils.cpp"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

/** @brief Maximum size for the IntArray typedef */
#define MAX_SIZE 100

/**
* @brief Template class for a simple array
*
* @tparam T The type of elements in the array
* @tparam Size The fixed size of the array
*/
template <typename T, int Size>
class Array {
public:
/** @brief Default constructor */
Array();

/**
* @brief Array access operator
*
* @param index The index of the element to access
* @return T& Reference to the element at the given index
*/
T& operator[](int index);

/**
* @brief Get the size of the array
*
* @return int The size of the array
*/
int size() const;

private:
T m_data[Size]; /**< The array data */
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include "Shape.h"
#include "Utils.h"

namespace OuterNamespace {
namespace InnerNamespace {
/**
* @brief Circle class, derived from Shape
*/
class Circle : public Shape {
public:
/**
* @brief Constructor
*
* @param id The unique identifier for the circle
* @param radius The radius of the circle
*/
Circle(int id, double radius);

/**
* @brief Implementation of the draw function
*
* Draws the circle (in this case, prints circle information)
*/
void draw() const override;

private:
double m_radius; /**< The radius of the circle */
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once

/// Outer namespace
namespace OuterNamespace {
/// Inner namespace
namespace InnerNamespace {
/**
* @brief Enum class for colors
*/
enum class Color {
Red, /**< Red color */
Green, /**< Green color */
Blue /**< Blue color */
};

/**
* @brief Abstract base class for shapes
*/
class Shape {
public:
/**
* @brief Constructor
*
* @param id The unique identifier for the shape
*/
explicit Shape(int id);

/**
* @brief Virtual destructor
*/
virtual ~Shape();

/**
* @brief Pure virtual function for drawing the shape
*/
virtual void draw() const = 0;

/**
* @brief Getter for the shape's ID
*
* @return int The shape's ID
*/
int getId() const;

private:
int m_id; /**< The shape's unique identifier */
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#pragma once

/// Anonymous namespace for utility functions
namespace {
/**
* @brief Generate a "random" number
*
* @note This is not actually random in this implementation
*
* @return int A predetermined "random" number
*/
int getRandomNumber();

/**
* @brief Helper function to convert int to string
*
* @param value The integer value to convert
* @param buffer The char buffer to store the result
* @param index Reference to the current index in the buffer
*/
void intToString(int value, char* buffer, int& index);

/**
* @brief Helper function to convert double to string (simplified)
*
* @param value The double value to convert
* @param buffer The char buffer to store the result
* @param index Reference to the current index in the buffer
*/
void doubleToString(double value, char* buffer, int& index);

/**
* @brief Helper function to print a string
*
* @param str The null-terminated string to print
*/
void print(const char* str);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "Array.h"

// Implementation of Array<T, Size>

/**
* Initializes all elements of the array to their default value.
*/
template <typename T, int Size>
Array<T, Size>::Array() {
// Implementation stub
}

/**
* Array access operator for Array<T, Size>
* Provides read and write access to elements in the array.
* This implementation does not perform bounds checking
*/
template <typename T, int Size>
T& Array<T, Size>::operator[](int index) {
// Implementation stub
static T dummy;
return dummy;
PeterChou1 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Get the size of the array for Array<T, Size>
*/
template <typename T, int Size>
int Array<T, Size>::size() const {
return Size;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "Circle.h"

namespace OuterNamespace {
namespace InnerNamespace {

/**
* Initializes a Circle object with a given ID and radius.
*/
Circle::Circle(int id, double radius) : Shape(id), m_radius(radius) {
// Implementation stub
}

/**
* This function is responsible for drawing the circle. In a real
* implementation, this would perform the actual drawing operation.
* In this stub implementation, it simply prints information about
* the circle.
*/
void Circle::draw() const {
// Implementation stub
}

} // namespace InnerNamespace
} // namespace OuterNamespace
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "Shape.h"

namespace OuterNamespace {
namespace InnerNamespace {

/**
* Initializes a Shape object with a given ID.
*/
Shape::Shape(int id) : m_id(id) {
// Implementation stub
}

/**
* Ensures proper cleanup of derived classes.
*/
Shape::~Shape() {
// Implementation stub
}

/**
* Get unique identifier of the shape
*/
int Shape::getId() const {
return m_id;
}

} // namespace InnerNamespace
} // namespace OuterNamespace
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "Utils.h"

namespace {

/**
* This function returns a predetermined number to simulate randomness.
* In a real implementation, this would use a proper random number generator
*/
int getRandomNumber() {
// Implementation stub
return 4;
}

/**
* Converts an integer value to its string representation and stores
* the result in the provided buffer.
*/
void intToString(int value, char* buffer, int& index) {
// Implementation stub
}

/**
* Converts a double value to its string representation with two decimal
* places and stores the result in the provided buffer.
*/
void doubleToString(double value, char* buffer, int& index) {
// Implementation stub
}

/**
* Prints the provided null-terminated string to the standard output.
*/
void print(const char* str) {
// Implementation stub
}

} // anonymous namespace
Loading
Loading