forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.h
More file actions
32 lines (28 loc) · 718 Bytes
/
common.h
File metadata and controls
32 lines (28 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Aseprite Code Generator
// Copyright (c) 2014, 2015 David Capello
//
// 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;
for (std::size_t i=0; i<xmlid.size(); ++i) {
if (xmlid[i] == '_') {
firstLetter = true;
}
else if (firstLetter) {
firstLetter = false;
cppid += std::toupper(xmlid[i]);
}
else
cppid += xmlid[i];
}
return cppid;
}
#endif