This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
struct CCFArray | |
{ | |
CFArrayRef array; | |
CCFArray() | |
{ | |
array = CFArrayCreate( kCFAllocatorDefault, 0, 0, 0 ); | |
} | |
CCFArray(CFArrayRef cf):array(cf) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string CFGetType( long typeId ) | |
{ | |
static map<long,string> types = { | |
{CFArrayGetTypeID(),"CFArray"}, | |
{CFBooleanGetTypeID(),"CFBoolean"}, | |
{CFDataGetTypeID(),"CFData"}, | |
{CFDateGetTypeID(),"CFDate"}, | |
{CFDictionaryGetTypeID(),"CFDictionary"}, | |
{CFNumberGetTypeID(),"CFNumber"}, | |
{CFStringGetTypeID(),"CFString"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map<IOReturn,string> ioMakeErrorMap() | |
{ | |
map<IOReturn,string> map; | |
map[ kIOReturnSuccess ] = "kIOReturnSuccess KERN_SUCCESS // OK"; | |
map[ kIOReturnError ] = " // general error"; | |
map[ kIOReturnNoMemory ] = " // can't allocate memory "; | |
map[ kIOReturnNoResources ] = "resource shortage "; | |
map[ kIOReturnIPCError ] = "error during IPC "; | |
map[ kIOReturnNoDevice ] = "no such device "; | |
map[ kIOReturnNotPrivileged ] = "privilege violation "; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For allocating a 2D vector | |
template <typename T> vector< vector<T> > twoD( size_t rows, size_t cols ) | |
{ | |
vector< vector<T> > vv( rows ); | |
for( int i = 0; i < vv.size(); i++ ) | |
vv[i].resize( cols ); | |
return vv; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for a vector | |
template <typename T> bool contains( const vector<T> &vvector, const T& item ) | |
{ | |
return vvector.find( item ) != vvector.end() ; | |
} | |
// for a set | |
template <typename T> bool contains( const set<T> &sset, const T& item ) | |
{ | |
return sset.find( item ) != sset.end() ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MERSENNETWISTER_H | |
#define MERSENNETWISTER_H | |
/* | |
A C-program for MT19937, with initialization improved 2002/1/26. | |
Coded by Takuji Nishimura and Makoto Matsumoto. | |
Before using, initialize the state by using init_genrand(seed) | |
or init_by_array(init_key, key_length). | |
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, | |
All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdarg.h> | |
// bitfield because some error messages can | |
// be categorized as Info | Warning | Error | |
enum ErrorLevel{ | |
Info = 1 << 0, Warning = 1 << 1, Error = 1 << 2 | |
}; | |
const char* ErrorLevelName[] = { | |
"None", //0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* An implementation of convertion from OpenSSL to OpenSSH public key format | |
* | |
* Copyright (c) 2008 Mounir IDRASSI <mounir.idrassi@idrix.fr>. All rights reserved. | |
* | |
* This program is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
* or FITNESS FOR A PARTICULAR PURPOSE. | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reverses a mapping of map: T -> vector<S> to map: S -> vector<T> | |
template<typename T, typename S> | |
void reverseMapping( map< T, vector<S> >& oMapping, map< S, vector<T> >& revMapping ) | |
{ | |
for( typename map< T, vector<S> >::iterator iter = oMapping.begin() ; iter != oMapping.end() ; ++iter ) | |
{ | |
for( int i = 0 ; i < iter->second.size() ; i++ ) | |
{ | |
pair< typename map< S, vector<T> >::iterator, bool > res = | |
revMapping.insert( make_pair( iter->second[i], vector<T>() ) ) ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>DVTConsoleDebuggerInputTextColor</key> | |
<string>0 0 0 1</string> | |
<key>DVTConsoleDebuggerInputTextFont</key> | |
<string>Menlo-Regular - 12.0</string> | |
<key>DVTConsoleDebuggerOutputTextColor</key> | |
<string>0 0 0 1</string> |
OlderNewer