From 8898ad9b25fca6afe2374d293a981db02a83d7e9 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 31 May 2012 14:46:27 +0000 Subject: Committing the documentation to svn to have it accessible online --- .../n_gen_ex_2_content_bundle_8cpp_source.html | 254 +++++++++++++++++++++ 1 file changed, 254 insertions(+) create mode 100644 Doc/doxygen/html/n_gen_ex_2_content_bundle_8cpp_source.html (limited to 'Doc/doxygen/html/n_gen_ex_2_content_bundle_8cpp_source.html') diff --git a/Doc/doxygen/html/n_gen_ex_2_content_bundle_8cpp_source.html b/Doc/doxygen/html/n_gen_ex_2_content_bundle_8cpp_source.html new file mode 100644 index 0000000..9e21bd9 --- /dev/null +++ b/Doc/doxygen/html/n_gen_ex_2_content_bundle_8cpp_source.html @@ -0,0 +1,254 @@ + + + + + +Starshatter_Open: D:/SRC/StarshatterSVN/nGenEx/ContentBundle.cpp Source File + + + + + + + + + + + + + +
+
+ + + + + + +
+
Starshatter_Open +
+
Open source Starshatter engine
+
+
+ + + + + +
+
+ +
+
+
+ +
+ + + + +
+ +
+ +
+
+
ContentBundle.cpp
+
+
+Go to the documentation of this file.
1 /* Project nGenEx
+
2  Destroyer Studios LLC
+
3  Copyright © 1997-2006. All Rights Reserved.
+
4 
+
5  SUBSYSTEM: nGenEx.lib
+
6  FILE: ContentBundle.cpp
+
7  AUTHOR: John DiCamillo
+
8 
+
9 
+
10  OVERVIEW
+
11  ========
+
12  Chained collection of localized strings
+
13 */
+
14 
+
15 #include "MemDebug.h"
+
16 #include "ContentBundle.h"
+
17 #include "DataLoader.h"
+
18 
+
19 void Print(const char* fmt, ...);
+
20 
+
21 // +--------------------------------------------------------------------+
+
22 
+
23 ContentBundle::ContentBundle(const char* bundle, Locale* locale)
+
24 {
+
25  Text file = FindFile(bundle, locale);
+
26  if (file.length() > 0) {
+
27  LoadBundle(file);
+
28  }
+
29 }
+
30 
+
31 // +--------------------------------------------------------------------+
+
32 
+ +
34 {
+
35 }
+
36 
+
37 // +--------------------------------------------------------------------+
+
38 
+
39 Text
+
40 ContentBundle::GetText(const char* key) const
+
41 {
+
42  return values.find(key, Text(key));
+
43 }
+
44 
+
45 // +--------------------------------------------------------------------+
+
46 
+
47 Text
+
48 ContentBundle::FindFile(const char* bundle, Locale* locale)
+
49 {
+
50  Text result;
+
51  Text basename = Text(bundle);
+ +
53 
+
54  if (loader && bundle) {
+
55  if (locale) {
+
56  result = basename + locale->GetFullCode() + ".txt";
+
57 
+
58  if (loader->FindFile(result))
+
59  return result;
+
60 
+
61  result = basename + "_" + locale->GetLanguage() + ".txt";
+
62 
+
63  if (loader->FindFile(result))
+
64  return result;
+
65  }
+
66 
+
67  result = basename + ".txt";
+
68 
+
69  if (loader->FindFile(result))
+
70  return result;
+
71  }
+
72 
+
73  return Text();
+
74 }
+
75 
+
76 // +--------------------------------------------------------------------+
+
77 
+
78 void
+
79 ContentBundle::LoadBundle(const char* filename)
+
80 {
+ +
82  if (loader && filename && *filename) {
+
83  BYTE* buffer = 0;
+
84  loader->LoadBuffer(filename, buffer, true, true);
+
85  if (buffer && *buffer) {
+
86  char key[1024];
+
87  char val[2048];
+
88  char* p = (char*) buffer;
+
89  int s = 0, ik = 0, iv = 0;
+
90 
+
91  key[0] = 0;
+
92  val[0] = 0;
+
93 
+
94  while (*p) {
+
95  if (*p == '=') {
+
96  s = 1;
+
97  }
+
98  else if (*p == '\n' || *p == '\r') {
+
99  if (key[0] && val[0])
+
100  values.insert(Text(key).trim(), Text(val).trim());
+
101 
+
102  ZeroMemory(key, 1024);
+
103  ZeroMemory(val, 2048);
+
104  s = 0;
+
105  ik = 0;
+
106  iv = 0;
+
107  }
+
108  else if (s == 0) {
+
109  if (!key[0]) {
+
110  if (*p == '#') {
+
111  s = -1; // comment
+
112  }
+
113  else if (!isspace(*p)) {
+
114  key[ik++] = *p;
+
115  }
+
116  }
+
117  else {
+
118  key[ik++] = *p;
+
119  }
+
120  }
+
121  else if (s == 1) {
+
122  if (!isspace(*p)) {
+
123  s = 2;
+
124  val[iv++] = *p;
+
125  }
+
126  }
+
127  else if (s == 2) {
+
128  val[iv++] = *p;
+
129  }
+
130 
+
131  p++;
+
132  }
+
133 
+
134  loader->ReleaseBuffer(buffer);
+
135  }
+
136  }
+
137 }
+
+
+ + + + -- cgit v1.1