Xmipp  v3.23.11-Nereus
Functions
cif::detail Namespace Reference

Functions

size_t write_value (std::ostream &os, std::string_view value, size_t offset, size_t width)
 
bool found_in_range (condition_impl *c, std::vector< and_condition_impl *>::iterator b, std::vector< and_condition_impl *>::iterator e)
 

Function Documentation

◆ found_in_range()

bool cif::detail::found_in_range ( condition_impl *  c,
std::vector< and_condition_impl *>::iterator  b,
std::vector< and_condition_impl *>::iterator  e 
)

Definition at line 82 of file condition.cpp.

83  {
84  bool result = true;
85 
86  for (auto s = b; s != e; ++s)
87  {
88  auto &cs = (*s)->m_sub;
89 
90  if (find_if(cs.begin(), cs.end(), [c](const condition_impl *i) { return i->equals(c); }) == cs.end())
91  {
92  result = false;
93  break;
94  }
95  }
96 
97  return result;
98  }
doublereal * c
#define i
doublereal * b
struct _constraint * cs

◆ write_value()

size_t cif::detail::write_value ( std::ostream &  os,
std::string_view  value,
size_t  offset,
size_t  width 
)

Definition at line 1779 of file category.cpp.

1780  {
1781  if (value.find('\n') != std::string::npos or width == 0 or value.length() > 132) // write as text field
1782  {
1783  if (offset > 0)
1784  os << '\n';
1785  os << ';';
1786 
1787  char pc = 0;
1788  for (auto ch : value)
1789  {
1790  if (pc == '\n' and ch == ';')
1791  os << '\\';
1792  os << ch;
1793  pc = ch;
1794  }
1795 
1796  if (value.back() != '\n')
1797  os << '\n';
1798  os << ';' << '\n';
1799  offset = 0;
1800  }
1801  else if (sac_parser::is_unquoted_string(value))
1802  {
1803  os << value;
1804 
1805  if (value.length() < width)
1806  {
1807  os << std::string(width - value.length(), ' ');
1808  offset += width;
1809  }
1810  else
1811  {
1812  os << ' ';
1813  offset += value.length() + 1;
1814  }
1815  }
1816  else
1817  {
1818  bool done = false;
1819  for (char q : { '\'', '"' })
1820  {
1821  auto p = value.find(q); // see if we can use the quote character
1822  while (p != std::string::npos and sac_parser::is_non_blank(value[p + 1]) and value[p + 1] != q)
1823  p = value.find(q, p + 1);
1824 
1825  if (p != std::string::npos)
1826  continue;
1827 
1828  os << q << value << q;
1829 
1830  if (value.length() + 2 < width)
1831  {
1832  os << std::string(width - value.length() - 2, ' ');
1833  offset += width;
1834  }
1835  else
1836  {
1837  os << ' ';
1838  offset += value.length() + 1;
1839  }
1840 
1841  done = true;
1842  break;
1843  }
1844 
1845  if (not done)
1846  {
1847  if (offset > 0)
1848  os << '\n';
1849  os << ';' << value << '\n'
1850  << ';' << '\n';
1851  offset = 0;
1852  }
1853  }
1854 
1855  return offset;
1856  }