mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-14 00:38:15 -05:00
Add Tests for ZCG cpp
This commit is contained in:
11
src/ZoneCodeGeneratorLib/Utils/AlignmentUtils.h
Normal file
11
src/ZoneCodeGeneratorLib/Utils/AlignmentUtils.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
class AlignmentUtils
|
||||
{
|
||||
public:
|
||||
template<typename T>
|
||||
static T Align(T number, T alignmentValue)
|
||||
{
|
||||
return (number + (alignmentValue - 1)) / alignmentValue * alignmentValue;
|
||||
}
|
||||
};
|
39
src/ZoneCodeGeneratorLib/Utils/NamespaceBuilder.cpp
Normal file
39
src/ZoneCodeGeneratorLib/Utils/NamespaceBuilder.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include "NamespaceBuilder.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
std::string NamespaceBuilder::Combine(const std::string& _namespace, const std::string& name)
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << _namespace << "::" << name;
|
||||
|
||||
return str.str();
|
||||
}
|
||||
|
||||
void NamespaceBuilder::Push(std::string element)
|
||||
{
|
||||
m_elements.emplace_back(std::move(element));
|
||||
}
|
||||
|
||||
void NamespaceBuilder::Pop()
|
||||
{
|
||||
m_elements.pop_back();
|
||||
}
|
||||
|
||||
std::string NamespaceBuilder::ToString()
|
||||
{
|
||||
std::ostringstream str;
|
||||
auto first = true;
|
||||
|
||||
for(const auto& element : m_elements)
|
||||
{
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
str << "::";
|
||||
|
||||
str << element;
|
||||
}
|
||||
|
||||
return str.str();
|
||||
}
|
16
src/ZoneCodeGeneratorLib/Utils/NamespaceBuilder.h
Normal file
16
src/ZoneCodeGeneratorLib/Utils/NamespaceBuilder.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class NamespaceBuilder
|
||||
{
|
||||
std::vector<std::string> m_elements;
|
||||
|
||||
public:
|
||||
static std::string Combine(const std::string& _namespace, const std::string& name);
|
||||
|
||||
void Push(std::string element);
|
||||
void Pop();
|
||||
std::string ToString();
|
||||
};
|
Reference in New Issue
Block a user