2014-12-14 23:19:31 +00:00
|
|
|
// Aseprite Code Generator
|
2015-03-05 00:35:11 +00:00
|
|
|
// Copyright (c) 2014, 2015 David Capello
|
2014-12-14 23:19:31 +00:00
|
|
|
//
|
|
|
|
// This file is released under the terms of the MIT license.
|
|
|
|
// Read LICENSE.txt for more information.
|
|
|
|
|
|
|
|
#ifndef GEN_COMMON_H_INCLUDED
|
|
|
|
#define GEN_COMMON_H_INCLUDED
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cctype>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
inline std::string convert_xmlid_to_cppid(const std::string& xmlid, bool firstLetterUpperCase)
|
|
|
|
{
|
|
|
|
bool firstLetter = firstLetterUpperCase;
|
|
|
|
std::string cppid;
|
2015-03-05 00:35:11 +00:00
|
|
|
for (std::size_t i=0; i<xmlid.size(); ++i) {
|
2014-12-14 23:19:31 +00:00
|
|
|
if (xmlid[i] == '_') {
|
|
|
|
firstLetter = true;
|
|
|
|
}
|
|
|
|
else if (firstLetter) {
|
|
|
|
firstLetter = false;
|
|
|
|
cppid += std::toupper(xmlid[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
cppid += xmlid[i];
|
|
|
|
}
|
|
|
|
return cppid;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|