Jump to content

  • Log In with Google      Sign In   
  • Create Account

nuclear123

Member Since 05 Feb 2010
Offline Last Active Oct 05 2012 02:28 PM

Topics I've Started

Interface with website from desktop app?

20 August 2012 - 10:30 PM

Say i'm wanting to make an application that can make a post on a forum or even in form on a website where i need to edit my accounts profile info. About how would i go about achieving interoperability with a website i did not create?

Contract Programming Work advice?

19 August 2012 - 12:57 PM

First off forgive me if this is in the wrong section( which i'm sure of :P )

Currently, i'm graduating in 2 more semesters of college and will have my bachelors in computer science. All is well except for the fact that the current location that i'm at doesn't offer job opportunities for my field. There are a couple cities near by that i wouldn't mind the drive to, but as well the pay will be good but not amazing. The point is my girlfriend graduated about a year ago and has a very good paying job( as an RN ) and enjoys the place where she works. Due to the fact that she does have a stable and secure job as well as a good paying one i'm satisfied with possibly finding a contract programming job or anything i might be able to perform from my home. The reason i'm posting on here is to ask others if they happen to know of any "known" websites that offer this kind of work or where i might find my luck at :). Thanks for the help

BTW: i currently have no interest in game programming even though i would use it as a last resort :) everything is worth a try

C++ ODBC Wrapper Classes ( SQLHANDLES ) - part 1

02 August 2012 - 07:52 PM

In order to further increase my knowledge of ODBC and C++ good design practices i have decided to try my go at creating wrapper classes of the current ODBC C Api located on MSDN. I'm mainly wanting criticism on design problems people might see. Any advice is greatly appreciated ;) cheers


In order to avoid VTABLE overhead i have tried my best to implement simulated dynamic binding/CRTP ( which i believe i have implemented correctly )


template<class TDerived, SQLSMALLINT THandle = SQL_HANDLE_UNKNOWN>
class __declspec(novtable) CHandle
{
public:
  SQLHANDLE   m_h;
  SQLSMALLINT m_hType;
  enum { SQL_HANDLE_UNKNOWN = -1 };
public:
  CHandle() :
   m_h(NULL), m_hType(THandle)
  {
   _ASSERTE(m_hType != -1);
  }
 
  CHandle(SQLHANDLE h) :
   m_h(h), m_hType(THandle)
  {
   _ASSERTE(h != NULL);
   _ASSERTE(m_hType != -1);
  
   Attach(h);
  }
  void Attach(_In_ SQLHANDLE h)
  {
   _ASSERTE(h != NULL);
   _ASSERTE(m_h == NULL);
   _ASSERTE(m_hType != -1);
  
   m_h = h;
  }
  SQLHANDLE Detach()
  {
   _ASSERTE(m_h != NULL);
   _ASSERTE(m_hType != -1);
   SQLHANDLE hTemp = m_h;
   m_h = NULL;
   return hTemp;
  }
  bool Create()
  {
   _ASSERTE(m_h == NULL);
   _ASSERTE(m_hType != -1);
  
   g_rt = SQLAllocHandle(THandle, NULL, &m_h);
   _ASSERTE(SQL_SUCCEEDED(g_rt));
   if (SQL_SUCCEEDED(g_rt) == FALSE)
    return FALSE;
  
   return TRUE;
  }
  void Destroy()
  {
   _ASSERTE(m_h != NULL);
   _ASSERTE(m_hType != -1);
  
   g_rt = SQLFreeHandle(THandle, m_h);
   _ASSERTE(SQL_SUCCEEDED(g_rt));
   m_h = NULL;
   m_hType = -1;
  }
  // TODO : test setting multiple attributes
  bool SetAttribute(_In_ SQLINTEGER attribute, _In_ SQLPOINTER value)
  {
   _ASSERTE(m_h != NULL);
   return static_cast<TDerived*>(this)->_SetAttribute(attribute, value);
  }
  // TODO : test getting multiple attributes
  bool GetAttribute(_In_ SQLINTEGER attribute, _Inout_ SQLPOINTER pValue, _Inout_ SQLINTEGER* pcbWritten)
  {
   _ASSERTE(m_h != NULL);
   return static_cast<TDerived*>(this)->_GetAttribute(attribute, pValue, pcbWritten);
  }
  operator SQLHANDLE()
  {
   return m_h;
  }
};

class __declspec(novtable) CEnviromentHandle :
  public CHandle< CEnviromentHandle, SQL_HANDLE_ENV>
{
public:

  bool _SetAttribute(_In_ SQLINTEGER attribute, _In_ SQLPOINTER value)
  {
   _ASSERTE(m_h != NULL);
   g_rt = SQLSetEnvAttr(m_h, attribute, value, SQL_NTS);
   _ASSERTE(SQL_SUCCEEDED(g_rt));
   if (SQL_SUCCEEDED(g_rt) == FALSE)
    return FALSE;
  
   return TRUE;
  }
  // TODO : i might need last parameter. For now ignoreing
  bool _GetAttribute(_In_ SQLINTEGER attribute, _Inout_ SQLPOINTER pValue, _Inout_ SQLINTEGER* pcbWritten)
  {
   _ASSERTE(m_h != NULL);
   g_rt = SQLGetEnvAttr(m_h, attribute, pValue, SQL_IS_UINTEGER, pcbWritten);
   _ASSERTE(SQL_SUCCEEDED(g_rt));
   if (SQL_SUCCEEDED(g_rt) == FALSE)
    return FALSE;
  
   return TRUE;
  }
};
class __declspec(novtable) CConnectionHandle :
  public CHandle< CConnectionHandle, SQL_HANDLE_DBC>
{
public:
  bool _SetAttribute(_In_ SQLINTEGER attribute, _In_ SQLPOINTER value)
  {
   _ASSERTE(m_h != NULL);
   g_rt = SQLSetConnectAttr(m_h, attribute, value, SQL_NTS);
   _ASSERTE(SQL_SUCCEEDED(g_rt));
   if (SQL_SUCCEEDED(g_rt) == FALSE)
    return FALSE;
  
   return TRUE;
  }
  // TODO : i might need last parameter. For now ignoreing
  bool _GetAttribute(_In_ SQLINTEGER attribute, _Inout_ SQLPOINTER pValue, _Inout_ SQLINTEGER* pcbWritten)
  {
   _ASSERTE(m_h != NULL);
   g_rt = SQLGetConnectAttr(m_h, attribute, pValue, SQL_IS_UINTEGER, pcbWritten);
   _ASSERTE(SQL_SUCCEEDED(g_rt));
   if (SQL_SUCCEEDED(g_rt) == FALSE)
    return FALSE;
  
   return TRUE;
  }
};

class __declspec(novtable) CStatementHandle :
  public CHandle< CStatementHandle, SQL_HANDLE_STMT>
{
public:
  bool _SetAttribute(_In_ SQLINTEGER attribute, _In_ SQLPOINTER value)
  {
   _ASSERTE(m_h != NULL);
   g_rt = SQLSetStmtAttr(m_h, attribute, value, SQL_NTS);
   _ASSERTE(SQL_SUCCEEDED(g_rt));
   if (SQL_SUCCEEDED(g_rt) == FALSE)
    return FALSE;
  
   return TRUE;
  }
  // TODO : i might need last parameter. For now ignoreing
  bool _GetAttribute(_In_ SQLINTEGER attribute, _Inout_ SQLPOINTER pValue, _Inout_ SQLINTEGER* pcbWritten)
  {
   _ASSERTE(m_h != NULL);
   g_rt = SQLGetStmtAttr(m_h, attribute, pValue, SQL_IS_UINTEGER, pcbWritten);
   _ASSERTE(SQL_SUCCEEDED(g_rt));
   if (SQL_SUCCEEDED(g_rt) == FALSE)
    return FALSE;
  
   return TRUE;
  }
};

The Curiously Recurring Template Pattern help

02 August 2012 - 01:18 AM

I cannot for the life of me figure out what im doing wrong. I'm trying to implement CRTP/static polymorphism to avoid the cost of vtable using the following code

template <class Derived>
struct base
{
// some reason this function is not getting called
    void implementation()
    {
         _asm int 3; 
		 static_cast<Derived*>(this)->implementation();
		 // ...
    }
};

struct derived : base<derived>
{
	 void implementation()
	 {
		  _asm int 3;
	 }
};

int main()
{
     derived test;
     test.implementation();
     return 0;
}

the problem is it's always calling the derived classes member function without first calling the base class.

Array of Arrays?

22 July 2012 - 12:41 PM

i cannot for the life of me figure out how to create the following an array of static arrays. below is a picture of what i mean. I want to be able to advanced my pointer 1 byte and hit another string. Is the following even possible?

http://craz.net/Snapper/live/view/?s=r6t

PARTNERS