Ejemplo n.º 1
0
	void operator()(size_t flags, Size<T>& size, const char* name, const char* units)
	{
		if(flags & F_INTERNAL)
			return;

		const u64 value = (u64)size.value;
		if(value == 0)
			return;

		u64 divisor;
		if(value > GiB)
		{
			divisor = GiB;
			units = " GiB";
		}
		else if(value > MiB)
		{
			divisor = MiB;
			units = " MiB";
		}
		else if(value > KiB)
		{
			divisor = KiB;
			units = " KiB";
		}
		else
		{
			divisor = 1;
			units = " bytes";
		}

		WriteName(name);

		// (avoid floating-point output unless division would truncate the value)
		if(value % divisor == 0)
			ss << (value/divisor);
		else
			ss << (double(value)/divisor);

		WriteUnits(units);
	}
Ejemplo n.º 2
0
	void Write(size_t flags, Field& field, const char* name, const char* units, ...)
	{
		// SMBIOS uses the smallest and sometimes also largest representable
		// signed/unsigned value to indicate `unknown' (except enumerators -
		// but those are handled in the other function overload), so skip them.
		if(field == std::numeric_limits<Field>::min() || field == std::numeric_limits<Field>::max())
			return;

		WriteName(name);

		if(flags & F_HEX)
			ss << std::hex << std::uppercase;

		if(sizeof(field) == 1)	// avoid printing as a character
			ss << unsigned(field);
		else
			ss << field;

		if(flags & F_HEX)
			ss << std::dec;	// (revert to decimal, e.g. for displaying sizes)

		WriteUnits(units);
	}
Ejemplo n.º 3
0
/*----------------------------------------------------------------------
   WriteStructureSchema						
   ecrit le schema de structure pointe' par pSS dans le fichier	
   de nom fileName.						
   Si code est nul, ecrit le schema avec un nouveau code		
   d'identification, sinon avec code comme code d'identification.	
  ----------------------------------------------------------------------*/
ThotBool             WriteStructureSchema (Name fileName, PtrSSchema pSS,
					   int code)
{
   PtrTtAttribute      pAttr;
   int                 i, j;

   /* ouvre le fichier */
   outfile = TtaWriteOpen (fileName);
   if (outfile == 0)
      return False;

   /* ecrit la partie fixe du schema de structure */
   WriteName (pSS->SsName);
   if (code == 0)
      /* alloue un nouveau code d'identification au schema compile' */
      WriteShort (UniqueIdent ());
   else
      /* le schema compile' a le code d'identification code */
      WriteShort (code);
   WriteName (pSS->SsDefaultPSchema);
   WriteBoolean (pSS->SsExtension);
   WriteShort (pSS->SsDocument);
   WriteShort (pSS->SsRootElem);
   WriteShort (pSS->SsNAttributes);
   WriteShort (pSS->SsNRules);
   WriteBoolean (pSS->SsExport);

   WriteShort (pSS->SsNExceptions);
   for (i = 0; i < pSS->SsNExceptions; i++)
      WriteShort (pSS->SsException[i]);

   /* ecrit le texte des constantes */
   i = 0;
   do
      TtaWriteByte (outfile, pSS->SsConstBuffer[i++]);
   while (pSS->SsConstBuffer[i - 1] != '\0' || pSS->SsConstBuffer[i] != '\0');

   /* SsFirstDynNature */
   TtaWriteByte (outfile, '\0');

   /* ecrit les attributs */
   for (i = 0; i < pSS->SsNAttributes; i++)
     {
	pAttr = pSS->SsAttribute->TtAttr[i];
	WriteName (pAttr->AttrName);
	WriteBoolean (pAttr->AttrGlobal);
	WriteShort (pAttr->AttrFirstExcept);
	WriteShort (pAttr->AttrLastExcept);
	WriteAttributeType (pAttr->AttrType);
	switch (pAttr->AttrType)
	      {
		 case AtNumAttr:
		 case AtTextAttr:
		    break;
		 case AtReferenceAttr:
		    WriteShort (pAttr->AttrTypeRef);
		    WriteName (pAttr->AttrTypeRefNature);
		    break;
		 case AtEnumAttr:
		    WriteShort (pAttr->AttrNEnumValues);
		    for (j = 0; j < pAttr->AttrNEnumValues; j++)
		       WriteName (pAttr->AttrEnumValue[j]);
		    break;
	      }
     }
   /* ecrit les regles de structure */
   for (i = 0; i < pSS->SsNRules; i++)
      WriteRule (pSS->SsRule->SrElem[i]);

   /* ecrit les regles d'extension */
   if (pSS->SsExtension)
     {
	WriteShort (pSS->SsNExtensRules);
	for (i = 0; i < pSS->SsNExtensRules; i++)
	   WriteRule (&pSS->SsExtensBlock->EbExtensRule[i]);
     }
   TtaWriteClose (outfile);
   return True;
}
Ejemplo n.º 4
0
/*----------------------------------------------------------------------
   WriteRule     ecrit une regle de structure			
  ----------------------------------------------------------------------*/
static void         WriteRule (SRule * pSRule)
{
   int                 j;

   WriteName (pSRule->SrName);
   WriteShort (pSRule->SrNDefAttrs);
   for (j = 0; j < pSRule->SrNDefAttrs; j++)
      WriteShort (pSRule->SrDefAttr[j]);
   for (j = 0; j < pSRule->SrNDefAttrs; j++)
      WriteSignedShort (pSRule->SrDefAttrValue[j]);
   for (j = 0; j < pSRule->SrNDefAttrs; j++)
      WriteBoolean (pSRule->SrDefAttrModif[j]);
   WriteShort (pSRule->SrNLocalAttrs);
   for (j = 0; j < pSRule->SrNLocalAttrs; j++)
      WriteShort (pSRule->SrLocalAttr->Num[j]);
   for (j = 0; j < pSRule->SrNLocalAttrs; j++)
      WriteBoolean (pSRule->SrRequiredAttr->Bln[j]);
   WriteBoolean (pSRule->SrUnitElem);
   WriteBoolean (pSRule->SrRecursive);
   WriteBoolean (pSRule->SrExportedElem);
   if (pSRule->SrExportedElem)
     {
	WriteShort (pSRule->SrExportContent);
	WriteName (pSRule->SrNatExpContent);
     }
   WriteShort (pSRule->SrFirstExcept);
   WriteShort (pSRule->SrLastExcept);
   WriteShort (pSRule->SrNInclusions);
   for (j = 0; j < pSRule->SrNInclusions; j++)
      WriteShort (pSRule->SrInclusion[j]);
   WriteShort (pSRule->SrNExclusions);
   for (j = 0; j < pSRule->SrNExclusions; j++)
      WriteShort (pSRule->SrExclusion[j]);
   WriteBoolean (pSRule->SrRefImportedDoc);
   WriteConstructor (pSRule->SrConstruct);
   switch (pSRule->SrConstruct)
	 {
	    case CsNatureSchema:
	       /* don't write anything */
	       break;
	    case CsBasicElement:
	       WriteBasicType (pSRule->SrBasicType);
	       break;
	    case CsReference:
	       WriteShort (pSRule->SrReferredType);
	       WriteName (pSRule->SrRefTypeNat);
	       break;
	    case CsIdentity:
	       WriteShort (pSRule->SrIdentRule);
	       break;
	    case CsList:
	       WriteShort (pSRule->SrListItem);
	       WriteShort (pSRule->SrMinItems);
	       WriteShort (pSRule->SrMaxItems);
	       break;
	    case CsChoice:
	       WriteSignedShort (pSRule->SrNChoices);
	       if (pSRule->SrNChoices > 0)
		  for (j = 0; j < pSRule->SrNChoices; j++)
		     WriteShort (pSRule->SrChoice[j]);
	       break;
	    case CsAggregate:
	    case CsUnorderedAggregate:
	       WriteShort (pSRule->SrNComponents);
	       for (j = 0; j < pSRule->SrNComponents; j++)
		  WriteShort (pSRule->SrComponent[j]);
	       for (j = 0; j < pSRule->SrNComponents; j++)
		  WriteBoolean (pSRule->SrOptComponent[j]);
	       break;
	    case CsConstant:
	       WriteShort (pSRule->SrIndexConst);
	       break;
	    case CsPairedElement:
	       WriteBoolean (pSRule->SrFirstOfPair);
	       break;
	    case CsExtensionRule:
	       break;
	    case CsDocument:
	    case CsAny:
	    case CsEmpty:
	       break;
	 }
}
Ejemplo n.º 5
0
void PDF::WriteReferenceArray(const char * name, const IntArray & array)
   {
   WriteName(name);
   WriteReferenceArray(array);
   fputc('\n', file);
   }
Ejemplo n.º 6
0
void PDF::WriteReference(const char * name, int object)
   {
   WriteName(name);
   WriteReference(object);
   fputc('\n', file);
   }
Ejemplo n.º 7
0
void PDF::WriteDate(const char * name, int year, int month, int day)
   {
   WriteName(name);
   WriteDate(year, month, day);
   fputc('\n', file);
   }
Ejemplo n.º 8
0
void PDF::WriteString(const char * name, const char * string)
   {
   WriteName(name);
   WriteString(string);
   fputc('\n', file);
   }
Ejemplo n.º 9
0
void PDF::WriteName(const char * name, const char * name2)
   {
   WriteName(name);
   WriteName(name2);
   fputc('\n', file);
   }
Ejemplo n.º 10
0
void PDF::WriteDouble(const char * name, double value)
   {
   WriteName(name);
   WriteDouble(value);
   fputc('\n', file);
   }
Ejemplo n.º 11
0
void PDF::WriteInteger(const char * name, int integer)
   {
   WriteName(name);
   WriteInteger(integer);
   fputc('\n', file);
   }
Ejemplo n.º 12
0
void PDF::WriteBoolean(const char * name, bool boolean)
   {
   WriteName(name);
   WriteBoolean(boolean);
   fputc('\n', file);
   }