More Website Templates @ TemplateMonster.com - November 14, 2011!

478 lines of C code generated from the 10 line BRON2 Code example.

/****************************************************************************
* GENERATION   : The TEST code module was generated using BRON2 C code      *
*              : Generator. DO NOT MODIFY                                   *
* AUTHOR       : (C)2012, Amenuensis Ltd.,                                  *
* CONTACT      : <support@Amenuensis.com>                                   *
****************************************************************************/
#include	"test.h"

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : firstObject *                                              *
* NAME         : newFirstObject                                             *
* PARAMS       : --- NONE ---                                               *
* DESCRIPTION  : This function allocates memory for a new firstObject       *
*              : object. It zeros each field, fills in the essential        *
*              : fields, creates list and hash headers and fills in         *
*              : essential references. This function returns a NULL if it   *
*              : was unable to allocate all the memory required.            *
****************************************************************************/
firstObject
*newFirstObject( void )
{

	/* ALLOCATE A FIRST_OBJECT OBJECT */
	/* ============================== */
	firstObject *my = ( firstObject * ) calloc( 1, sizeof( firstObject ) );

	/* CHECK THAT THE FIRST_OBJECT EXISTS */
	/* ================================== */
	if( my != NULL )
	{

		/* CREATE A NEW THE_OTHER_OBJECT LIST HEADER */
		/* ========================================= */
		my->theOtherObjectList = dNewList();
		if( my->theOtherObjectList == NULL )
		{

			/* UNABLE TO ALLOCATE A THE_OTHER_OBJECT HEADER - SO FREE THE FIRST_OBJECT */
			/* ======================================================================= */
			freeFirstObject( my );

			/* RETURN THE ERROR INDICATION - NULL */
			/* ================================== */
			return NULL;
		}
	}
	return my;
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : void                                                       *
* NAME         : freeFirstObject                                            *
* PARAMS       : firstObject *my                                            *
* DESCRIPTION  : This function frees the memory for the firstObject object. *
*              : It deallocates and frees any child objects associated with *
*              : its lists or hashes. It then finally deallocates the       *
*              : firstObject object itself.                                 *
****************************************************************************/
void
freeFirstObject( firstObject *my )
{

	/* CHECK THAT THE FIRST_OBJECT EXISTS */
	/* ================================== */
	if( my != NULL )
	{

		/* CHECK THAT THE THE_OTHER_OBJECT_LIST WAS ALLOCATED CORRECTLY */
		/* ============================================================ */
		if( my->theOtherObjectList != NULL )
		{

			/* FREE ALL CHILD THE_OTHER_OBJECT OBJECTS */
			/* ======================================= */
			dApplyFuncToList( my->theOtherObjectList, unlinkFreeTheOtherObject );

			/* FREE THE THE_OTHER_OBJECT_LIST HEADER */
			/* ===================================== */
			free( my->theOtherObjectList );
		}

		/* FREE THE FIRST_OBJECT OBJECT */
		/* ============================ */
		free( my );
	}
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : theOtherObject *                                           *
* NAME         : newTheOtherObject                                          *
* PARAMS       : char * findMe                                              *
*              : int Mustsupplythisvalue                                    *
* DESCRIPTION  : This function allocates memory for a new theOtherObject    *
*              : object. It zeros each field, fills in the essential        *
*              : fields, creates list and hash headers and fills in         *
*              : essential references. This function returns a NULL if it   *
*              : was unable to allocate all the memory required.            *
****************************************************************************/
theOtherObject
*newTheOtherObject( char * findMe, int Mustsupplythisvalue )
{

	/* ALLOCATE A THE_OTHER_OBJECT OBJECT */
	/* ================================== */
	theOtherObject *my = ( theOtherObject * ) calloc( 1, sizeof( theOtherObject
		) );

	/* CHECK THAT THE THE_OTHER_OBJECT EXISTS */
	/* ====================================== */
	if( my != NULL )
	{

		/* CHECK THAT THE STRING EXISTS */
		/* ============================ */
		if( findMe != NULL )
		{

			/* COPY THE FIND_ME STRING */
			/* ======================= */
			my->findMe = saveStr( findMe );

			/* CHECK THAT THE STRING ISN'T COPIED */
			/* ================================== */
			if( my->findMe == NULL )
			{

				/* FREE THE THE_OTHER_OBJECT */
				/* ========================= */
				freeTheOtherObject( my );
				return NULL;
			}
		}

		/* STORE THE _MUSTSUPPLYTHISVALUE FIELD */
		/* ==================================== */
		my->Mustsupplythisvalue = Mustsupplythisvalue;
	}
	return my;
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : void                                                       *
* NAME         : freeTheOtherObject                                         *
* PARAMS       : theOtherObject *my                                         *
* DESCRIPTION  : This function frees the memory for the theOtherObject      *
*              : object. It deallocates and frees any child objects         *
*              : associated with its lists or hashes. It then finally       *
*              : deallocates the theOtherObject object itself.              *
****************************************************************************/
void
freeTheOtherObject( theOtherObject *my )
{

	/* CHECK THAT THE THE_OTHER_OBJECT EXISTS */
	/* ====================================== */
	if( my != NULL )
	{

		/* CHECK THAT A VALID STRING HAS BEEN ALLOCATED */
		/* ============================================ */
		if( my->findMe != NULL )
		{

			/* FREE THE STRING */
			/* =============== */
			free( my->findMe );
		}

		/* FREE THE THE_OTHER_OBJECT OBJECT */
		/* ================================ */
		free( my );
	}
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : theOtherObject *                                           *
* NAME         : linkTheOtherObject                                         *
* PARAMS       : firstObject *parent                                        *
*              : theOtherObject *my                                         *
* DESCRIPTION  : This function links a theOtherObject object to its parent  *
*              : firstObject object, which is part of a 1:n relationship.   *
****************************************************************************/
theOtherObject
*linkTheOtherObject( firstObject *parent, theOtherObject *my )
{

	/* CHECK THAT THE THE_OTHER_OBJECT OBJECT AND ITS FIRST_OBJECT PARENT EXISTS */
	/* ========================================================================= */
	if( my != NULL && parent != NULL )
	{

		/* LINK THE THE_OTHER_OBJECT OBJECT INTO THE PARENT FIRST_OBJECT OBJECT */
		/* ==================================================================== */
		dAddTail( parent->theOtherObjectList, ( dnode * ) my );

		/* LINK THE PARENT FIRST_OBJECT OBJECT TO THE THE_OTHER_OBJECT OBJECT */
		/* ================================================================== */
		my->parent = parent;
	}
	return my;
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : void                                                       *
* NAME         : unlinkTheOtherObject                                       *
* PARAMS       : theOtherObject *my                                         *
* DESCRIPTION  : This function unlinks a theOtherObject object from its     *
*              : parent firstObject object. It does not delete the          *
*              : theOtherObject object.                                     *
****************************************************************************/
void
unlinkTheOtherObject( theOtherObject *my )
{

	/* CHECK THAT THE THE_OTHER_OBJECT EXISTS */
	/* ====================================== */
	if( my != NULL )
	{

		/* REMOVE THE THE_OTHER_OBJECT OBJECT FROM ITS PARENT */
		/* ================================================== */
		dRemNode( ( dnode * ) my );
		my->parent = NULL;
	}
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : theOtherObject *                                           *
* NAME         : linkNewTheOtherObject                                      *
* PARAMS       : firstObject *parent                                        *
*              : char * findMe                                              *
*              : int Mustsupplythisvalue                                    *
* DESCRIPTION  : This function creates a new theOtherObject object and will *
*              : link it to its parent firstObject object, if it has been   *
*              : created correctly.                                         *
****************************************************************************/
theOtherObject
*linkNewTheOtherObject( firstObject *parent, char * findMe, int
	Mustsupplythisvalue )
{
	theOtherObject *my = newTheOtherObject( findMe, Mustsupplythisvalue );

	/* CHECK THAT THE THE_OTHER_OBJECT HAS BEEN CREATED CORRECTLY */
	/* ========================================================== */
	if( my != NULL )
	{

		/* LINK THE THE_OTHER_OBJECT OBJECT TO THE PARENT FIRST_OBJECT OBJECT */
		/* ================================================================== */
		my = linkTheOtherObject( parent, my );
	}
	return my;
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : void                                                       *
* NAME         : unlinkFreeTheOtherObject                                   *
* PARAMS       : theOtherObject *my                                         *
* DESCRIPTION  : This function unlinks the theOtherObject object from its   *
*              : parent firstObject object, then uses the                   *
*              : freeTheOtherObject function to free it.                    *
****************************************************************************/
void
unlinkFreeTheOtherObject( theOtherObject *my )
{

	/* CHECK THAT THE THE_OTHER_OBJECT EXISTS */
	/* ====================================== */
	if( my != NULL )
	{

		/* UNLINK THE THE_OTHER_OBJECT OBJECT FROM ITS PARENT FIRST_OBJECT OBJECT */
		/* ====================================================================== */
		unlinkTheOtherObject( my );

		/* FREE THE THE_OTHER_OBJECT */
		/* ========================= */
		freeTheOtherObject( my );
	}
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : theOtherObject *                                           *
* NAME         : findNextTheOtherObject                                     *
* PARAMS       : firstObject *parent                                        *
*              : theOtherObject *soFar                                      *
*              : char * findMe                                              *
* DESCRIPTION  : This function finds the next matching theOtherObject       *
*              : object, after the search made so far, and matches the      *
*              : given criteria. It returns NULL if no more matches are     *
*              : found.                                                     *
****************************************************************************/
theOtherObject
*findNextTheOtherObject( firstObject *parent, theOtherObject *soFar, char *
	findMe )
{
	theOtherObject *my;

	/* CHECK THAT THIS IS THE FIRST SEARCH */
	/* =================================== */
	if( soFar == NULL )
	{

		/* SET THE SO FAR FLAG TO THE BEGINNING OF THE LIST */
		/* ================================================ */
		soFar = ( theOtherObject * ) parent->theOtherObjectList;
	}

	/* GO THROUGHT EACH NODE IN THE LIST */
	/* ================================= */
	for( my = ( theOtherObject * ) SUCC( soFar );
		my != ( theOtherObject * ) parent->theOtherObjectList;
		my = SUCC( my ) )
	{
		if( findMe != NULL && strcmp( my->findMe, findMe ) )
		{

			/* NOT THIS ONE */
			/* ============ */
			continue;
		}

		/* RETURN THE MATCHING OBJECT */
		/* ========================== */
		return my;
	}

	/* RETURN THE NONE FOUND INDICATION */
	/* ================================ */
	return NULL;
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : void                                                       *
* NAME         : matchAllTheOtherObject                                     *
* PARAMS       : firstObject *parent                                        *
*              : refList *rl                                                *
*              : char * findMe                                              *
* DESCRIPTION  : This functions searches the parent firstObject object      *
*              : looking for instances of theOtherObject objects that match *
*              : the search criteria, adding references of matching         *
*              : theOtherObject objects to the refList.                     *
*              : NB For details on the refList object, see ref.def          *
****************************************************************************/
void
matchAllTheOtherObject( firstObject *parent, refList *rl, char * findMe )
{
	theOtherObject *my;

	/* FOR EACH THE_OTHER_OBJECT IN THE FIRST_OBJECT THE_OTHER_OBJECT_LIST */
	/* =================================================================== */
	for( my = ( theOtherObject * ) theFirstTheOtherObject( parent );
		my != ( theOtherObject * ) parent->theOtherObjectList;
		my = SUCC( my ) )
	{
		if( findMe != NULL && strcmp( my->findMe, findMe ) )
		{

			/* NOT THIS ONE */
			/* ============ */
			continue;
		}

		/* LINK A REFERENCE TO THE MATCHING THE_OTHER_OBJECT TO THE REF LIST */
		/* ================================================================= */
		linkNewReference( rl, ( void * ) my );
	}
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : theOtherObject *                                           *
* NAME         : findFirstTheOtherObject                                    *
* PARAMS       : firstObject *parent                                        *
*              : char * findMe                                              *
* DESCRIPTION  : This function finds the first matching theOtherObject      *
*              : object that matches the given criteria. It returns NULL if *
*              : no match is found.                                         *
****************************************************************************/
theOtherObject
*findFirstTheOtherObject( firstObject *parent, char * findMe )
{

	/* FIND THE NEXT THE_OTHER_OBJECT ON FROM NULL */
	/* =========================================== */
	return findNextTheOtherObject( parent, NULL, findMe );
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : yetanotherobject *                                         *
* NAME         : newYetanotherobject                                        *
* PARAMS       : --- NONE ---                                               *
* DESCRIPTION  : This function allocates memory for a new yetanotherobject  *
*              : object. It zeros each field, fills in the essential        *
*              : fields, creates list and hash headers and fills in         *
*              : essential references. This function returns a NULL if it   *
*              : was unable to allocate all the memory required.            *
****************************************************************************/
yetanotherobject
*newYetanotherobject( void )
{

	/* ALLOCATE A YETANOTHEROBJECT OBJECT */
	/* ================================== */
	yetanotherobject *my = ( yetanotherobject * ) calloc( 1, sizeof(
		yetanotherobject ) );

	/* CHECK THAT THE YETANOTHEROBJECT EXISTS */
	/* ====================================== */
	if( my != NULL )
	{
	}
	return my;
}

/****************************************************************************
* LIBRARY      : TEST                                                       *
* INCLUDE FILE : test.h                                                     *
* ------------ : ---------------------------------------------------------- *
* RETURN       : void                                                       *
* NAME         : freeYetanotherobject                                       *
* PARAMS       : yetanotherobject *my                                       *
* DESCRIPTION  : This function frees the memory for the yetanotherobject    *
*              : object. It deallocates and frees any child objects         *
*              : associated with its lists or hashes. It then finally       *
*              : deallocates the yetanotherobject object itself.            *
****************************************************************************/
void
freeYetanotherobject( yetanotherobject *my )
{

	/* CHECK THAT THE YETANOTHEROBJECT EXISTS */
	/* ====================================== */
	if( my != NULL )
	{

		/* FREE THE YETANOTHEROBJECT OBJECT */
		/* ================================ */
		free( my );
	}
}




 

See the 96 lines of generated C header code

Successful System Designs

“Before Amenuensis, software projects we were involved in benefited greatly from the use of BRON technology. We formed Amenuensis to bring BRON 2 and it's sister product Visual BRON to a wider audience of software engineers.” Rebecca BryanCEO & Co-Founder

“Using BRON 2 or VisualBRON allows time to ensure that systems designs are right, to test thoroughly, and to try what-if optimisations that simply aren't feasible without BRON. Design & code Reviews become a breeze.” Mark Gregory Co-Founder