Space Fighter
A "shmup" game for Computer Programming C++
Loading...
Searching...
No Matches
Resource.cpp
Go to the documentation of this file.
1
2/*
3 ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
4 ██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
5 █████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
6 ██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
7 ██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
8 ╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
9 /vvvvvvvvvvvvvvvvvvv \=========================================,
10 `^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
11 Katana Engine \/ © 2012 - Shuriken Studios LLC
12 http://www.shurikenstudios.com
13*/
14
15#include "KatanaEngine.h"
16
17namespace KatanaEngine
18{
19 void Resource::Split(const std::string &line, const char delimeter, std::vector<std::string> &elements)
20 {
21 if (line.empty()) return;
22
23 elements.clear();
24
25 std::stringstream ss(line);
26 std::string element;
27
28 while (std::getline(ss, element, delimeter))
29 {
30 elements.push_back(element);
31 }
32 }
33
34 void Resource::ParseComments(std::string &line)
35 {
36 if (line.empty()) return;
37
38 std::size_t position = line.find("//");
39 if (position == std::string::npos) return;
40
41 line = line.substr(0, position);
42
43 TrimLine(line);
44 }
45
46 void Resource::TrimLine(std::string &line)
47 {
48 if (line.empty()) return;
49
50 std::size_t pos;
51
52 pos = line.find_first_not_of(" \t");
53 if (pos != std::string::npos) line = line.substr(pos);
54
55 pos = line.find_last_not_of(" \t");
56 if (pos != std::string::npos) line = line.substr(0, pos + 1);
57 }
58}
void Split(const std::string &line, const char delimeter, std::vector< std::string > &elements)
Splits a string into a vector of strings.
Definition Resource.cpp:19
void TrimLine(std::string &line)
Removes white-space at the front and end of a line of text.
Definition Resource.cpp:46
void ParseComments(std::string &line)
Removes c-style, single-line comments from a line of text.
Definition Resource.cpp:34
Katana Engine is a library of classes, interfaces, and value types that provides a foundation for dev...
Definition Animation.cpp:18