Skip to content
/ cTools Public

some helpers im using since 2009. contain usefull things like vec2, vec3, vec4, variant, actionTime and more

License

Notifications You must be signed in to change notification settings

aiekick/cTools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Win Linux Osx

cTools :

a two files helper im using from more than 10 years, in all my project. Contain usefull templated things for c++ like vec2, vec3, vec4, variant, actionTime and more. need a bit of refactoring btw :) use the namespace ct

  • ct::cCyclicArray => circular list
  • ct::cActionTime => define when to do action according to time of last event
  • ct::cTexture => opengl texture simple container
  • ct::cColor => color class for conversion
  • ct::vec2 => vec2 class for quick operation / math x,y
  • ct::mat2 => mat2 class for matrix 2x2
  • ct::vec3 => vec3 class for quick operation / math x,y,z
  • ct::vec4 => vec4 class for quick operation / math x,y,z,w
  • ct::rect => rect class for quick operation / math x,y,w,h
  • ct::AABB => AABB 2D
  • ct::AABBCC => AABBCC 3D
  • ct::variant => variant class for quick conversion between many types and string

and other string conversion / extraction etc..

Logger :

Log method for check/write in auto in a log file

  • LogStr(n)
  • LogValue(s, n)
  • LogGlError()
  • LogGlErrorVar(var)
  • LogAssert(a,b)

FileHelper

this singleton is usefull for manipulate files / directory fully tested on win/LINUX/MACOS

  • convert from absolute to realtive to aantoher path
  • test aboslute or relative
  • is file exist
  • test if a file exist a list of path to search in
  • simplify a patth (like if you have toto/../toto/../toto => toto
  • get/set app path
  • get/set current directory
  • load/save file to/from string
  • parse file path name
  • destroy a file
  • open a fil in an external editor
  • open a url in a browser
  • select a file in os explorer
  • get drives (on win32)

dependency : ctools, dirent/h, glfw if you want to use clipboard

ConfigAbstract

ConfigAbstract let you load/save a config file easily from class using lib tinyxml2

Usage :

class toto : public conf::ConfigAbstract
{
public:
	toto()
	{
		LoadConfigFile("config.xml");
	}

	~toto()
	{
		SaveConfigFile("config.xml");
	}

	std::string getXml(const std::string& vOffset);
	void setFromXml(tinyxml2::XMLElement* vElem, tinyxml2::XMLElement* vParent);
};


std::string toto::getXml(const std::string& vOffset)
{
	std::string str;

	str += vOffset + "\t<tata value=\"" + "true" + "\"/>\n";
	
	return str;
}

bool toto::setFromXml(tinyxml2::XMLElement* vElem, tinyxml2::XMLElement* vParent)
{
	// The value of this child identifies the name of this element
	std::string strName = "";
	std::string strValue = "";
	std::string strParentName = "";

	strName = vElem->Value();
	if (vElem->GetText())
		strValue = vElem->GetText();
	if (vParent != 0)
		strParentName = vParent->Value();

	auto att = vElem->FirstAttribute();
	if (att && std::string(att->Name()) == "value")
	{
		strValue = att->Value();
		if (strName == "tata")
			youvar = strValue;
	}
	
	return true; // parsing continue if childs or stop
}

Releases

No releases published

Packages

No packages published