瀏覽代碼

core: new String class.

legacy
Sam Hocevar sam 12 年之前
父節點
當前提交
f2b71d368e
共有 4 個檔案被更改,包括 83 行新增7 行删除
  1. +7
    -6
      src/core.h
  2. +0
    -0
      src/lol/core/array.h
  3. +75
    -0
      src/lol/core/string.h
  4. +1
    -1
      src/lolcore.vcxproj

+ 7
- 6
src/core.h 查看文件

@@ -74,15 +74,16 @@ static inline int isnan(float f)
#endif

// Base types
#include "lol/debug.h"
#include "lol/math/math.h"
#include "lol/math/half.h"
#include "lol/math/real.h"
#include "lol/math/vector.h"
#include <lol/debug.h>
#include <lol/core/array.h>
#include <lol/core/string.h>
#include <lol/math/math.h>
#include <lol/math/half.h>
#include <lol/math/real.h>
#include <lol/math/vector.h>
#include "numeric.h"
#include "timer.h"
#include "thread/thread.h"
#include "array.h"

// Static classes
#include "log.h"


src/array.h → src/lol/core/array.h 查看文件


+ 75
- 0
src/lol/core/string.h 查看文件

@@ -0,0 +1,75 @@
//
// Lol Engine
//
// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the Do What The Fuck You Want To
// Public License, Version 2, as published by Sam Hocevar. See
// http://sam.zoy.org/projects/COPYING.WTFPL for more details.
//

//
// The String class
// ----------------
// A very simple String class, based on Array.
//

#if !defined __LOL_STRING_H__
#define __LOL_STRING_H__

#include <lol/core/array.h>

namespace lol
{

class String : protected Array<char>
{
private:
typedef Array<char> super;

public:
inline String()
: Array()
{
Push('\0');
}

inline String(char const *str)
: Array()
{
do
{
Push(*str);
}
while (*str++);
}

inline char &operator [](int n)
{
return ((super &)*this)[n];
}

inline char const &operator [](int n) const
{
return ((super const &)*this)[n];
}

inline String operator +(String const &s)
{
String ret(*this);
return ret += s;
}

inline String operator +=(String const &s)
{
/* Be careful, we have a trailing zero we don't want! */
--m_count;
(super &)*this += (super const &)s;
return *this;
}
};

} /* namespace lol */

#endif // __LOL_STRING_H__


+ 1
- 1
src/lolcore.vcxproj 查看文件

@@ -300,7 +300,6 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="application\application.h" />
<ClInclude Include="array.h" />
<ClInclude Include="audio.h" />
<ClInclude Include="bitfield.h" />
<ClInclude Include="bullet\btBulletCollisionCommon.h" />
@@ -583,6 +582,7 @@
<ClInclude Include="log.h" />
<ClInclude Include="loldebug.h" />
<ClInclude Include="lolgl.h" />
<ClInclude Include="lol\core\array.h" />
<ClInclude Include="lol\debug.h" />
<ClInclude Include="lol\math\half.h" />
<ClInclude Include="lol\math\math.h" />


Loading…
取消
儲存