Skip to content

Commit ef523a2

Browse files
committed
Modified the format for default values of function identifiers.
Header file default value: Input file name (without extension) Identifier default value: Based on input file. Format is "NameExt" For #51 and #58.
1 parent 05fef53 commit ef523a2

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ namespace bin2cpp
196196
virtual bool save(const char * filename) const = 0;
197197
};
198198
#endif //BIN2CPP_EMBEDDEDFILE_CLASS
199-
const File & getHelloworldhtmlFile();
199+
const File & getHelloworldHtmlFile();
200200
}; //bin2cpp
201201

202202
#endif //HELLOWORLD_H
@@ -222,11 +222,11 @@ namespace bin2cpp
222222
#include <fstream> //for ofstream
223223
namespace bin2cpp
224224
{
225-
class HelloworldhtmlFile : public virtual bin2cpp::File
225+
class HelloworldHtmlFile : public virtual bin2cpp::File
226226
{
227227
public:
228-
HelloworldhtmlFile() { build(); }
229-
virtual ~HelloworldhtmlFile() {}
228+
HelloworldHtmlFile() { build(); }
229+
virtual ~HelloworldHtmlFile() {}
230230
virtual size_t getSize() const { return 238; }
231231
virtual const char * getFileName() const { return "helloworld.html"; }
232232
virtual const char * getFilePath() const { return getFileName(); }
@@ -251,7 +251,7 @@ namespace bin2cpp
251251
private:
252252
std::string mBuffer;
253253
};
254-
const File & getHelloworldhtmlFile() { static HelloworldhtmlFile _instance; return _instance; }
254+
const File & getHelloworldHtmlFile() { static HelloworldHtmlFile _instance; return _instance; }
255255
}; //bin2cpp
256256
```
257257

samples/demo_helloworld/demo_helloworld.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
int main(int argc, char* argv[])
88
{
99
//get a reference to the embedded file
10-
const bin2cpp::File & resource = bin2cpp::getHelloworldhtmlFile();
10+
const bin2cpp::File & resource = bin2cpp::getHelloworldHtmlFile();
1111

1212
//print information about the file.
1313
std::cout << "Embedded file '" << resource.getFileName() << "' is " << resource.getSize() << " bytes long.\n";

src/bin2cpp/common.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,12 @@ namespace bin2cpp
157157
{
158158
std::string id;
159159

160-
//get filename of the given path
161-
id = ra::filesystem::GetFilename(path.c_str());
160+
//build default id
161+
std::string name = ra::filesystem::GetFilenameWithoutExtension(path.c_str());
162+
std::string ext = ra::filesystem::GetFileExtention(path.c_str());
163+
name = ra::strings::CapitalizeFirstCharacter(name);
164+
ext = ra::strings::CapitalizeFirstCharacter(ext );
165+
id = name + ext;
162166

163167
//filter out characters which are not alphanumeric characters or '_'.
164168
static const std::string validCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";

test/bin2cpp_unittest/TestExtraction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ TEST_F(TestExtraction, testIssue56a)
562562
std::string output_path1234 = "generated_files/testIssue56a/saved_files/_testIssue56a.index.1234.css";
563563
{
564564
ra::filesystem::NormalizePath(output_path1234);
565-
const issue56a::File & file = issue56a::get_testIssue56aindex1234cssFile();
565+
const issue56a::File & file = issue56a::get_testIssue56aindex1234CssFile();
566566
bool extractSuccess = file.save(output_path1234.c_str());
567567
ASSERT_TRUE(extractSuccess);
568568
}
@@ -571,7 +571,7 @@ TEST_F(TestExtraction, testIssue56a)
571571
std::string output_path4321 = "generated_files/testIssue56a/saved_files/_testIssue56a.index.4321.css";
572572
{
573573
ra::filesystem::NormalizePath(output_path4321);
574-
const issue56a::File & file = issue56a::get_testIssue56aindex4321cssFile();
574+
const issue56a::File & file = issue56a::get_testIssue56aindex4321CssFile();
575575
bool extractSuccess = file.save(output_path4321.c_str());
576576
ASSERT_TRUE(extractSuccess);
577577
}

0 commit comments

Comments
 (0)