Browse Source

Remove Str dependency

Daniele Bartolini 13 năm trước cách đây
mục cha
commit
163758890d
5 tập tin đã thay đổi với 38 bổ sung37 xóa
  1. 11 10
      src/Device.cpp
  2. 2 3
      src/Device.h
  3. 3 2
      src/Log.h
  4. 1 2
      src/os/OS.h
  5. 21 20
      src/os/linux/LinuxOS.cpp

+ 11 - 10
src/Device.cpp

@@ -31,6 +31,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "OS.h"
 #include "Renderer.h"
 #include "Types.h"
+#include "String.h"
 #include <cstdlib>
 
 namespace crown
@@ -45,12 +46,12 @@ Device::Device() :
 	mPreferredWindowWidth(1000),
 	mPreferredWindowHeight(625),
 	mPreferredWindowFullscreen(false),
-	mPreferredRootPath(Str::EMPTY),
-	mPreferredUserPath(Str::EMPTY),
 	mIsInit(false),
 	mIsRunning(false),
 	mRenderer(NULL)
 {
+	string::strcpy(mPreferredRootPath, string::EMPTY);
+	string::strcpy(mPreferredUserPath, string::EMPTY);
 }
 
 //-----------------------------------------------------------------------------
@@ -76,7 +77,7 @@ bool Device::Init(int argc, char** argv)
 	}
 
 	// Sets the root path
-	GetFilesystem()->Init(mPreferredRootPath.c_str(), mPreferredUserPath.c_str());
+	// GetFilesystem()->Init(mPreferredRootPath.c_str(), mPreferredUserPath.c_str());
 
 	// Creates the main window
 	if (!os::create_render_window(0, 0, mPreferredWindowWidth, mPreferredWindowHeight, mPreferredWindowFullscreen))
@@ -183,7 +184,7 @@ void Device::Frame()
 //-----------------------------------------------------------------------------
 bool Device::ParseCommandLine(int argc, char** argv)
 {
-	if (argc == 2 && Str::StrCmp(argv[1], "-help") == 0)
+	if (argc == 2 && string::strcmp(argv[1], "-help") == 0)
 	{
 		os::printf("Usage: %s [options]\n", argv[0]);
 		os::printf("Options:\n\n");
@@ -202,31 +203,31 @@ bool Device::ParseCommandLine(int argc, char** argv)
 	int32_t i = 1;
 	while (i < argc)
 	{
-		if (Str::StrCmp(argv[i], "-root-path") == 0)
+		if (string::strcmp(argv[i], "-root-path") == 0)
 		{
 			if (argc < i + 2)
 			{
 				os::printf("%s: error: missing absolute path after `-root-path`\n", argv[0]);
 				return false;
 			}
-			mPreferredRootPath = argv[i + 1];
+			string::strcpy(mPreferredRootPath, argv[i + 1]);
 			// Two arguments crunched
 			i += 2;
 			continue;
 		}
-		if (Str::StrCmp(argv[i], "-user-path") == 0)
+		if (string::strcmp(argv[i], "-user-path") == 0)
 		{
 			if (argc < i + 2)
 			{
 				os::printf("%s: error: missing absolute path after `-user-path`\n", argv[0]);
 				return false;
 			}
-			mPreferredUserPath = argv[i + 1];
+			string::strcpy(mPreferredUserPath, argv[i + 1]);
 			// Two arguments crunched
 			i += 2;
 			continue;
 		}
-		if (Str::StrCmp(argv[i], "-metrics") == 0)
+		if (string::strcmp(argv[i], "-metrics") == 0)
 		{
 			if (argc < i + 3)
 			{
@@ -239,7 +240,7 @@ bool Device::ParseCommandLine(int argc, char** argv)
 			i += 3;
 			continue;
 		}
-		if (Str::StrCmp(argv[i], "-fullscreen") == 0)
+		if (string::strcmp(argv[i], "-fullscreen") == 0)
 		{
 			mPreferredWindowFullscreen = true;
 			// One argument crunched

+ 2 - 3
src/Device.h

@@ -27,7 +27,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "Types.h"
 #include "Config.h"
-#include "Str.h"
 
 namespace crown
 {
@@ -68,8 +67,8 @@ private:
 	int32_t					mPreferredWindowWidth;
 	int32_t					mPreferredWindowHeight;
 	bool					mPreferredWindowFullscreen;
-	Str						mPreferredRootPath;
-	Str						mPreferredUserPath;
+	char					mPreferredRootPath[512];
+	char					mPreferredUserPath[512];
 
 	bool					mIsInit		: 1;
 	bool					mIsRunning	: 1;

+ 3 - 2
src/Log.h

@@ -25,7 +25,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #pragma once
 
-#include "Str.h"
+#include <cstdio>
+#include "Types.h"
 
 namespace crown
 {
@@ -62,7 +63,7 @@ public:
 private:
 
 	static LogLevel		mThreshold;
-	static int32_t			mIndentCount;
+	static int32_t		mIndentCount;
 };
 
 } // namespace crown

+ 1 - 2
src/os/OS.h

@@ -26,7 +26,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Config.h"
-#include "Str.h"
 #include "List.h"
 #include "Types.h"
 
@@ -77,7 +76,7 @@ const char*		get_cwd();						//! Fills ret with the path of the current working
 const char*		get_home();						//! Fills ret with the path of the user home directory
 const char*		get_env(const char* env);		//! Returns the content of the 'env' environment variable or the empty string
 
-bool			ls(const char* path, List<Str>& fileList);	//! Returns the list of filenames in a directory.
+//bool			ls(const char* path, List<Str>& fileList);	//! Returns the list of filenames in a directory.
 
 //-----------------------------------------------------------------------------
 void			init_os();

+ 21 - 20
src/os/linux/LinuxOS.cpp

@@ -24,6 +24,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include "OS.h"
+#include "String.h"
 #include <cstdio>
 #include <cstdarg>
 #include <sys/stat.h>
@@ -146,7 +147,7 @@ const char* get_cwd()
 	static char cwdBuf[MAX_PATH_LENGTH];
 	if (getcwd(cwdBuf, MAX_PATH_LENGTH) == NULL)
 	{
-		return Str::EMPTY;
+		return string::EMPTY;
 	}
 
 	return cwdBuf;
@@ -160,7 +161,7 @@ const char* get_home()
 
 	if (envHome == NULL)
 	{
-		return Str::EMPTY;
+		return string::EMPTY;
 	}
 
 	return envHome;
@@ -174,34 +175,34 @@ const char* get_env(const char* env)
 
 	if (envDevel == NULL)
 	{
-		return Str::EMPTY;
+		return string::EMPTY;
 	}
 
 	return envDevel;
 }
 
-//-----------------------------------------------------------------------------
-bool ls(const char* path, List<Str>& fileList)
-{
-	DIR *dir;
-	struct dirent *ent;
+////-----------------------------------------------------------------------------
+//bool ls(const char* path, List<Str>& fileList)
+//{
+//	DIR *dir;
+//	struct dirent *ent;
 
-	dir = opendir(path);
+//	dir = opendir(path);
 
-	if (dir == NULL)
-	{
-		return false;
-	}
+//	if (dir == NULL)
+//	{
+//		return false;
+//	}
 
-	while ((ent = readdir (dir)) != NULL)
-	{
-		fileList.push_back(Str(ent->d_name));
-	}
+//	while ((ent = readdir (dir)) != NULL)
+//	{
+//		fileList.push_back(Str(ent->d_name));
+//	}
 
-	closedir (dir);
+//	closedir (dir);
 
-	return true;
-}
+//	return true;
+//}
 
 //-----------------------------------------------------------------------------
 void init_os()