void Graph::Store(std::fstream &stream) { // not the best way of doing this, should have some unique ID for accounts... // not strictly valid either, but are we going to have more than 512 accounts... stream.write((char *) &m_account, sizeof(unsigned char)); StoreString(m_name, stream); m_startDate.Store(stream); m_endDate.Store(stream); stream.write((char *) &m_type, sizeof(unsigned char)); std::bitset<8> localset; localset[0] = m_ignoreTransfers; unsigned char cBitset = static_cast<unsigned char>(localset.to_ulong()); stream.write((char *) &cBitset, sizeof(unsigned char)); stream.write((char *) &m_dateType, sizeof(unsigned char)); stream.write((char *) &m_itemsType, sizeof(unsigned char)); unsigned int numItems = static_cast<unsigned int>(m_items.size()); stream.write((char *) &numItems, sizeof(unsigned int)); for (std::set<std::string>::iterator it = m_items.begin(); it != m_items.end(); ++it) { StoreString((*it), stream); } stream.write((char *) &m_viewType, sizeof(unsigned char)); }
int LoadStaticText( control_t* ctrl, XGHandle& data, int off ) { if( ctrl->item_id == 888 ) ctrl->tag = 'game'; // game graphic control. if( ctrl->item_id == 1099 ) ctrl->tag = 'repo'; if( ctrl->item_id == 2222 ) ctrl->tag = 'prol'; return StoreString( data, off ) + 4; }
void Transaction::Store(std::fstream &stream) { m_Date.Store(stream); StoreString(m_Description, stream); StoreString(m_Payee, stream); StoreString(m_Category, stream); m_Amount.Store(stream); stream.write((char *) &m_Type, sizeof(unsigned char)); std::bitset<8> localset; localset[0] = m_Cleared; localset[1] = m_Split; localset[2] = m_Reconciled; localset[3] = m_Flagged; localset[4] = m_HasFITID; unsigned char cBitset = static_cast<unsigned char>(localset.to_ulong()); stream.write((char *) &cBitset, sizeof(unsigned char)); if (m_HasFITID) { StoreString(m_FITID, stream); } unsigned char numSplits = static_cast<unsigned char>(m_aSplits.size()); stream.write((char *) &numSplits, sizeof(unsigned char)); std::vector<SplitTransaction>::iterator it = m_aSplits.begin(); std::vector<SplitTransaction>::iterator itEnd = m_aSplits.end(); for (; it != itEnd; ++it) { (*it).Store(stream); } }
/*>static WHOLEPDB *ReadWholePDB(FILE *fpin) ----------------------------------------- Input: FILE *fpin File pointer Returns: WHOLEPDB * Whole PDB structure containing linked list to PDB coordinate data Reads a PDB file, storing the header and trailer information as well as the coordinate data. Can read gzipped files as well as uncompressed files. Coordinate data is accessed as linked list of type PDB as follows: WHOLEPDB *wpdb; PDB *p; wpdb = ReadWholePDB(fp); for(p=wpdb->pdb; p!=NULL; p=p->next) { ... Do something with p ... } 30.05.02 Original By: ACRM 07.03.07 Made into a doXXX routine to add a atomsonly parameter TODO FIXME!!!!! Move all this into doReadPDB so that we don't worry about rewinding any more */ static WHOLEPDB *doReadWholePDB(FILE *fpin, BOOL atomsonly) { WHOLEPDB *wpdb; char buffer[MAXBUFF]; FILE *fp = fpin; #ifdef GUNZIP_SUPPORT int signature[3], i, ch; char cmd[80]; #endif if((wpdb=(WHOLEPDB *)malloc(sizeof(WHOLEPDB)))==NULL) return(NULL); wpdb->pdb = NULL; wpdb->header = NULL; wpdb->trailer = NULL; #ifdef GUNZIP_SUPPORT cmd[0] = '\0'; /* See whether this is a gzipped file */ for(i=0; i<3; i++) signature[i] = fgetc(fpin); for(i=2; i>=0; i--) ungetc(signature[i], fpin); if((signature[0] == (int)0x1F) && (signature[1] == (int)0x8B) && (signature[2] == (int)0x08)) { /* It is gzipped so we'll open gunzip as a pipe and send the data through that into a temporary file */ cmd[0] = '\0'; sprintf(cmd,"gunzip >/tmp/readpdb_%d",(int)getpid()); if((fp = (FILE *)popen(cmd,"w"))==NULL) { wpdb->natoms = (-1); return(NULL); } while((ch=fgetc(fpin))!=EOF) fputc(ch, fp); pclose(fp); /* We now reopen the temporary file as our PDB input file */ sprintf(cmd,"/tmp/readpdb_%d",(int)getpid()); if((fp = fopen(cmd,"r"))==NULL) { wpdb->natoms = (-1); return(NULL); } } #endif /* Read the header from the PDB file */ while(fgets(buffer,MAXBUFF,fp)) { if(!strncmp(buffer, "ATOM ", 6) || !strncmp(buffer, "HETATM", 6) || !strncmp(buffer, "MODEL ", 6)) { break; } if((wpdb->header = StoreString(wpdb->header, buffer))==NULL) return(NULL); } /* Read the coordinates */ rewind(fp); if(atomsonly) { wpdb->pdb = ReadPDBAtoms(fp, &(wpdb->natoms)); } else { wpdb->pdb = ReadPDB(fp, &(wpdb->natoms)); } /* Read the trailer */ rewind(fp); while(fgets(buffer,MAXBUFF,fp)) { if(!strncmp(buffer, "CONECT", 6) || !strncmp(buffer, "MASTER", 6) || !strncmp(buffer, "END ", 6)) { wpdb->trailer = StoreString(wpdb->trailer, buffer); } } return(wpdb); }
int LoadButton( control_t* ctrl, XGHandle& data, int off ) { #pragma unused( ctrl ) return StoreString( data, off+8 ) + 8; }
int LoadEditText( control_t* ctrl, XGHandle& data, int off ) { #pragma unused( ctrl ) return StoreString( data, off ) + 26; }