Aggiunta funzione insert_row ai record_array
git-svn-id: svn://10.65.10.50/trunk@2812 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
		
							parent
							
								
									4796306755
								
							
						
					
					
						commit
						9fe1e240a7
					
				@ -1015,7 +1015,7 @@ bool TCursor::ok() const
 | 
				
			|||||||
    kt.ltrim(3);
 | 
					    kt.ltrim(3);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  if (key < kf || (kt.not_empty() && kt < key.left(kt.len())))
 | 
					  if (key < (const char *) kf || (kt.not_empty() && kt < (const char *) key.left(kt.len())))
 | 
				
			||||||
    return FALSE;                  
 | 
					    return FALSE;                  
 | 
				
			||||||
  if (_filter_update || _filterfunction_update) _if->update();
 | 
					  if (_filter_update || _filterfunction_update) _if->update();
 | 
				
			||||||
  if ((_filterfunction ? _filterfunction(_if) : TRUE ) &&
 | 
					  if ((_filterfunction ? _filterfunction(_if) : TRUE ) &&
 | 
				
			||||||
@ -1870,7 +1870,8 @@ bool TRecord_array::renum_key(
 | 
				
			|||||||
// @syntax bool renum_key(const char* field, const TString& num);
 | 
					// @syntax bool renum_key(const char* field, const TString& num);
 | 
				
			||||||
// @syntax bool renum_key(const char* field, long num);
 | 
					// @syntax bool renum_key(const char* field, long num);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{             
 | 
					{      
 | 
				
			||||||
 | 
					  CHECKS(_num != field, "You can't renumber field ", field);
 | 
				
			||||||
  const TString& curr = key().get(field);
 | 
					  const TString& curr = key().get(field);
 | 
				
			||||||
  if (curr == num)
 | 
					  if (curr == num)
 | 
				
			||||||
    return FALSE;
 | 
					    return FALSE;
 | 
				
			||||||
@ -1901,6 +1902,26 @@ int TRecord_array::rec2row(const TRectype& r) const
 | 
				
			|||||||
  return n;
 | 
					  return n;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int TRecord_array::insert_row(TRectype* r)
 | 
				
			||||||
 | 
					{      
 | 
				
			||||||
 | 
					  const int nr = rec2row(*r);
 | 
				
			||||||
 | 
					  CHECK(nr, "You cannot insert a new key");
 | 
				
			||||||
 | 
					  const bool shift = exist(nr);
 | 
				
			||||||
 | 
					  insert(r, nr);
 | 
				
			||||||
 | 
					  if (shift)                        // Se ho cambiato il record campione
 | 
				
			||||||
 | 
					  {                                                 // e ci sono altre righe ...
 | 
				
			||||||
 | 
					    for (int f = last(); f > nr; f--)         
 | 
				
			||||||
 | 
					    {    
 | 
				
			||||||
 | 
					      char n[16]; 
 | 
				
			||||||
 | 
					      TRectype & rec = row(f, FALSE);
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      sprintf(n, "%ld", (long)_offset + f);
 | 
				
			||||||
 | 
					      rec.put(_num, n);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return nr;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int TRecord_array::add_row(TRectype* r)
 | 
					int TRecord_array::add_row(TRectype* r)
 | 
				
			||||||
{               
 | 
					{               
 | 
				
			||||||
  const int nr = rec2row(*r);
 | 
					  const int nr = rec2row(*r);
 | 
				
			||||||
 | 
				
			|||||||
@ -269,10 +269,16 @@ public:
 | 
				
			|||||||
  bool exist(int r) const;
 | 
					  bool exist(int r) const;
 | 
				
			||||||
  // @cmember Ritorna la riga <p r>
 | 
					  // @cmember Ritorna la riga <p r>
 | 
				
			||||||
  TRectype& row(int r, bool create);
 | 
					  TRectype& row(int r, bool create);
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					  // @cmember Inserisce una riga alla posizione indicata nel record, sposta gli altri elementi se la poszione era gia' occupata
 | 
				
			||||||
 | 
					  virtual int insert_row(TRectype* r);
 | 
				
			||||||
 | 
					  // @cmember Inserisce una riga alla posizione indicata nel record, sposta gli altri elementi se la poszione era gia' occupata
 | 
				
			||||||
 | 
					  int insert_row(const TRectype& r) 
 | 
				
			||||||
 | 
					  { return insert_row((TRectype*)r.dup()); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // @cmember Aggiunge/sostituisce una riga  
 | 
					  // @cmember Aggiunge/sostituisce una riga alla posizione indicata nel record 
 | 
				
			||||||
  virtual int add_row(TRectype* r);
 | 
					  virtual int add_row(TRectype* r);
 | 
				
			||||||
  // @cmember Aggiunge un nuovo record all'array
 | 
					  // @cmember Aggiunge/sostituisce una riga alla posizione indicata nel record
 | 
				
			||||||
  int add_row(const TRectype& r) 
 | 
					  int add_row(const TRectype& r) 
 | 
				
			||||||
  { return add_row((TRectype*)r.dup()); }
 | 
					  { return add_row((TRectype*)r.dup()); }
 | 
				
			||||||
  // @cmember Cancella una riga identificata da <p n>
 | 
					  // @cmember Cancella una riga identificata da <p n>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user