mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-14 00:38:15 -05:00
parse struct and union sequences
This commit is contained in:
17
src/ZoneCodeGeneratorLib/Utils/NameUtils.cpp
Normal file
17
src/ZoneCodeGeneratorLib/Utils/NameUtils.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include "NameUtils.h"
|
||||
|
||||
#include <random>
|
||||
#include <sstream>
|
||||
|
||||
std::string NameUtils::GenerateRandomName()
|
||||
{
|
||||
static constexpr auto ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
std::ostringstream str;
|
||||
|
||||
std::random_device random;
|
||||
|
||||
for (auto i = 0u; i < 32u; i++)
|
||||
str << ALPHABET[random() % std::char_traits<char>::length(ALPHABET)];
|
||||
|
||||
return str.str();
|
||||
}
|
9
src/ZoneCodeGeneratorLib/Utils/NameUtils.h
Normal file
9
src/ZoneCodeGeneratorLib/Utils/NameUtils.h
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
class NameUtils
|
||||
{
|
||||
public:
|
||||
static std::string GenerateRandomName();
|
||||
};
|
@ -13,6 +13,11 @@ std::string NamespaceBuilder::Combine(const std::string& _namespace, const std::
|
||||
return str.str();
|
||||
}
|
||||
|
||||
bool NamespaceBuilder::IsEmpty() const
|
||||
{
|
||||
return m_elements.empty();
|
||||
}
|
||||
|
||||
void NamespaceBuilder::Push(std::string element)
|
||||
{
|
||||
m_elements.emplace_back(std::move(element));
|
||||
|
@ -10,6 +10,7 @@ class NamespaceBuilder
|
||||
public:
|
||||
static std::string Combine(const std::string& _namespace, const std::string& name);
|
||||
|
||||
_NODISCARD bool IsEmpty() const;
|
||||
void Push(std::string element);
|
||||
void Pop();
|
||||
std::string ToString();
|
||||
|
Reference in New Issue
Block a user