Skip to content

Commit

Permalink
trimtrimtrim
Browse files Browse the repository at this point in the history
  • Loading branch information
grencez committed Dec 12, 2023
1 parent ddf3013 commit 77a5e3f
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/cx/alphatab.hh
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/**
* \file alphatab.hh
* Dynamic array.
**/
#ifndef AlphaTab_HH_
#define AlphaTab_HH_
#include <string>

#include "synhax.hh"
extern "C" {
#include "table.h"
}
Expand All @@ -17,6 +15,16 @@ namespace C {
typedef TableT(char) AlphaTab;
}

inline
std::ostream&
operator<<(ostream& out, const C::AlphaTab& a)
{
size_t n = a.sz;
if (n > 0 && a.s[n-1] == '\0') {n -= 1;}
if (n > 0) {out.write(a.s, n);}
return out;
}

class AlphaTab
{
private:
Expand Down Expand Up @@ -114,15 +122,11 @@ public:
bool empty() const {
return (this->size() == 0);
}

friend C::AlphaTab& operator<<(C::AlphaTab& a, const Cx::AlphaTab& b);
};

inline
std::ostream& operator<<(ostream& out, const AlphaTab& a) {
if (a.size() > 0)
out.write(a.data(), a.size());
return out;
return (out << (std::string_view)a);
}

typedef AlphaTab String;
Expand Down

0 comments on commit 77a5e3f

Please sign in to comment.